Example #1
0
    def play(self, item, menuw):
        _debug_('play(item=%r, menuw=%r)' % (item, menuw), 2)

        self.item = item
        self.filename = item.filename
        self.command = item.command
        self.mode = item.mode
        self.menuw = menuw

        if not os.path.isfile(self.filename):
            osd.clearscreen()
            osd.drawstring(_('File "%s" not found!') % self.filename, 30, 280)
            osd.update()
            time.sleep(2.0)
            self.menuw.refresh()
            return 0

        if plugin.getbyname('MIXER'):
            plugin.getbyname('MIXER').reset()

        if plugin.is_active('joy'):
            try:
                plugin.getbyname('JOY').enable(FALSE)
            except Exception, e:
                _debug_('getbyname(\'JOY\')', e, DWARNING)
Example #2
0
    def play(self, item, menuw):
        logger.log( 9, 'play(item=%r, menuw=%r)', item, menuw)

        self.item = item
        self.filename = item.filename
        self.command = item.command
        self.mode = item.mode
        self.menuw = menuw

        if not os.path.isfile(self.filename):
            osd.clearscreen()
            osd.drawstring(_('File "%s" not found!') % self.filename, 30, 280)
            osd.update()
            time.sleep(2.0)
            self.menuw.refresh()
            return 0

        if plugin.getbyname('MIXER'):
            plugin.getbyname('MIXER').reset()

        if plugin.is_active('joy'):
            try:
                plugin.getbyname('JOY').disable()
            except Exception, why:
                logger.warning('getbyname("JOY"): %s', why)
Example #3
0
    def draw_button(self, osd, x, y, w, h, color, action):
        """
        Draw a color button and associated text.
        """
        iconfilename = os.path.join(config.ICON_DIR, 'misc/' + color + 'button.png' )
        iw,ih = osd.drawimage(iconfilename, (x + 5, y + 7,  h - 14, h - 14))

        if isinstance(action, MenuItem):
            string = action.name
        else:
            string = action[1]

        font = osd.get_font('small0')
        osd.drawstring(string, font, None,
                              x = x + 5 + iw, y = y + 5, width = w - iw, height = h - 10,
                              mode = 'soft', align_v='center')
Example #4
0
    def draw_button(self, osd, x, y, w, h, color, action):
        """
        Draw a color button and associated text.
        """
        iconfilename = os.path.join(config.ICON_DIR,
                                    'misc/' + color + 'button.png')
        iw, ih = osd.drawimage(iconfilename, (x + 5, y + 7, -1, -1))

        if isinstance(action, MenuItem):
            string = action.name
        else:
            string = action[1]

        font = osd.get_font('small0')
        osd.drawstring(string,
                       font,
                       None,
                       x=x + 5 + iw,
                       y=y + 5,
                       width=w - iw,
                       height=h - 10,
                       mode='soft',
                       align_v='center')
