Esempio n. 1
0
 def killall(self):
     """
     Kills all animations
     """
     for a in self.animations:
         a.remove()
     rc.unregister(self.update)
Esempio n. 2
0
    def stop(self, cmd=''):
        """
        stop the child
        """
        logger.log( 9, 'ChildApp2.stop(cmd=%r)', cmd)
        self.timer.stop()
        rc.unregister(self.stop)

        if cmd and self.isAlive():
            self.write(cmd)
            # wait for the app to terminate itself
            for i in range(60):
                if not self.isAlive():
                    break
                time.sleep(0.1)

        # kill the app
        if self.isAlive():
            self.kill()

        # Ok, we can use the OSD again.
        if self.stop_osd:
            osd.restart()

        if self.is_video:
            rc.post_event(Event(VIDEO_END))
Esempio n. 3
0
    def stop(self, cmd=''):
        """
        stop the child
        """
        rc.unregister(self.poll)
        rc.unregister(self.stop)

        if cmd and self.isAlive():
            _debug_('sending exit command to app \"%r\"' % cmd)
            self.write(cmd)
            # wait for the app to terminate itself
            for i in range(60):
                if not self.isAlive():
                    break
                time.sleep(0.1)

        # kill the app
        self.kill()

        # Ok, we can use the OSD again.
        if self.stop_osd:
            osd.restart()

        if self.is_video:
            rc.post_event(Event(VIDEO_END))
Esempio n. 4
0
 def hide(self):
     """
     used when hiding the bar
     """
     self.status = BAR_HIDE
     self.render = []
     self.player = None
     self.Timer = None
     self.bar = None
     rc.unregister(self.update)
Esempio n. 5
0
    def update_wait(self):
        """
        This is used while starting freevo
        """
        if osd._singleton == None:
            return

        if self.osd == None:
            self.osd = osd.get_singleton()
            rc.unregister(self.update)
            self.update = self.update_enabled
            rc.register(self.update, True, 0)
Esempio n. 6
0
    def kill(self, anim_object):
        """
        Kill an animation
        """

        try:
            i = self.animations.index(anim_object)
            self.animations[i].remove()
        except:
            pass
        if len(self.animations) == 0:
            # no more animations, unregister ourself to the main loop:
            rc.unregister(self.update)
Esempio n. 7
0
 def hide(self):
     """
     used when hiding the bar
     """
     _debug_('hide(self)', 2)
     self.status = BAR_HIDE
     self.render = []
     self.player = None
     self.Timer  = None
     self.bar    = None
     if self.update_registered:
         rc.unregister(self.update)
         self.update_registered = False
Esempio n. 8
0
    def update_enabled(self):
        """
        This is the draw method for animations
        """
        render = []
        add = render.append
        remove = self.animations.remove
        i = 0

        timer = pygame.time.get_ticks()

        for a in copy.copy(self.animations):

            # XXX something should be done to clean up the mess
            if a.delete:
                self.animations.remove(a)
                if len(self.animations) == 0:
                    # no more animations, unregister ourself to the main loop:
                    rc.unregister(self.update)
                continue

            if a.active:
                r = a.poll(timer)
                if r:
                    i += 1
                    add(r)
            # XXX something might be done to handle stopped animations
            else:
                pass

        # only invoke osd singleton if there are updates
        # since this is a potential time hog
        if len(render) > 0:
            rects = []
            for (rect, surf) in render:
                self.osd.putsurface(surf, rect.left, rect.top)
                rects.append(rect)

            if len(rects) > 0:
                self.osd.update(rects)
Esempio n. 9
0
    def eventhandler(self, event, menuw=None):
        #print 'eventhandler(self, event=%s, menuw=%s)' % (event, menuw)
        if event == PAUSE or event == PLAY:
            if self.slideshow:
                rc.post_event(Event(OSD_MESSAGE, arg=_('pause')))
                self.slideshow = False
                rc.unregister(self.signalhandler)
                self.signal_registered = False
            else:
                rc.post_event(Event(OSD_MESSAGE, arg=_('play')))
                self.slideshow = True
                rc.register(self.signalhandler, False, 100)
                self.signal_registered = True
            return True

        elif event == STOP:
            self.last_image = None, None
            self.signal_registered = False
            rc.unregister(self.signalhandler)
            rc.app(None)
            self.fileitem.eventhandler(event)
            return True

        # up and down will stop the slideshow and pass the
        # event to the playlist
        elif event == PLAYLIST_NEXT or event == PLAYLIST_PREV:
            self.signal_registered = False
            rc.unregister(self.signalhandler)
            self.fileitem.eventhandler(event)
            return True

        # rotate image
        elif event == IMAGE_ROTATE:
            if event.arg == 'left':
                self.rotation = (self.rotation + 270) % 360
            else:
                self.rotation = (self.rotation + 90) % 360
            self.fileitem['rotation'] = self.rotation
            self.view(self.fileitem, zoom=self.zoom, rotation=self.rotation)
            return True

        # print image information
        elif event == TOGGLE_OSD:
            self.osd_mode = (self.osd_mode +
                             1) % (len(config.IMAGEVIEWER_OSD) + 1)
            # Redraw
            self.view(self.fileitem, zoom=self.zoom, rotation=self.rotation)
            return True

        # zoom to one third of the image
        # 1 is upper left, 9 is lower right, 0 zoom off
        elif str(event) in self.zoom_btns:
            self.zoom = self.zoom_btns[str(event)]

            if self.zoom:
                # Zoom one third of the image, don't load the next
                # image in the list
                self.view(self.fileitem,
                          zoom=self.zoom,
                          rotation=self.rotation)
            else:
                # Display entire picture, don't load next image in case
                # the user wants to zoom around some more.
                self.view(self.fileitem, zoom=0, rotation=self.rotation)
            return True

        elif event == IMAGE_MOVE:
            coord = event.arg
            if isinstance(self.zoom, int):
                self.zoom = self.zoom, coord[0], coord[1]
            else:
                self.zoom = self.zoom[
                    0], self.zoom[1] + coord[0], self.zoom[2] + coord[1]
            self.view(self.fileitem, zoom=self.zoom, rotation=self.rotation)
            return True

        # save the image with the current rotation
        elif event == IMAGE_SAVE:
            if self.rotation and os.path.splitext(self.filename)[1] == ".jpg":
                cmd = 'jpegtran -copy all -rotate %s -outfile /tmp/freevo-iview %s' \
                      % ((self.rotation + 180) % 360, self.filename)
                os.system(cmd)
                os.system('mv /tmp/freevo-iview %s' % self.filename)
                self.rotation = 0
                self.osd.bitmapcache.__delitem__(self.filename)
                return True

        else:
            return self.fileitem.eventhandler(event)