Exemplo n.º 1
0
    def init_page(self):

        menu = self.menustack[-1]
        if not menu:
            return

        # Create the list of main selection items (menu_items)
        menu_items = []
        first = menu.page_start
        self.rows, self.cols = menu.items_per_page()

        for choice in menu.choices[first:first + (self.rows * self.cols)]:
            menu_items.append(choice)

        self.rows, self.cols = menu.items_per_page()

        self.menu_items = menu_items

        if len(menu_items) == 0:
            self.all_items = menu_items + [
                MenuItem('Back', self.back_one_menu)
            ]
        else:
            self.all_items = menu_items

        if not menu.selected in self.all_items:
            menu.selected = self.all_items[0]

        if not menu.choices:
            menu.selected = self.all_items[0]

        rc.post_event(MENU_PROCESS_END)

        # make sure we are in context 'menu'
        rc.set_context(self.event_context)
Exemplo n.º 2
0
    def __init__(self, parent='osd', x=None, y=None, width=0, height=0):
        GUIObject.__init__(self, x, y, width, height)

        if not parent or parent == 'osd':
            parent = self.osd.app_list[0]

        parent.add_child(self)

        self.osd.add_app(self)

        self.event_context = 'input'
        _debug_('window: setting context to %s' % self.event_context, 2)
        rc.set_context(self.event_context)

        if not width:
            self.width = self.osd.width / 2

        if not height:
            self.height = self.osd.height / 4

        if not self.left:
            self.left = self.osd.width / 2 - self.width / 2

        if not self.top:
            self.top = self.osd.height / 2 - self.height / 2
            self.center_on_screen = True

        self.internal_h_align = Align.CENTER
        self.internal_v_align = Align.CENTER
Exemplo n.º 3
0
 def chapter(self):
     if self.schapter == None:
         rc.app(self)
         rc.set_context('input')
         self.pop = PopupBox(_('Choose title to play. <1-9>'))
         self.pop.show()
     else:
         self.play()
Exemplo n.º 4
0
 def remove_app(self, app):
     _times = self.app_list.count(app)
     for _time in range(_times):
         self.app_list.remove(app)
     if _times and hasattr(self.focused_app(), 'event_context'):
         _debug_('app is %s' % self.focused_app(),2)
         _debug_('osd: Setting context to %s' % self.focused_app().get_event_context(),2)
         rc.set_context(self.focused_app().get_event_context())
Exemplo n.º 5
0
    def refresh(self):
        """refresh the guide

        This function is called automatically by freevo whenever this menu is
        opened or reopened.
        """
        _debug_('Refresh', 2)
        if not self.menuw.children:
            rc.set_context(self.event_context)
            self.menuw.refresh()
        self.update(force=True)
Exemplo n.º 6
0
 def show(self, menuw):
     """
     Display the screen and make it the active 'menu'.
     menuw - The menu widget to push this screen onto.
     """
     self.menuw = menuw
     menuw.pushmenu(self)
     if hasattr(self, 'event_context'):
         _debug_(
             'scrollabletext_screen: setting context to %s' %
             self.event_context, 2)
         rc.set_context(self.event_context)
Exemplo n.º 7
0
    def refresh(self, force_update=True):
        """refresh the guide

        This function is called automatically by freevo whenever this menu is
        opened or reopened.
        """
        _debug_('refresh(force_update=True)', 2)
        if self.menuw.children:
            return
        _debug_('tvguide: setting context to %s' % self.event_context, 2)
        rc.set_context(self.event_context)
        self.update(force_update)
        skin.draw(self.type, self)
Exemplo n.º 8
0
    def play_dvd(self, arg=None, menuw=None):
        self.schapter = None
        self.selected = None

        if len(self.files) > 1:
            rc.app(self)
            rc.set_context('input')
            self.pop = PopupBox(
                _('Choose disc (%i discs available).' % len(self.files)))
            self.pop.show()
        else:
            self.selected = 1
            self.chapter()