Example #5
0
    def show(self, force_redraw=False):
        """
        the main drawing function
        """
        if osd.must_lock:
            # only lock s_alpha layer, because only there
            # are pixel operations (round rectangle)
            self.s_alpha.lock()

        if force_redraw:
            _debug_('show, force update', 2)
            self.update_bg = (0, 0, osd.width, osd.height)
            self.update_alpha = []
            self.update_content = []

        update_area = self.update_alpha

        # if the background has some changes ...
        if self.update_bg:
            ux1, uy1, ux2, uy2 = self.update_bg
            for x1, y1, x2, y2, image in self.drawlist.bgimages:
                if not (x2 < ux1 or y2 < uy1 or x1 > ux2 or y1 > uy2):
                    self.s_bg.blit(image, (ux1, uy1),
                                   (ux1 - x1, uy1 - y1, ux2 - ux1, uy2 - uy1))
            update_area.append(self.update_bg)

        # rectangles
        if update_area:
            self.s_alpha.fill((0, 0, 0, 0))
            for x1, y1, x2, y2, bgcolor, size, color, radius in self.drawlist.rectangles:
                # only redraw if necessary
                if self.in_update(x1, y1, x2, y2, update_area):
                    # if the radius and the border is not inside the update area,
                    # use drawbox, it's faster
                    if self.in_update(x1 + size + radius,
                                      y1 + size + radius,
                                      x2 - size - radius,
                                      y2 - size - radius,
                                      update_area,
                                      full=True):
                        osd.drawroundbox(x1,
                                         y1,
                                         x2,
                                         y2,
                                         color=bgcolor,
                                         layer=self.s_alpha)
                    else:
                        osd.drawroundbox(x1,
                                         y1,
                                         x2,
                                         y2,
                                         color=bgcolor,
                                         border_size=size,
                                         border_color=color,
                                         radius=radius,
                                         layer=self.s_alpha)
            # and than blit only the changed parts of the screen
            try:
                for x0, y0, x1, y1 in update_area:
                    self.s_content.blit(self.s_bg, (x0, y0),
                                        (x0, y0, x1 - x0, y1 - y0))
                    self.s_content.blit(self.s_alpha, (x0, y0),
                                        (x0, y0, x1 - x0, y1 - y0))
            except:
                pass

        update_area += self.update_content

        layer = self.s_screen
        for x0, y0, x1, y1 in update_area:
            layer.blit(self.s_content, (x0, y0), (x0, y0, x1 - x0, y1 - y0))

        # if something changed redraw all content objects
        if update_area:
            ux1, uy1, ux2, uy2 = osd.width, osd.height, 0, 0
            for a in update_area:
                ux1 = min(ux1, a[0])
                uy1 = min(uy1, a[1])
                ux2 = max(ux2, a[2])
                uy2 = max(uy2, a[3])

            for x1, y1, x2, y2, image in self.drawlist.images:
                if self.in_update(x1, y1, x2, y2, update_area):
                    layer.blit(image, (ux1, uy1),
                               (ux1 - x1, uy1 - y1, ux2 - ux1, uy2 - uy1))

            for x1, y1, x2, y2, text, font, height, align_h, align_v, mode, \
                    ellipses, dim in self.drawlist.text:
                if self.in_update(x1, y1, x2, y2, update_area):
                    osd.drawstringframed(text,
                                         x1,
                                         y1,
                                         x2 - x1,
                                         height,
                                         font,
                                         align_h=align_h,
                                         align_v=align_v,
                                         mode=mode,
                                         ellipses=ellipses,
                                         dim=dim,
                                         layer=layer)

        if self.drawlist.skin_area:
            for area in self.drawlist.skin_area:
                x, y, w, h, name = area
                osd.drawbox(x, y, x + w, y + h, 1, osd.COL_WHITE, 0, layer)
                osd.drawstring(name,
                               x + 1,
                               y + 1,
                               fgcolor=osd.COL_WHITE,
                               bgcolor=osd.COL_BLUE,
                               layer=layer)
                update_area.append((x, y, x + w, y + h))

        if not update_area:
            return None

        rect = (osd.width, osd.height, 0, 0)
        for u in update_area:
            osd.screenblit(layer, (u[0], u[1]),
                           (u[0], u[1], u[2] - u[0], u[3] - u[1]))
            rect = (min(u[0], rect[0]), min(u[1], rect[1]), max(u[2], rect[2]),
                    max(u[3], rect[3]))
        rect = (rect[0], rect[1], rect[2] - rect[0], rect[3] - rect[1])

        if osd.must_lock:
            self.s_alpha.unlock()

        return rect
Example #6
0
#    shutdown()

