def __init__(self, *args, **kwargs): kodigui.BaseWindow.__init__(self, *args, **kwargs) util.setGlobalProperty('action.button1.busy', '') util.setGlobalProperty('action.button2.busy', '') self.itemCount = kwargs.get('item_count') self.itemPos = kwargs.get('item_pos') self.skipped = {} self.lastUnskipped = self.itemPos self.init(kwargs)
def refreshInfo(self): oldFocusId = self.getFocusId() util.setGlobalProperty('hide.resume', '' if self.video.viewOffset.asInt() else '1') self.setInfo() xbmc.sleep(100) if oldFocusId == self.PLAY_BUTTON_ID: self.focusPlayButton()
def doCallback(self): if not self.callback: self.action = None return False if self.action != 'watch': if self.button1 and self.button1[0] == self.action: util.setGlobalProperty('action.button1.busy', '1') elif self.button2 and self.button2[0] == self.action: util.setGlobalProperty('action.button2.busy', '1') action = self.action self.action = None try: changes = self.callback(self.object, action) finally: util.setGlobalProperty('action.button1.busy', '') util.setGlobalProperty('action.button2.busy', '') if not changes: return False self.button1 = changes.get('button1') self.button2 = changes.get('button2') self.titleIndicator = changes.get('title_indicator', '') self.start = changes.get('start', '') self.updateDisplayProperties() return True
def setFilter(self, filter_=False): if filter_ is False: filter_ = self.filter ret = True if filter_ == self.filter: ret = False self.filter = filter_ util.setGlobalProperty('section', self.section) util.setGlobalProperty('guide.filter', [t[1] for t in self.types if t[0] == filter_][0]) return ret
def disconnect(self): self.current = None self.showMenu() for key in self.windows.keys(): util.DEBUG_LOG('Closing window: {0}'.format(key)) self.windows[key].doClose() self.windows[key].close() del self.windows[key] util.setGlobalProperty('menu.visible', '') self.menu.doClose() del self.menu self.menu = None
def start(self): self.menu = MenuDialog.create() while True: util.setGlobalProperty('menu.visible', '1') self.menu.modal() if not self.current: return self.waitOnWindow() if not self.current: return if self.exit: return
def create(self): self.setStartID(100 + len(self.paths)) self.maxEnd = 99 + len(self.paths) xml = '' posy = 0 for idx, p in enumerate(self.paths): chanID = self.nextID() chanLabelID = self.nextID() airingsXML = '' slots = [] airingsXML += self.CHANNEL_LABEL_BASE_XML.format(ID=chanLabelID) for x in range(self.ITEMS_PER_ROW): ID = self.nextID() if not x: width = 1100 first = ID else: width = 1 slots.append(ID) util.setGlobalProperty('badge.color.{0}'.format(ID), '00FFFFFF') airingsXML += self.AIRING_BASE_XML.format(ID=ID, WIDTH=width) airingsXML += self.END_BUTTON_XML.format(100 + idx) xml += self.CHANNEL_BASE_XML.format(ID=chanID, AIRINGS_XML=airingsXML, POSY=posy, PATH=p.rsplit('/', 1)[-1], FIRST=first) data = {'ID': chanID, 'label': chanLabelID, 'slots': slots} self.channels[p] = data posy += 52 with open(self.BASE_XML_PATH, 'r') as f: with open(self.OUTPUT_PATH, 'w') as o: o.write(f.read().replace('<!-- GENERATED CONTENT -->', xml)) return self
def open(self, window): self.last = self.current if self.current and self.current.name == window.name: return True current = self.current if current: current.doClose() current.close() util.setGlobalProperty('WM.error', '') if window.name in self.windows: self.current = self.windows[window.name] self.current.show() else: if window.usesGenerate: util.setGlobalProperty('WM.busy', '1') try: self.current = window.generate() finally: util.setGlobalProperty('WM.busy', '') else: self.current = window.create() if self.current: self.windows[window.name] = self.current else: # self.current = current # if self.current: # self.current.show() return False return True
def updateGridItem(self, airing, ID): if airing.conflicted: util.setGlobalProperty('badge.color.{0}'.format(ID), 'FFD93A34') elif airing.scheduled: util.setGlobalProperty('badge.color.{0}'.format(ID), 'FFFF8000') else: util.setGlobalProperty('badge.color.{0}'.format(ID), '00FFFFFF')
def finish(self): if not xbmcgui.Dialog().yesno('Exit?', 'Close Tablo?'): return False self.saveCurrent() self.exit = True self.showMenu() self.current = None for key in self.windows.keys(): util.DEBUG_LOG('Closing window: {0}'.format(key)) self.windows[key].doClose() self.windows[key].close() del self.windows[key] util.setGlobalProperty('menu.visible', '') self.menu.doClose() del self.menu self.menu = None return True
def __init__(self): util.setGlobalProperty('WM.error', '') util.setGlobalProperty('WM.busy', '') util.setGlobalProperty('menu.visible', '1') self.menu = None self.current = None self.last = None self.windows = {} self.waiting = False self.exit = False
def setBusy(on=True): util.setGlobalProperty('background.busy', on and '1' or '')
import kodigui from lib import util util.setGlobalProperty('background.busy', '') util.setGlobalProperty('background.shutdown', '') util.setGlobalProperty('background.splash', '') class BackgroundWindow(kodigui.BaseWindow): xmlFile = 'script-plex-background.xml' path = util.ADDON.getAddonInfo('path') theme = 'Main' res = '1080i' width = 1920 height = 1080 def __init__(self, *args, **kwargs): kodigui.BaseWindow.__init__(self, *args, **kwargs) self.function = kwargs.get('function') def onFirstInit(self): self.function() self.doClose() def setBusy(on=True): util.setGlobalProperty('background.busy', on and '1' or '') def setSplash(on=True): util.setGlobalProperty('background.splash', on and '1' or '')
def setError(self, error): util.setGlobalProperty('WM.error', error)
def hideMenu(self): if not self.current: return util.setGlobalProperty('menu.visible', '') self.menu.doClose() self.current.onWindowFocus()
def updateChannelAirings(self, path): genData = self.gen.channels[path] pos = self.gen.paths.index(path) pathID = path.rsplit('/', 1)[-1] self.setProperty('started.{0}'.format(pathID), '') totalwidth = 0 self.setProperty('nodata.{0}'.format(path.rsplit('/', 1)[-1]), '') row = [] slot = -1 atEnd = False for slot, airing in enumerate( self.grid.airings( self.hhData.halfHour, min(self.hhData.maxHalfHour, self.hhData.cutoff), path)): try: ID = genData['slots'][slot] except IndexError: break self.slotButtons[ID] = airing control = self.getControl(ID) if airing.conflicted: util.setGlobalProperty('badge.color.{0}'.format(ID), 'FFD93A34') elif airing.scheduled: util.setGlobalProperty('badge.color.{0}'.format(ID), 'FFFF8000') else: util.setGlobalProperty('badge.color.{0}'.format(ID), '00FFFFFF') if airing.airingNow(self.hhData.halfHour): if self.hhData.offsetHalfHours != 0 and self.hhData.halfHour != airing.datetime: self.setProperty('started.{0}'.format(pathID), '1') duration = airing.secondsToEnd(start=self.hhData.halfHour) else: duration = airing.duration row.append((ID, airing, duration < 1800 and True or False)) if airing.datetimeEnd >= self.hhData.cutoff: atEnd = True if airing.datetimeEnd > self.hhData.cutoff: duration -= tablo.compat.timedelta_total_seconds( airing.datetimeEnd - self.hhData.cutoff) if airing.qualifiers: new = 'new' in airing.qualifiers and u'[COLOR FF2F8EC0]{0}:[/COLOR] '.format( T(32159)) or u'' live = 'live' in airing.qualifiers and u'[COLOR FF2F8EC0]{0}:[/COLOR] '.format( T(32160)) or u'' label = u'{0}{1}'.format(new or live, airing.title) else: label = airing.title width = int(round((duration / 1800.0) * self.gen.HALF_HOUR_WIDTH)) save = width if totalwidth > 1110: self.offButtons[ID] = True control.setVisible(False) else: if totalwidth + width > 1110: width = 1110 - totalwidth if width < self.gen.HALF_HOUR_WIDTH: self.offButtons[ID] = True control.setVisible(True) totalwidth += save control.setRadioDimension(width - 31, 1, 30, 30) control.setWidth(width) if width > 34: control.setLabel(label) else: control.setLabel(' ') if slot == -1 or (totalwidth < 1110 and not atEnd): slot += 1 ID = genData['slots'][slot] util.setGlobalProperty('badge.color.{0}'.format(ID), '00FFFFFF') control = self.getControl(ID) control.setSelected(False) control.setWidth(1110 - totalwidth) if self.grid.hasNoData(path): control.setLabel(' ') self.setProperty('nodata.{0}'.format(pathID), '1') else: control.setLabel('Loading...') control.setVisible(True) self.slotButtons[ID] = None row.append((ID, None, False)) for slot in range(slot + 1, self.gen.ITEMS_PER_ROW): ID = genData['slots'][slot] self.setProperty('badge.color.{0}'.format(ID), '00FFFFFF') control = self.getControl(ID) control.setSelected(False) control.setVisible(False) control.setLabel('') self.slotButtons[ID] = None self.rows[pos] = row
def setSplash(on=True): util.setGlobalProperty('background.splash', on and '1' or '')
def setShutdown(on=True): util.setGlobalProperty('background.shutdown', on and '1' or '')
def updateChannelAirings(self, path): genData = self.gen.channels[path] pos = self.gen.paths.index(path) pathID = path.rsplit('/', 1)[-1] self.setProperty('started.{0}'.format(pathID), '') totalwidth = 0 self.setProperty('nodata.{0}'.format(path.rsplit('/', 1)[-1]), '') row = [] slot = -1 atEnd = False for slot, airing in enumerate(self.grid.airings(self.hhData.halfHour, min(self.hhData.maxHalfHour, self.hhData.cutoff), path)): try: ID = genData['slots'][slot] except IndexError: break self.slotButtons[ID] = airing control = self.getControl(ID) if airing.conflicted: util.setGlobalProperty('badge.color.{0}'.format(ID), 'FFD93A34') elif airing.scheduled: util.setGlobalProperty('badge.color.{0}'.format(ID), 'FFFF8000') else: util.setGlobalProperty('badge.color.{0}'.format(ID), '00FFFFFF') if airing.airingNow(self.hhData.halfHour): if self.hhData.offsetHalfHours != 0 and self.hhData.halfHour != airing.datetime: self.setProperty('started.{0}'.format(pathID), '1') duration = airing.secondsToEnd(start=self.hhData.halfHour) else: duration = airing.duration row.append((ID, airing, duration < 1800 and True or False)) if airing.datetimeEnd >= self.hhData.cutoff: atEnd = True if airing.datetimeEnd > self.hhData.cutoff: duration -= tablo.compat.timedelta_total_seconds(airing.datetimeEnd - self.hhData.cutoff) if airing.qualifiers: new = 'new' in airing.qualifiers and u'[COLOR FF2F8EC0]{0}:[/COLOR] '.format(T(32159)) or u'' live = 'live' in airing.qualifiers and u'[COLOR FF2F8EC0]{0}:[/COLOR] '.format(T(32160)) or u'' label = u'{0}{1}'.format(new or live, airing.title) else: label = airing.title width = int(round((duration / 1800.0) * self.gen.HALF_HOUR_WIDTH)) save = width if totalwidth > 1110: self.offButtons[ID] = True control.setVisible(False) else: if totalwidth + width > 1110: width = 1110 - totalwidth if width < self.gen.HALF_HOUR_WIDTH: self.offButtons[ID] = True control.setVisible(True) totalwidth += save control.setRadioDimension(width - 31, 1, 30, 30) control.setWidth(width) if width > 34: control.setLabel(label) else: control.setLabel(' ') if slot == -1 or (totalwidth < 1110 and not atEnd): slot += 1 ID = genData['slots'][slot] util.setGlobalProperty('badge.color.{0}'.format(ID), '00FFFFFF') control = self.getControl(ID) control.setSelected(False) control.setWidth(1110 - totalwidth) if self.grid.hasNoData(path): control.setLabel(' ') self.setProperty('nodata.{0}'.format(pathID), '1') else: control.setLabel('Loading...') control.setVisible(True) self.slotButtons[ID] = None row.append((ID, None, False)) for slot in range(slot + 1, self.gen.ITEMS_PER_ROW): ID = genData['slots'][slot] self.setProperty('badge.color.{0}'.format(ID), '00FFFFFF') control = self.getControl(ID) control.setSelected(False) control.setVisible(False) control.setLabel('') self.slotButtons[ID] = None self.rows[pos] = row