Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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)
Exemplo n.º 3
0
    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()
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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
Exemplo n.º 7
0
    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
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
    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
Exemplo n.º 11
0
    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
Exemplo n.º 12
0
    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
Exemplo n.º 13
0
    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
Exemplo n.º 14
0
    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
Exemplo n.º 15
0
 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')
Exemplo n.º 16
0
 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')
Exemplo n.º 17
0
    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
Exemplo n.º 18
0
    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
Exemplo n.º 19
0
    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
Exemplo n.º 20
0
 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
Exemplo n.º 21
0
 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
Exemplo n.º 22
0
def setBusy(on=True):
    util.setGlobalProperty('background.busy', on and '1' or '')
Exemplo n.º 23
0
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 '')
Exemplo n.º 24
0
 def setError(self, error):
     util.setGlobalProperty('WM.error', error)
Exemplo n.º 25
0
 def hideMenu(self):
     if not self.current:
         return
     util.setGlobalProperty('menu.visible', '')
     self.menu.doClose()
     self.current.onWindowFocus()
Exemplo n.º 26
0
    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
Exemplo n.º 27
0
 def setError(self, error):
     util.setGlobalProperty('WM.error', error)
Exemplo n.º 28
0
 def hideMenu(self):
     if not self.current:
         return
     util.setGlobalProperty('menu.visible', '')
     self.menu.doClose()
     self.current.onWindowFocus()
Exemplo n.º 29
0
def setSplash(on=True):
    util.setGlobalProperty('background.splash', on and '1' or '')
Exemplo n.º 30
0
def setShutdown(on=True):
    util.setGlobalProperty('background.shutdown', on and '1' or '')
Exemplo n.º 31
0
    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