except Exception, why:
    _debug_('Crash!: %s' % (why), config.DCRITICAL)
    try:
        tb = sys.exc_info()[2]
        fname, lineno, funcname, text = traceback.extract_tb(tb)[-1]

        if config.FREEVO_EVENTHANDLER_SANDBOX:
            secs = 5
        else:
            secs = 1
        for i in range(secs, 0, -1):
            osd.clearscreen(color=osd.COL_BLACK)
            osd.drawstring(_('Freevo crashed!'),
                           70,
                           70,
                           fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Filename: %s') % fname,
                           70,
                           130,
                           fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Lineno: %s') % lineno,
                           70,
                           160,
                           fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Function: %s') % funcname,
                           70,
                           190,
                           fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Text: %s') % text,
                           70,
Example #7
0
    def show(self, force_redraw=False):
        """
        the main drawing function
        """
        logger.log( 8, 'show(force_redraw=%r)', force_redraw)
        if osd.must_lock:
            # only lock s_alpha layer, because only there
            # are pixel operations (round rectangle)
            self.s_alpha.lock()

        if force_redraw:
            logger.log( 9, 'show, force update')
            self.update_bg      = (0, 0, osd.width, osd.height)
            self.update_alpha   = []
            self.update_content = []

        update_area = self.update_alpha

        # if the background has some changes ...
        if self.update_bg:
            ux1, uy1, ux2, uy2 = self.update_bg
            for x1, y1, x2, y2, image in self.drawlist.bgimages:
                if not (x2 < ux1 or y2 < uy1 or x1 > ux2 or y1 > uy2):
                    self.s_bg.blit(image, (ux1, uy1), (ux1-x1, uy1-y1, ux2-ux1, uy2-uy1))
            update_area.append(self.update_bg)

        # rectangles
        if update_area:
            self.s_alpha.fill((0,0,0,0))
            for x1, y1, x2, y2, bgcolor, size, color, radius in self.drawlist.rectangles:
                # only redraw if necessary
                if self.in_update(x1, y1, x2, y2, update_area):
                    # if the radius and the border is not inside the update area,
                    # use drawbox, it's faster
                    if self.in_update(x1+size+radius, y1+size+radius, x2-size-radius,
                                      y2-size-radius, update_area, full=True):
                        osd.drawroundbox(x1, y1, x2, y2, color=bgcolor,
                                         layer=self.s_alpha)
                    else:
                        osd.drawroundbox(x1, y1, x2, y2, color=bgcolor,
                                         border_size=size, border_color=color,
                                         radius=radius, layer=self.s_alpha)
            # and than blit only the changed parts of the screen
            try:
                for x0, y0, x1, y1 in update_area:
                    self.s_content.blit(self.s_bg, (x0, y0), (x0, y0, x1-x0, y1-y0))
                    self.s_content.blit(self.s_alpha, (x0, y0), (x0, y0, x1-x0, y1-y0))
            except:
                pass

        update_area += self.update_content

        layer = self.s_screen
        for x0, y0, x1, y1 in update_area:
            layer.blit(self.s_content, (x0, y0), (x0, y0, x1-x0, y1-y0))

        # if something changed redraw all content objects
        if update_area:
            ux1, uy1, ux2, uy2 = osd.width, osd.height, 0, 0
            for a in update_area:
                ux1 = min(ux1, a[0])
                uy1 = min(uy1, a[1])
                ux2 = max(ux2, a[2])
                uy2 = max(uy2, a[3])

            for x1, y1, x2, y2, image in self.drawlist.images:
                if self.in_update(x1, y1, x2, y2, update_area):
                    layer.blit(image, (ux1, uy1), (ux1-x1, uy1-y1, ux2-ux1, uy2-uy1))

            for x1, y1, x2, y2, text, font, height, align_h, align_v, mode, \
                    ellipses, dim in self.drawlist.text:
                if self.in_update(x1, y1, x2, y2, update_area):
                    osd.drawstringframed(text, x1, y1, x2 - x1, height, font,
                                         align_h = align_h,
                                         align_v = align_v, mode=mode,
                                         ellipses=ellipses, dim=dim, layer=layer)

        if self.drawlist.skin_area:
            for area in self.drawlist.skin_area:
                x,y,w,h,name = area
                osd.drawbox(x,y,x + w, y +h, 1, osd.COL_WHITE, 0, layer)
                osd.drawstring(name, x + 1, y + 1, fgcolor=osd.COL_WHITE, bgcolor=osd.COL_BLUE, layer=layer)
                update_area.append((x,y,x+w,y+h))

        if not update_area:
            return None

        rect = (osd.width, osd.height, 0, 0)
        for u in update_area:
            osd.screenblit(layer, (u[0], u[1]), (u[0], u[1], u[2]-u[0], u[3]-u[1]))
            rect = ( min(u[0], rect[0]), min(u[1], rect[1]),
                     max(u[2], rect[2]), max(u[3], rect[3]))
        rect = (rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1])

        if osd.must_lock:
            self.s_alpha.unlock()

        return rect
Example #8
0
except SystemExit, why:
    print 'Freevo %s exited' % (version.version,)

except Exception, why:
    logger.fatal('Crash!', exc_info=True)
    try:
        tb = sys.exc_info()[2]
        fname, lineno, funcname, text = traceback.extract_tb(tb)[-1]

        if config.FREEVO_EVENTHANDLER_SANDBOX:
            secs = 5
        else:
            secs = 1
        for i in range(secs, 0, -1):
            osd.clearscreen(color=osd.COL_BLACK)
            osd.drawstring(_('Freevo crashed!'), 70, 70, fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Filename: %s') % fname, 70, 130, fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Lineno: %s') % lineno, 70, 160, fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Function: %s') % funcname, 70, 190, fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Text: %s') % text, 70, 220, fgcolor=osd.COL_ORANGE)
            osd.drawstring(str(sys.exc_info()[1]), 70, 280, fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Please see the logfiles for more info'), 70, 350, fgcolor=osd.COL_ORANGE)
            osd.drawstring(_('Exit in %s seconds') % i, 70, 410, fgcolor=osd.COL_ORANGE)
            osd.update()
            time.sleep(1)

    except:
        pass
    traceback.print_exc()

    # Shutdown the application, but not the system even if that is