Exemplo n.º 9
0
    def show(self, menuw):
        """
        Display the screen and make it the active 'menu'.

        @param menuw: The menu widget to push this screen onto.
        """
        self.menuw = menuw
        self.transition = skin.TRANSITION_IN
        menuw.pushmenu(self)
        self.transition = False
        if hasattr(self, 'event_context'):
            logger.log( 9, 'scrollabletext_screen: setting context to %s', self.event_context)
            rc.set_context(self.event_context)
Exemplo n.º 10
0
    def show(self, menuw):
        """
        Display the screen and make it the active 'menu'.

        @param menuw: The menu widget to push this screen onto.
        """
        self.menuw = menuw
        self.transition = skin.TRANSITION_IN
        menuw.pushmenu(self)
        self.transition = False
        if hasattr(self, 'event_context'):
            logger.log(9, 'scrollabletext_screen: setting context to %s',
                       self.event_context)
            rc.set_context(self.event_context)
Exemplo n.º 11
0
 def reset_seek(self):
     _debug_('seek timeout')
     self.seek = 0
     rc.set_context('video')
Exemplo n.º 12
0
    def eventhandler(self, event, menuw=None):
        """
        eventhandler for mplayer control. If an event is not bound in this
        function it will be passed over to the items eventhandler
        """
        if not self.app:
            return self.item.eventhandler(event)

        for p in self.plugins:
            if p.eventhandler(event):
                return True

        if event == VIDEO_MANUAL_SEEK:
            self.seek = 0
            rc.set_context('input')
            self.app.write('osd_show_text "input"\n')
            return True

        if event.context == 'input':
            if event in INPUT_ALL_NUMBERS:
                self.reset_seek_timeout()
                self.seek = self.seek * 10 + int(event)
                return True

            elif event == INPUT_ENTER:
                self.seek_timer.cancel()
                self.seek *= 60
                self.app.write('seek ' + str(self.seek) + ' 2\n')
                _debug_("seek " + str(self.seek) + " 2\n")
                self.seek = 0
                rc.set_context('video')
                return True

            elif event == INPUT_EXIT:
                _debug_('seek stopped')
                #self.app.write('seek stopped\n')
                self.seek_timer.cancel()
                self.seek = 0
                rc.set_context('video')
                return True

        if event == STOP:
            self.stop()
            return self.item.eventhandler(event)

        if event == 'AUDIO_ERROR_START_AGAIN':
            self.stop()
            self.play(self.options, self.item)
            return True

        if event in (PLAY_END, USER_END):
            self.stop()
            return self.item.eventhandler(event)

        if event == VIDEO_SEND_MPLAYER_CMD:
            self.app.write('%s\n' % event.arg)
            return True

        if event == TOGGLE_OSD:
            self.app.write('osd\n')
            return True

        if event == PAUSE or event == PLAY:
            self.app.write('pause\n')
            return True

        if event == SEEK:
            if event.arg > 0 and self.item_length != -1 and self.dynamic_seek_control:
                # check if the file is growing
                if self.item_info.get_endpos() == self.item_length:
                    # not growing, deactivate this
                    self.item_length = -1

                self.dynamic_seek_control = False

            if event.arg > 0 and self.item_length != -1:
                # safety time for bad mplayer seeking
                seek_safety_time = 20
                if self.item_info['type'] in ('MPEG-PES', 'MPEG-TS'):
                    seek_safety_time = 500

                # check if seek is allowed
                if self.item_length <= self.item.elapsed + event.arg + seek_safety_time:
                    # get new length
                    self.item_length = self.item_info.get_endpos()

                # check again if seek is allowed
                if self.item_length <= self.item.elapsed + event.arg + seek_safety_time:
                    _debug_('unable to seek %s secs at time %s, length %s' % \
                            (event.arg, self.item.elapsed, self.item_length))
                    self.app.write('osd_show_text "%s"\n' %
                                   _('Seeking not possible'))
                    return False

            self.app.write('seek %s\n' % event.arg)
            return True

        if event == OSD_MESSAGE:
            self.app.write('osd_show_text "%s"\n' % event.arg)
            return True

        # nothing found? Try the eventhandler of the object who called us
        return self.item.eventhandler(event)