Author: dmeyer
Date: Sat Jan 20 20:21:16 2007
New Revision: 9017

Removed:
   trunk/ui/src/audio/plugins/detach.py
Modified:
   trunk/ui/src/audio/player.py
   trunk/ui/src/image/plugins/apod.py
   trunk/ui/src/image/viewer.py

Log:
adjust to new application style

Modified: trunk/ui/src/audio/player.py
==============================================================================
--- trunk/ui/src/audio/player.py        (original)
+++ trunk/ui/src/audio/player.py        Sat Jan 20 20:21:16 2007
@@ -42,11 +42,11 @@
 
 # Freevo imports
 import config
-import gui
-import gui.areas
 
 from event import *
-from application import Application
+from application import Application, STATUS_RUNNING, STATUS_STOPPING, \
+        STATUS_STOPPED, STATUS_IDLE, CAPABILITY_TOGGLE, CAPABILITY_PAUSE, \
+        CAPABILITY_FULLSCREEN
 
 import logging
 log = logging.getLogger('audio')
@@ -73,16 +73,11 @@
     basic object to handle the different player
     """
     def __init__(self):
-        Application.__init__(self, 'audioplayer', 'audio', False, True)
+        capabilities = (CAPABILITY_TOGGLE, CAPABILITY_PAUSE)
+        Application.__init__(self, 'audioplayer', 'audio', capabilities)
         self.player = kaa.popcorn.Player()
         self.player.signals['failed'].connect_weak(self._play_failed)
-        self.running    = False
-        self.bg_playing = False
         self.elapsed_timer = kaa.notifier.WeakTimer(self.elapsed)
-        
-        # register player to the skin
-        areas = ('screen', 'title', 'view', 'info')
-        self.draw_engine = gui.areas.Handler('player', areas)
 
 
     def play(self, item, player=None):
@@ -94,18 +89,21 @@
         #     return
 
         self.item = item
-        self.running = True
 
-        if self.bg_playing:
-            log.info('start new background playing')
+        # Calculate some new values
+        if not self.item.length:
+            self.item.remain = 0
         else:
-            self.show()
+            self.item.remain = self.item.length - self.item.elapsed
+
+        # set the current item to the gui engine
+        self.engine.set_item(self.item)
+        self.status = STATUS_RUNNING
 
         self.player.open(self.item.url)
         self.player.signals['end'].connect_once(PLAY_END.post, self.item)
         self.player.signals['start'].connect_once(PLAY_START.post, self.item)
         self.player.play()
-        self.refresh()
 
 
     def _play_failed(self):
@@ -130,36 +128,7 @@
         # This function doesn't use the Application.stop() code here
         # because we stop and it is stopped when the child is dead.
         self.player.stop()
-        self.running = False
-
-
-    def show(self):
-        """
-        show the player gui
-        """
-        Application.show(self)
-        self.bg_playing = False
-        self.refresh()
-        self.draw_engine.show(config.GUI_FADE_STEPS)
-
-        # post event for showing visualizations
-        # FIXME: maybe this is a Signal
-        AUDIO_VISUAL_SHOW.post()
-
-
-    def hide(self):
-        """
-        hide the player gui
-        """
-        Application.hide(self)
-        self.draw_engine.hide(config.GUI_FADE_STEPS)
-        # DOES NOT WORK
-        # if self.running:
-        #   self.bg_playing = True
-
-        # post event for hiding visualizations
-        # FIXME: maybe this is a Signal
-        AUDIO_VISUAL_HIDE.post()
+        self.status = STATUS_STOPPING
 
 
     def elapsed(self):
@@ -167,22 +136,13 @@
         Callback for elapsed time changes.
         """
         self.item.elapsed = round(self.player.get_position())
-        self.refresh()
-
-
-    def refresh(self):
-        """
-        update the screen
-        """
-        if not self.visible or not self.running:
-            return
         # Calculate some new values
         if not self.item.length:
             self.item.remain = 0
         else:
             self.item.remain = self.item.length - self.item.elapsed
         # redraw
-        self.draw_engine.draw(self.item)
+        self.engine.update()
 
 
     def eventhandler(self, event):
@@ -207,9 +167,11 @@
             # Now the player has stopped (either we called self.stop() or the
             # player stopped by itself. So we need to set the application to
             # to stopped.
-            self.stopped()
+            self.status = STATUS_STOPPED
             self.elapsed_timer.stop()
             self.item.eventhandler(event)
+            if self.status == STATUS_STOPPED:
+                self.status = STATUS_IDLE
             return True
 
         if event == PAUSE:

Modified: trunk/ui/src/image/plugins/apod.py
==============================================================================
--- trunk/ui/src/image/plugins/apod.py  (original)
+++ trunk/ui/src/image/plugins/apod.py  Sat Jan 20 20:21:16 2007
@@ -45,7 +45,7 @@
 from menu import Item, Action, ActionItem, Menu
 from image import ImageItem
 
-from gui.windows import MessageBox, WaitBox
+from application import TextWindow, MessageWindow
 
 
 class ApodMainMenuItem(Item):
@@ -100,14 +100,14 @@
         if items:
             self.pushmenu(Menu(_('Apod Pictures'), items))
         else:
-            MessageBox(_('No Images found')).show()
+            MessageWindow(_('No Images found')).show()
 
 
     def fetch_current_picture(self):
         """
         Fetch current picture.
         """
-        box = WaitBox(text=_('Getting picture, please wait'))
+        box = TextWindow(text=_('Getting picture, please wait'))
         box.show()
 
         thread = Thread(self.__fetch_current_picture_thread)
@@ -146,7 +146,7 @@
         box.destroy()
         if not isinstance(error, (str, unicode)):
             error = 'Exception: %s' % error
-        MessageBox(error).show()
+        MessageWindow(error).show()
 
 
     def __fetch_current_picture_finished(self, filename, box):

Modified: trunk/ui/src/image/viewer.py
==============================================================================
--- trunk/ui/src/image/viewer.py        (original)
+++ trunk/ui/src/image/viewer.py        Sat Jan 20 20:21:16 2007
@@ -55,7 +55,8 @@
 from gui.animation import *
 
 from event import *
-from application import Application
+from application import Application, STATUS_RUNNING, STATUS_STOPPING, \
+     STATUS_STOPPED, STATUS_IDLE, CAPABILITY_TOGGLE, CAPABILITY_FULLSCREEN
 
 # get logging object
 log = logging.getLogger('image')
@@ -72,7 +73,8 @@
         """
         create an image viewer application
         """
-        Application.__init__(self, 'image viewer', 'image', True)
+        capabilities = (CAPABILITY_TOGGLE, CAPABILITY_FULLSCREEN)
+        Application.__init__(self, 'imageviewer', 'image', capabilities)
 
         self.osd_mode = 0    # Draw file info on the image
         self.zoom = 0   # Image zoom
@@ -93,13 +95,13 @@
         self.sshow_timer = kaa.notifier.OneShotTimer(self.signalhandler)
 
 
-    def hide(self):
+    def hide_app(self):
         """
         Hide the viewer. This clears the cache and removes the application
         from the eventhandler stack. It is still possible to show() this
         object again.
         """
-        Application.hide(self)
+        Application.hide_app(self)
         if self.last_image:
             self.last_image.unparent()
         self.last_image = None
@@ -133,13 +135,13 @@
         filename      = item.filename
         self.item = item
 
-        self.show()
-
         if not self.last_item:
             # We just started, update the screen to make it
             # empty (all hides from the menu are updated)
             gui.display.update()
 
+        self.status = STATUS_RUNNING
+
         # only load new image when the image changed
         if self.filename == filename and self.rotation == rotation and \
                len(filename) > 0:
@@ -285,8 +287,8 @@
         """
         Stop the current viewing
         """
-        # Don't stop the viewer application, just send a PLAY_END
-        # event.
+        # set status to stopping
+        self.status = STATUS_STOPPING
         event = Event(PLAY_END, self.item)
         event.set_handler(self.eventhandler)
         event.post()
@@ -341,8 +343,10 @@
 
         if event == PLAY_END:
             # Viewing is done, set application to stopped
-            self.stopped()
+            self.status = STATUS_STOPPED
             self.item.eventhandler(event)
+            if self.status == STATUS_STOPPED:
+                self.status = STATUS_IDLE
             return True
 
         if event == IMAGE_ROTATE:

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to