From: Dirk M. <di...@fr...> - 2009-02-24 20:36:33
|
Author: dmeyer Date: Tue Feb 24 15:36:23 2009 New Revision: 11325 Log: use relative imports in all plugins Modified: branches/candy/ui/src/__init__.py branches/candy/ui/src/audio/audiodiskitem.py branches/candy/ui/src/audio/audioitem.py branches/candy/ui/src/audio/interface.py branches/candy/ui/src/audio/player.py branches/candy/ui/src/audio/plugins/album.py branches/candy/ui/src/audio/plugins/artist.py branches/candy/ui/src/image/fxdhandler.py branches/candy/ui/src/image/imageitem.py branches/candy/ui/src/image/interface.py branches/candy/ui/src/image/plugins/apod.py branches/candy/ui/src/image/plugins/calendar.py branches/candy/ui/src/image/viewer.py branches/candy/ui/src/input/eventmap.py branches/candy/ui/src/input/plugins/interface.py branches/candy/ui/src/input/plugins/joystick.py branches/candy/ui/src/input/plugins/keyboard.py branches/candy/ui/src/input/plugins/lirc.py branches/candy/ui/src/plugins/dpms.py branches/candy/ui/src/plugins/file_ops.py branches/candy/ui/src/plugins/idlebar/plugin.py branches/candy/ui/src/plugins/lcd.py branches/candy/ui/src/plugins/osd.py branches/candy/ui/src/plugins/shoppingcart.py branches/candy/ui/src/plugins/shutdown.py branches/candy/ui/src/plugins/unpack.py branches/candy/ui/src/video/configure.py branches/candy/ui/src/video/database.py branches/candy/ui/src/video/fxdhandler.py branches/candy/ui/src/video/interface.py branches/candy/ui/src/video/player.py branches/candy/ui/src/video/playlist.py branches/candy/ui/src/video/plugins/resume.py branches/candy/ui/src/video/videoitem.py Modified: branches/candy/ui/src/__init__.py ============================================================================== --- branches/candy/ui/src/__init__.py (original) +++ branches/candy/ui/src/__init__.py Tue Feb 24 15:36:23 2009 @@ -35,7 +35,7 @@ if obj.upper() == obj or obj == 'Event': __api__.__all__.append(obj) setattr(__api__, obj, getattr(__event__, obj)) -for module in ('menu', 'application', 'fxditem', 'playlist', 'directory', 'mainmenu'): +for module in ('menu', 'application', 'fxditem', 'playlist', 'directory', 'mainmenu', 'mediamenu'): exec('import %s as module' % module) for obj in module.__all__: __api__.__all__.append(obj) Modified: branches/candy/ui/src/audio/audiodiskitem.py ============================================================================== --- branches/candy/ui/src/audio/audiodiskitem.py (original) +++ branches/candy/ui/src/audio/audiodiskitem.py Tue Feb 24 15:36:23 2009 @@ -41,22 +41,18 @@ import kaa # Freevo imports -from freevo.ui import config - -from freevo.ui.menu import Action, Menu +from .. import api as freevo from audioitem import AudioItem -from freevo.ui.playlist import Playlist -from freevo.ui.directory import DirItem # get logging object log = logging.getLogger('audio') -class AudioDiskItem(Playlist): +class AudioDiskItem(freevo.Playlist): """ Class for handling audio disks. """ def __init__(self, device, parent): - Playlist.__init__(self, parent=parent, type='audio') + super(AudioDiskItem, self).__init__(parent=parent, type='audio') self.type = 'audiocd' self.info = device self.name = device.get('title') @@ -69,7 +65,7 @@ """ Return a list of actions for this item """ - return [ Action(_('Browse disc'), self.browse ) ] + return [ freevo.Action(_('Browse disc'), self.browse ) ] @kaa.coroutine() @@ -89,8 +85,8 @@ items = [] # random playlist (only active for audio) - if config.directory.add_random_playlist and len(play_items) > 1: - pl = Playlist(_('Random playlist'), play_items, self, random=True) + if freevo.config.directory.add_random_playlist and len(play_items) > 1: + pl = freevo.Playlist(_('Random playlist'), play_items, self, random=True) pl.autoplay = True items += [ pl ] @@ -98,9 +94,9 @@ # BEACON_FIXME # if hasattr(self.info, 'mixed'): - # d = DirItem(self.mountdir, self) + # d = freevo.DirItem(self.mountdir, self) # d.name = _('Data files on disc') # items.append(d) - item_menu = Menu(self.name, items, type = 'audio') + item_menu = freevo.Menu(self.name, items, type = 'audio') self.get_menustack().pushmenu(item_menu) Modified: branches/candy/ui/src/audio/audioitem.py ============================================================================== --- branches/candy/ui/src/audio/audioitem.py (original) +++ branches/candy/ui/src/audio/audioitem.py Tue Feb 24 15:36:23 2009 @@ -40,8 +40,7 @@ import time # freevo imports -from freevo.ui.menu import MediaItem, Action -from freevo.ui.event import PLAY_END, STOP +from .. import api as freevo # audio player import player as audioplayer @@ -49,14 +48,14 @@ # get logging object log = logging.getLogger('audio') -class AudioItem(MediaItem): +class AudioItem(freevo.MediaItem): """ This is the common class to get information about audiofiles. """ type = 'audio' def __init__(self, url, parent): - MediaItem.__init__(self, parent) + super(AudioItem, self).__init__(parent) self.user_stop = False self.set_url(url) @@ -71,14 +70,14 @@ except (ValueError, KeyError, TypeError): track = 0 return u'%20d %s' % (track, self.name.lower()) - return MediaItem.sort(self, mode) + return super(AudioItem, self).sort(mode) def actions(self): """ return a list of possible actions on this item """ - return [ Action('Play', self.play) ] + return [ freevo.Action('Play', self.play) ] def play(self): @@ -100,10 +99,10 @@ """ eventhandler for this item """ - if event == STOP: + if event == freevo.STOP: self.user_stop = True - if event == PLAY_END: + if event == freevo.PLAY_END: if not self.user_stop: self['last_played'] = int(time.time()) self.user_stop = False - return MediaItem.eventhandler(self, event) + return super(AudioItem, self).eventhandler(event) Modified: branches/candy/ui/src/audio/interface.py ============================================================================== --- branches/candy/ui/src/audio/interface.py (original) +++ branches/candy/ui/src/audio/interface.py Tue Feb 24 15:36:23 2009 @@ -45,12 +45,7 @@ import stat # Freevo imports -from freevo import plugin -from freevo.ui import fxditem -from freevo.ui import config -from freevo.ui.menu import MediaPlugin -from freevo.ui.mediamenu import MediaMenu -from freevo.ui.mainmenu import MainMenuPlugin +from .. import api as freevo # AudioItem from audioitem import AudioItem @@ -59,7 +54,7 @@ # fxdhandler for <audio> tags from fxdhandler import fxdhandler -class PluginInterface(MediaPlugin, MainMenuPlugin): +class PluginInterface(freevo.MediaPlugin, freevo.MainMenuPlugin): """ Plugin to handle all kinds of audio items """ @@ -70,14 +65,14 @@ Activate the plugin. """ # add fxd parser callback - fxditem.add_parser(['audio'], 'audio', fxdhandler) + freevo.add_fxdparser(['audio'], 'audio', fxdhandler) def suffix(self): """ return the list of suffixes this class handles """ - return [ 'beacon:audio' ] + config.audio.suffix.split(',') + return [ 'beacon:audio' ] + freevo.config.audio.suffix.split(',') def get(self, parent, listing): @@ -100,4 +95,4 @@ """ MainMenuPlugin.items to return the audio item. """ - return [ MediaMenu(parent, _('Audio Main Menu'), 'audio', config.audio.items) ] + return [ freevo.MediaMenu(parent, _('Audio Main Menu'), 'audio', freevo.config.audio.items) ] Modified: branches/candy/ui/src/audio/player.py ============================================================================== --- branches/candy/ui/src/audio/player.py (original) +++ branches/candy/ui/src/audio/player.py Tue Feb 24 15:36:23 2009 @@ -40,15 +40,12 @@ import kaa.popcorn # Freevo imports -from freevo.ui.event import * -from freevo.ui.application import Application, STATUS_RUNNING, STATUS_STOPPING, \ - STATUS_STOPPED, STATUS_IDLE, CAPABILITY_TOGGLE, CAPABILITY_PAUSE, \ - CAPABILITY_FULLSCREEN +from .. import api as freevo # get logging object log = logging.getLogger('audio') -class Player(Application): +class Player(freevo.Application): """ Audio player object. """ @@ -56,8 +53,8 @@ name = 'audioplayer' def __init__(self): - capabilities = (CAPABILITY_TOGGLE, CAPABILITY_PAUSE) - Application.__init__(self, 'audio', capabilities) + capabilities = (freevo.CAPABILITY_TOGGLE, freevo.CAPABILITY_PAUSE) + super(Player, self).__init__('audio', capabilities) self.player = kaa.popcorn.Player() self.elapsed_timer = kaa.WeakTimer(self.elapsed) @@ -67,15 +64,15 @@ """ play an item """ - if not self.status in (STATUS_IDLE, STATUS_STOPPED): + if not self.status in (freevo.STATUS_IDLE, freevo.STATUS_STOPPED): # Already running, stop the current player by sending a STOP # event. The event will also get to the playlist behind the # current item and the whole list will be stopped. - Event(STOP, handler=self.eventhandler).post() + freevo.Event(freevo.STOP, handler=self.eventhandler).post() # Now connect to our own 'stop' signal once to repeat this current # function call without the player playing yield kaa.inprogress(self.signals['stop']) - if not self.status in (STATUS_IDLE, STATUS_STOPPED): + if not self.status in (freevo.STATUS_IDLE, freevo.STATUS_STOPPED): log.error('unable to stop current audio playback') yield False if not kaa.main.is_running(): @@ -100,11 +97,11 @@ # Set the current item to the gui engine self.gui_context.item = self.item.properties self.gui_context.menu = self.playlist - self.status = STATUS_RUNNING + self.status = freevo.STATUS_RUNNING # Open media item and start playback - play_start = Event(PLAY_START, handler=self.eventhandler) - play_end = Event(PLAY_END, handler=self.eventhandler) + play_start = freevo.Event(freevo.PLAY_START, handler=self.eventhandler) + play_end = freevo.Event(freevo.PLAY_END, handler=self.eventhandler) self.player.signals['end'].connect_once(play_end.post, self.item) try: yield self.player.open(self.item.url) @@ -125,10 +122,10 @@ """ Stop playing. """ - if self.status != STATUS_RUNNING: + if self.status != freevo.STATUS_RUNNING: return True self.player.stop() - self.status = STATUS_STOPPING + self.status = freevo.STATUS_STOPPING def elapsed(self): @@ -144,29 +141,29 @@ React on some events or send them to the real player or the item belongig to the player """ - if event == STOP: + if event == freevo.STOP: # Stop the player and pass the event to the item self.stop() self.item.eventhandler(event) return True - if event == PLAY_START: + if event == freevo.PLAY_START: self.elapsed_timer.start(0.2) self.item.eventhandler(event) return True - if event == PLAY_END: + if event == freevo.PLAY_END: # 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.status = STATUS_STOPPED + self.status = freevo.STATUS_STOPPED self.elapsed_timer.stop() self.item.eventhandler(event) - if self.status == STATUS_STOPPED: - self.status = STATUS_IDLE + if self.status == freevo.STATUS_STOPPED: + self.status = freevo.STATUS_IDLE return True - if event in (PAUSE, PLAY): + if event in (freevo.PAUSE, freevo.PLAY): if self.player.get_state() == kaa.popcorn.STATE_PLAYING: self.suspend() return True @@ -175,7 +172,7 @@ return True return False - if event == SEEK: + if event == freevo.SEEK: self.player.seek(int(event.arg), kaa.popcorn.SEEK_RELATIVE) return True @@ -194,7 +191,7 @@ Release the audio resource that others can use it. """ # FIXME: make sure this function is not called twice - if not self.status == STATUS_RUNNING: + if not self.status == freevo.STATUS_RUNNING: yield False if self.player.get_state() == kaa.popcorn.STATE_PAUSED: yield None @@ -211,7 +208,7 @@ Resume playing the audio, at the position before. """ # FIXME: make sure this function is not called twice - if not self.status == STATUS_RUNNING: + if not self.status == freevo.STATUS_RUNNING: yield False if self.player.get_state() == kaa.popcorn.STATE_PLAYING: yield False Modified: branches/candy/ui/src/audio/plugins/album.py ============================================================================== --- branches/candy/ui/src/audio/plugins/album.py (original) +++ branches/candy/ui/src/audio/plugins/album.py Tue Feb 24 15:36:23 2009 @@ -40,18 +40,14 @@ import kaa.beacon # Freevo imports -from freevo.ui.mainmenu import MainMenuPlugin -from freevo.ui.menu import Item, ItemList, ActionItem, Menu, Action, GridMenu, MediaItem -from freevo.ui.playlist import Playlist -from freevo.ui.audio import AudioItem -from freevo.ui.directory import DirItem +from ... import api as freevo -class AlbumItem(MediaItem): +class AlbumItem(freevo.MediaItem): """ Item for on Album (or all) for an artist. """ def __init__(self, artist, album, parent): - MediaItem.__init__(self, parent) + super(AlbumItem, self).__init__(parent) self.artist = artist self.album = album self.name = _('[ All Songs ]') @@ -72,7 +68,7 @@ query = dict(artist=self.artist, type='audio') # FIXME: monitor query for live update async = kaa.beacon.query(**query) - self.playlist = Playlist(title, async, self, type='audio') + self.playlist = freevo.Playlist(title, async, self, type='audio') self.playlist.browse() @@ -80,16 +76,16 @@ """ Actions for this item. """ - return [ Action(_('Browse Songs'), self.browse) ] + return [ freevo.Action(_('Browse Songs'), self.browse) ] -class ArtistAlbumView(GridMenu): +class ArtistAlbumView(freevo.GridMenu): """ Item for an artist. """ def __init__(self, parent): - GridMenu.__init__(self, _('Artist/Albums View'), type = 'audio grid') + super(ArtistAlbumView, self).__init__(_('Artist/Albums View'), type = 'audio grid') self.artists_base = 0 self.artists = [] self.col_row_swap = False @@ -140,13 +136,13 @@ return artist_name -class PluginInterface(MainMenuPlugin): +class PluginInterface(freevo.MainMenuPlugin): """ Add 'Browse by Artist albums' to the audio menu. """ def items(self, parent): - return [ ActionItem(_('Browse by Artists/Albums'), parent, self.show) ] + return [ freevo.ActionItem(_('Browse by Artists/Albums'), parent, self.show) ] def show(self, parent): artistalbumview = ArtistAlbumView(parent) Modified: branches/candy/ui/src/audio/plugins/artist.py ============================================================================== --- branches/candy/ui/src/audio/plugins/artist.py (original) +++ branches/candy/ui/src/audio/plugins/artist.py Tue Feb 24 15:36:23 2009 @@ -40,16 +40,15 @@ import kaa.beacon # Freevo imports -from freevo.ui.mainmenu import MainMenuPlugin -from freevo.ui.menu import Item, ActionItem, Menu, Action -from freevo.ui.playlist import Playlist +from ... import api as freevo -class AlbumItem(Item): + +class AlbumItem(freevo.Item): """ Item for on Album (or all) for an artist. """ def __init__(self, artist, album, parent): - Item.__init__(self, parent) + super(AlbumItem, self).__init__(parent) self.artist = artist self.album = album self.name = _('[ All Songs ]') @@ -69,7 +68,7 @@ query = dict(artist=self.artist, type='audio') # FIXME: monitor query for live update async = kaa.beacon.query(**query) - self.playlist = Playlist(title, async, self, type='audio') + self.playlist = freevo.Playlist(title, async, self, type='audio') self.playlist.browse() @@ -77,16 +76,16 @@ """ Actions for this item. """ - return [ Action(_('Browse Songs'), self.browse) ] + return [ freevo.Action(_('Browse Songs'), self.browse) ] -class ArtistItem(Item): +class ArtistItem(freevo.Item): """ Item for an artist. """ def __init__(self, artist, parent): - Item.__init__(self, parent) + super(ArtistItem, self).__init__(parent) self.artist = artist # Work around a beacon bug for part in artist.split(' '): @@ -104,18 +103,18 @@ items = [ AlbumItem(self.artist, None, self) ] for album in query: items.append(AlbumItem(self.artist, album, self)) - self.get_menustack().pushmenu(Menu(_('Album'), items, type='audio')) + self.get_menustack().pushmenu(freevo.Menu(_('Album'), items, type='audio')) def actions(self): """ Actions for this item. """ - return [ Action(_('Browse Album from %s') % self.name, self.browse) ] + return [ freevo.Action(_('Browse Album from %s') % self.name, self.browse) ] -class PluginInterface(MainMenuPlugin): +class PluginInterface(freevo.MainMenuPlugin): """ Add 'Browse by Artist' to the audio menu. """ @@ -128,11 +127,11 @@ items = [] for artist in (yield kaa.beacon.query(attr='artist', type='audio')): items.append(ArtistItem(artist, parent)) - parent.get_menustack().pushmenu(Menu(_('Artists'), items, type='audio')) + parent.get_menustack().pushmenu(freevo.Menu(_('Artists'), items, type='audio')) def items(self, parent): """ Return the main menu item. """ - return [ ActionItem(_('Browse by Artists'), parent, self.artists) ] + return [ freevo.ActionItem(_('Browse by Artists'), parent, self.artists) ] Modified: branches/candy/ui/src/image/fxdhandler.py ============================================================================== --- branches/candy/ui/src/image/fxdhandler.py (original) +++ branches/candy/ui/src/image/fxdhandler.py Tue Feb 24 15:36:23 2009 @@ -58,11 +58,7 @@ import kaa # Freevo imports -from freevo.ui import config -from freevo.ui import menu - -from freevo.ui.util import match_files -from freevo.ui.playlist import Playlist +from .. import api as freevo # ImageItem from imageitem import ImageItem @@ -89,15 +85,14 @@ if child.name == 'directory': # for directories add all files in it recursive = fxd.getattr(child, 'recursive', 0) - files = match_files(fname, config.image.suffix.split(','), recursive) + files = freevo.util.match_files(fname, freevo.config.image.suffix.split(','), recursive) elif child.name == 'file': # add the given filename files = [ fname ] # get duration until the next images comes up - duration = fxd.getattr(child, 'duration', 0) or \ - config.image.viewer.duration + duration = fxd.getattr(child, 'duration', 0) or freevo.config.image.viewer.duration for file in files: items.append(ImageItem(file, None, duration)) @@ -107,7 +102,7 @@ print e # create the playlist based on the parsed file list - pl = Playlist('', items, fxd.getattr(None, 'parent', None), + pl = freevo.Playlist('', items, fxd.getattr(None, 'parent', None), random=fxd.getattr(node, 'random', 0), repeat=fxd.getattr(node, 'repeat', 0)) pl.autoplay = True @@ -125,7 +120,7 @@ files = [] suffix = [] - for p in menu.MediaPlugin.plugins('audio'): + for p in freevo.MediaPlugin.plugins('audio'): suffix += p.suffix() for child in children: @@ -133,7 +128,7 @@ fname = os.path.join(dirname, fxd.gettext(child)) if child.name == 'directory': recursive = fxd.getattr(child, 'recursive', 0) - files += match_files(fname, suffix, recursive) + files += freevo.util.match_files(fname, suffix, recursive) elif child.name == 'file': files.append(fname) except OSError, e: @@ -141,7 +136,7 @@ print e if files: - bg = Playlist(playlist=files, random = random, + bg = freevo.Playlist(playlist=files, random = random, repeat=True, type='audio') pl.background_playlist = bg Modified: branches/candy/ui/src/image/imageitem.py ============================================================================== --- branches/candy/ui/src/image/imageitem.py (original) +++ branches/candy/ui/src/image/imageitem.py Tue Feb 24 15:36:23 2009 @@ -38,19 +38,17 @@ import time # freevo imports -from freevo.ui import config -from freevo.ui.menu import MediaItem, Action -from freevo.ui.event import PLAY_END, STOP +from .. import api as freevo from viewer import viewer -class ImageItem(MediaItem): +class ImageItem(freevo.MediaItem): """ An item for image files """ type = 'image' - def __init__(self, url, parent, duration = config.image.viewer.duration): - MediaItem.__init__(self, parent) + def __init__(self, url, parent, duration = freevo.config.image.viewer.duration): + super(ImageItem, self).__init__(parent) self.user_stop = False # set url and parse the name self.set_url(url) @@ -70,7 +68,7 @@ """ Return a list of possible actions on this item. """ - return [ Action(_('View Image'), self.play) ] + return [ freevo.Action(_('View Image'), self.play) ] def cache(self): @@ -98,10 +96,10 @@ """ eventhandler for this item """ - if event == STOP: + if event == freevo.STOP: self.user_stop = True - if event == PLAY_END: + if event == freevo.PLAY_END: if not self.user_stop: self['last_played'] = int(time.time()) self.user_stop = False - return MediaItem.eventhandler(self, event) + return super(ImageItem, self).eventhandler(event) Modified: branches/candy/ui/src/image/interface.py ============================================================================== --- branches/candy/ui/src/image/interface.py (original) +++ branches/candy/ui/src/image/interface.py Tue Feb 24 15:36:23 2009 @@ -40,12 +40,7 @@ __all__ = [ 'PluginInterface' ] # freevo imports -from freevo import plugin -from freevo.ui import fxditem -from freevo.ui.menu import MediaPlugin -from freevo.ui import config -from freevo.ui.mediamenu import MediaMenu -from freevo.ui.mainmenu import MainMenuPlugin +from .. import api as freevo # ImageItem from imageitem import ImageItem @@ -53,7 +48,7 @@ # fxdhandler for <slideshow> tags from fxdhandler import fxdhandler -class PluginInterface(MediaPlugin, MainMenuPlugin): +class PluginInterface(freevo.MediaPlugin, freevo.MainMenuPlugin): """ Plugin to handle all kinds of image items """ @@ -64,14 +59,14 @@ Activate the plugin. """ # register the callbacks - fxditem.add_parser(['image'], 'slideshow', fxdhandler) + freevo.add_fxdparser(['image'], 'slideshow', fxdhandler) def suffix(self): """ return the list of suffixes this class handles """ - return [ 'beacon:image' ] + config.image.suffix.split(',') + return [ 'beacon:image' ] + freevo.config.image.suffix.split(',') def get(self, parent, listing): @@ -89,4 +84,4 @@ """ MainMenuPlugin.items to return the image item. """ - return [ MediaMenu(parent, _('Image Main Menu'), 'image', config.image.items) ] + return [ freevo.MediaMenu(parent, _('Image Main Menu'), 'image', freevo.config.image.items) ] Modified: branches/candy/ui/src/image/plugins/apod.py ============================================================================== --- branches/candy/ui/src/image/plugins/apod.py (original) +++ branches/candy/ui/src/image/plugins/apod.py Tue Feb 24 15:36:23 2009 @@ -39,18 +39,16 @@ import kaa.beacon # freevo imports -from freevo.ui.menu import Item, Action, ActionItem, Menu, MediaPlugin -from freevo.ui.mainmenu import MainMenuPlugin -from freevo.ui.image import ImageItem -from freevo.ui.application import TextWindow, MessageWindow +from ... import api as freevo +from .. import ImageItem -class ApodMainMenuItem(Item): +class ApodMainMenuItem(freevo.Item): """ This is the item for the main menu and creates the list of commands in a submenu. """ def __init__(self, parent, imagedir): - Item.__init__(self, parent) + super(ApodMainMenuItem, self).__init__(parent) self.name = _( 'APOD' ) self.info = { 'title' : 'APOD', 'description' : 'Astronomy Picture of the day' } @@ -61,7 +59,7 @@ """ Return actions for the item. """ - return [ Action(_('APOD Pictures'), self.create_menu) ] + return [ freevo.Action(_('APOD Pictures'), self.create_menu) ] def create_menu(self): @@ -69,15 +67,15 @@ Create a menu for APOD. """ # current image - current = ActionItem(_('Current Picture'), self, self.fetch_picture) + current = freevo.ActionItem(_('Current Picture'), self, self.fetch_picture) current.description = _('Download the current picture') # previous images - previous = ActionItem(_('Previous Pictures'), self, self.browse_pictures) + previous = freevo.ActionItem(_('Previous Pictures'), self, self.browse_pictures) previous.description = _('Browse all previously downloaded images') # add menu - self.get_menustack().pushmenu(Menu( _( 'Apod Pictures' ), [ current, previous ])) + self.get_menustack().pushmenu(freevo.Menu( _( 'Apod Pictures' ), [ current, previous ])) @kaa.coroutine() @@ -88,20 +86,20 @@ listing = (yield kaa.beacon.query(filename=self.imagedir)).get(filter='extmap') # get items items = [] - for p in MediaPlugin.plugins('image'): + for p in freevo.MediaPlugin.plugins('image'): items += p.get(self, listing) if items: - self.get_menustack().pushmenu(Menu(_('Apod Pictures'), items)) + self.get_menustack().pushmenu(freevo.Menu(_('Apod Pictures'), items)) else: - MessageWindow(_('No Images found')).show() + freevo.MessageWindow(_('No Images found')).show() def fetch_picture(self): """ Fetch current picture. """ - box = TextWindow(text=_('Getting picture, please wait')) + box = freevo.TextWindow(text=_('Getting picture, please wait')) box.show() async = kaa.ThreadCallback(self._fetch_picture_thread)() @@ -139,7 +137,7 @@ box.destroy() if not isinstance(exc_value, (str, unicode)): error = 'Exception: %s' % exc_value - MessageWindow(error).show() + freevo.MessageWindow(error).show() def _fetch_picture_finished(self, filename, box): @@ -153,7 +151,7 @@ -class PluginInterface(MainMenuPlugin): +class PluginInterface(freevo.MainMenuPlugin): """ Astronomy Picture of the Day download plugin. Downloads the picture for the current day and allow access to the dir for browsing the old @@ -183,7 +181,7 @@ self.imagedir = imagedir # init the plugin - MainMenuPlugin.__init__(self) + super(PluginInterface, self).__init__() Modified: branches/candy/ui/src/image/plugins/calendar.py ============================================================================== --- branches/candy/ui/src/image/plugins/calendar.py (original) +++ branches/candy/ui/src/image/plugins/calendar.py Tue Feb 24 15:36:23 2009 @@ -40,12 +40,10 @@ import kaa.beacon # freevo imports -from freevo.ui.menu import Item, Menu -from freevo.ui.mainmenu import MainMenuPlugin -from freevo.ui.playlist import Playlist +from ... import api as freevo -class BeaconQueryItem(Item): +class BeaconQueryItem(freevo.Item): """ Base item for all items in this plugin. """ @@ -53,7 +51,7 @@ media_type = 'image' def __init__(self, name, parent, sample=None): - Item.__init__(self, parent) + super(BeaconQueryItem, self).__init__(parent) self.name = name if sample: self.info['thumbnail'] = sample.get('thumbnail') @@ -82,7 +80,7 @@ items = self.get_items(all) if isinstance(items, kaa.InProgress): items = yield items - menu = Menu(self.name, items, type='image') + menu = freevo.Menu(self.name, items, type='image') menu.autoselect = True self.get_menustack().pushmenu(menu) @@ -109,7 +107,7 @@ for day, sample in result: result = yield self._query((self._year, self._month, day), (self._year, self._month, day)) - p = Playlist(_('%s-%s-%s') % (self._year, self._month, day), + p = freevo.Playlist(_('%s-%s-%s') % (self._year, self._month, day), playlist=result, parent=self, type='image') p.info['thumbnail'] = result[0].get('thumbnail') items.append(p) @@ -150,7 +148,7 @@ return [ YearItem(year, sample, self) for year, sample in result ] -class PluginInterface(MainMenuPlugin): +class PluginInterface(freevo.MainMenuPlugin): """ Calendar view plugin. """ Modified: branches/candy/ui/src/image/viewer.py ============================================================================== --- branches/candy/ui/src/image/viewer.py (original) +++ branches/candy/ui/src/image/viewer.py Tue Feb 24 15:36:23 2009 @@ -40,12 +40,8 @@ import kaa import kaa.imlib2 -# cache for loading images -from freevo.ui.util import ObjectCache - -from freevo.ui.event import * -from freevo.ui.application import Application, STATUS_RUNNING, STATUS_STOPPING, \ - STATUS_STOPPED, STATUS_IDLE, CAPABILITY_TOGGLE, CAPABILITY_FULLSCREEN +# freevo imports +from .. import api as freevo # get logging object log = logging.getLogger('image') @@ -53,7 +49,7 @@ # global viewer, will be set to the ImageViewer viewer = None -class ImageViewer(Application): +class ImageViewer(freevo.Application): """ Full screen image viewer for imageitems """ @@ -64,10 +60,10 @@ """ create an image viewer application """ - capabilities = (CAPABILITY_TOGGLE, CAPABILITY_FULLSCREEN) - Application.__init__(self, 'image', capabilities) + capabilities = (freevo.CAPABILITY_TOGGLE, freevo.CAPABILITY_FULLSCREEN) + super(ImageViewer, self).__init__('image', capabilities) self.osd_mode = 0 - self.bitmapcache = ObjectCache(3, desc='viewer') + self.bitmapcache = freevo.util.ObjectCache(3, desc='viewer') self.slideshow = True self.sshow_timer = kaa.OneShotTimer(self._next) self.signals['stop'].connect_weak(self._cleanup) @@ -80,13 +76,13 @@ # we don't need the signalhandler anymore self.sshow_timer.stop() # reset bitmap cache - self.bitmapcache = ObjectCache(3, desc='viewer') + self.bitmapcache = freevo.util.ObjectCache(3, desc='viewer') def _next(self): """ Send PLAY_END to show next image. """ - event = Event(PLAY_END, self.item) + event = freevo.Event(freevo.PLAY_END, self.item) event.set_handler(self.eventhandler) event.post() @@ -109,25 +105,25 @@ self.gui_context.zoom = 1.0 self.gui_context.pos = 0,0 self.gui_context.menu = self.playlist - self.status = STATUS_RUNNING + self.status = freevo.STATUS_RUNNING # start timer if self.item.duration and self.slideshow and \ not self.sshow_timer.active(): self.sshow_timer.start(self.item.duration) # Notify everyone about the viewing - PLAY_START.post(item) + freevo.PLAY_START.post(item) return None def stop(self): """ Stop the current viewing """ - if self.status != STATUS_RUNNING: + if self.status != freevo.STATUS_RUNNING: # already stopped return True # set status to stopping - self.status = STATUS_STOPPING - event = Event(PLAY_END, self.item) + self.status = freevo.STATUS_STOPPING + event = freevo.Event(freevo.PLAY_END, self.item) event.set_handler(self.eventhandler) event.post() @@ -144,38 +140,38 @@ """ Handle incoming events """ - if event == PAUSE or event == PLAY: + if event == freevo.PAUSE or event == freevo.PLAY: if self.slideshow: - OSD_MESSAGE.post(_('pause')) + freevo.OSD_MESSAGE.post(_('pause')) self.slideshow = False self.sshow_timer.stop() else: - OSD_MESSAGE.post(_('play')) + freevo.OSD_MESSAGE.post(_('play')) self.slideshow = True self.sshow_timer.start(1) return True - if event == STOP: + if event == freevo.STOP: self.stop() self.item.eventhandler(event) return True - if event == PLAYLIST_NEXT or event == PLAYLIST_PREV: + if event == freevo.PLAYLIST_NEXT or event == freevo.PLAYLIST_PREV: # up and down will stop the slideshow and pass the # event to the playlist self.sshow_timer.stop() self.item.eventhandler(event) return True - if event == PLAY_END: + if event == freevo.PLAY_END: # Viewing is done, set application to stopped - self.status = STATUS_STOPPED + self.status = freevo.STATUS_STOPPED self.item.eventhandler(event) - if self.status == STATUS_STOPPED: - self.status = STATUS_IDLE + if self.status == freevo.STATUS_STOPPED: + self.status = freevo.STATUS_IDLE return True - if event == IMAGE_ROTATE: + if event == freevo.IMAGE_ROTATE: # rotate image if event.arg == 'left': self.gui_context.rotation = (self.gui_context.rotation + 270) % 360 @@ -183,13 +179,13 @@ self.gui_context.rotation = (self.gui_context.rotation + 90) % 360 return True - if event in (ZOOM, ZOOM_IN, ZOOM_OUT): + if event in (freevo.ZOOM, freevo.ZOOM_IN, freevo.ZOOM_OUT): zoom = self.gui_context.zoom - if event == ZOOM: + if event == freevo.ZOOM: self.gui_context.zoom = event.arg - if event == ZOOM_IN: + if event == freevo.ZOOM_IN: self.gui_context.zoom += event.arg - if event == ZOOM_OUT: + if event == freevo.ZOOM_OUT: self.gui_context.zoom = max(1.0, self.gui_context.zoom + event.arg) if self.gui_context.zoom > 1.01: if zoom == 1.0: @@ -205,17 +201,17 @@ self.gui_context.pos = 0,0 return True - if event == IMAGE_MOVE: + if event == freevo.IMAGE_MOVE: # move inside a zoomed image x, y = self.gui_context.pos self.gui_context.pos = x + event.arg[0], y + event.arg[1] return True - if event == TOGGLE_OSD: + if event == freevo.TOGGLE_OSD: # FIXME: update widget return True - if event == IMAGE_SAVE: + if event == freevo.IMAGE_SAVE: # FIXME return True Modified: branches/candy/ui/src/input/eventmap.py ============================================================================== --- branches/candy/ui/src/input/eventmap.py (original) +++ branches/candy/ui/src/input/eventmap.py Tue Feb 24 15:36:23 2009 @@ -1,198 +1,198 @@ __all__ = [ 'EVENTMAP' ] -from freevo.ui.event import * +from .. import api as freevo # # Default key-event map # MENU_EVENTS = { - 'LEFT' : MENU_LEFT, - 'RIGHT' : MENU_RIGHT, - 'UP' : MENU_UP, - 'DOWN' : MENU_DOWN, - 'CH+' : MENU_PAGEUP, - 'CH-' : MENU_PAGEDOWN, - 'MENU' : MENU_GOTO_MAINMENU, - 'EXIT' : MENU_BACK_ONE_MENU, - 'SELECT' : MENU_SELECT, - 'PLAY' : MENU_PLAY_ITEM, - 'ENTER' : MENU_SUBMENU, - 'DISPLAY' : MENU_CHANGE_STYLE, - 'EJECT' : EJECT + 'LEFT' : freevo.MENU_LEFT, + 'RIGHT' : freevo.MENU_RIGHT, + 'UP' : freevo.MENU_UP, + 'DOWN' : freevo.MENU_DOWN, + 'CH+' : freevo.MENU_PAGEUP, + 'CH-' : freevo.MENU_PAGEDOWN, + 'MENU' : freevo.MENU_GOTO_MAINMENU, + 'EXIT' : freevo.MENU_BACK_ONE_MENU, + 'SELECT' : freevo.MENU_SELECT, + 'PLAY' : freevo.MENU_PLAY_ITEM, + 'ENTER' : freevo.MENU_SUBMENU, + 'DISPLAY' : freevo.MENU_CHANGE_STYLE, + 'EJECT' : freevo.EJECT } TVMENU_EVENTS = { - 'LEFT' : MENU_LEFT, - 'RIGHT' : MENU_RIGHT, - 'UP' : MENU_UP, - 'DOWN' : MENU_DOWN, - 'CH+' : MENU_PAGEUP, - 'CH-' : MENU_PAGEDOWN, - 'MENU' : MENU_GOTO_MAINMENU, - 'EXIT' : MENU_BACK_ONE_MENU, - 'SELECT' : MENU_SELECT, - 'DISPLAY' : MENU_CHANGE_STYLE, - 'ENTER' : TV_SHOW_CHANNEL, - 'REC' : TV_START_RECORDING + 'LEFT' : freevo.MENU_LEFT, + 'RIGHT' : freevo.MENU_RIGHT, + 'UP' : freevo.MENU_UP, + 'DOWN' : freevo.MENU_DOWN, + 'CH+' : freevo.MENU_PAGEUP, + 'CH-' : freevo.MENU_PAGEDOWN, + 'MENU' : freevo.MENU_GOTO_MAINMENU, + 'EXIT' : freevo.MENU_BACK_ONE_MENU, + 'SELECT' : freevo.MENU_SELECT, + 'DISPLAY' : freevo.MENU_CHANGE_STYLE, + 'ENTER' : freevo.TV_SHOW_CHANNEL, + 'REC' : freevo.TV_START_RECORDING } INPUT_EVENTS = { - 'EXIT' : INPUT_EXIT, - 'ENTER' : INPUT_ENTER, - 'SELECT' : INPUT_ENTER, - 'LEFT' : INPUT_LEFT, - 'RIGHT' : INPUT_RIGHT, - 'UP' : INPUT_UP, - 'DOWN' : INPUT_DOWN, - '1' : INPUT_1, - '2' : INPUT_2, - '3' : INPUT_3, - '4' : INPUT_4, - '5' : INPUT_5, - '6' : INPUT_6, - '7' : INPUT_7, - '8' : INPUT_8, - '9' : INPUT_9, - '0' : INPUT_0, - 'CH+' : MENU_PAGEUP, - 'CH-' : MENU_PAGEDOWN + 'EXIT' : freevo.INPUT_EXIT, + 'ENTER' : freevo.INPUT_ENTER, + 'SELECT' : freevo.INPUT_ENTER, + 'LEFT' : freevo.INPUT_LEFT, + 'RIGHT' : freevo.INPUT_RIGHT, + 'UP' : freevo.INPUT_UP, + 'DOWN' : freevo.INPUT_DOWN, + '1' : freevo.INPUT_1, + '2' : freevo.INPUT_2, + '3' : freevo.INPUT_3, + '4' : freevo.INPUT_4, + '5' : freevo.INPUT_5, + '6' : freevo.INPUT_6, + '7' : freevo.INPUT_7, + '8' : freevo.INPUT_8, + '9' : freevo.INPUT_9, + '0' : freevo.INPUT_0, + 'CH+' : freevo.MENU_PAGEUP, + 'CH-' : freevo.MENU_PAGEDOWN } TV_EVENTS = { - 'STOP' : STOP, - 'MENU' : STOP, - 'EXIT' : STOP, - 'SELECT' : STOP, - 'PAUSE' : PAUSE, - 'CH+' : TV_CHANNEL_UP, - 'CH-' : TV_CHANNEL_DOWN, - 'LEFT' : Event(SEEK, -60), - 'RIGHT' : Event(SEEK, 60), - 'REW' : Event(SEEK, -10), - 'FFWD' : Event(SEEK, 10), - 'DISPLAY' : TOGGLE_OSD, - '0' : INPUT_0, - '1' : INPUT_1, - '2' : INPUT_2, - '3' : INPUT_3, - '4' : INPUT_4, - '5' : INPUT_5, - '6' : INPUT_6, - '7' : INPUT_7, - '8' : INPUT_8, - '9' : INPUT_9, + 'STOP' : freevo.STOP, + 'MENU' : freevo.STOP, + 'EXIT' : freevo.STOP, + 'SELECT' : freevo.STOP, + 'PAUSE' : freevo.PAUSE, + 'CH+' : freevo.TV_CHANNEL_UP, + 'CH-' : freevo.TV_CHANNEL_DOWN, + 'LEFT' : freevo.Event(freevo.SEEK, -60), + 'RIGHT' : freevo.Event(freevo.SEEK, 60), + 'REW' : freevo.Event(freevo.SEEK, -10), + 'FFWD' : freevo.Event(freevo.SEEK, 10), + 'DISPLAY' : freevo.TOGGLE_OSD, + '0' : freevo.INPUT_0, + '1' : freevo.INPUT_1, + '2' : freevo.INPUT_2, + '3' : freevo.INPUT_3, + '4' : freevo.INPUT_4, + '5' : freevo.INPUT_5, + '6' : freevo.INPUT_6, + '7' : freevo.INPUT_7, + '8' : freevo.INPUT_8, + '9' : freevo.INPUT_9, } VIDEO_EVENTS = { - 'PLAY' : PLAY, - 'PAUSE' : PAUSE, - 'STOP' : STOP, - 'EXIT' : STOP, - 'UP' : PLAYLIST_PREV, - 'DOWN' : PLAYLIST_NEXT, - 'CH+' : PLAYLIST_PREV, - 'CH-' : PLAYLIST_NEXT, - 'LEFT' : Event(SEEK, -60), - 'RIGHT' : Event(SEEK, 60), - 'REW' : Event(SEEK, -10), - 'FFWD' : Event(SEEK, 10), - 'MENU' : MENU, - 'DISPLAY' : TOGGLE_OSD, - 'REC' : STORE_BOOKMARK, - '0' : VIDEO_MANUAL_SEEK, - 'MENU' : DVDNAV_MENU, - 'NEXT' : NEXT, - 'PREV' : PREV + 'PLAY' : freevo.PLAY, + 'PAUSE' : freevo.PAUSE, + 'STOP' : freevo.STOP, + 'EXIT' : freevo.STOP, + 'UP' : freevo.PLAYLIST_PREV, + 'DOWN' : freevo.PLAYLIST_NEXT, + 'CH+' : freevo.PLAYLIST_PREV, + 'CH-' : freevo.PLAYLIST_NEXT, + 'LEFT' : freevo.Event(freevo.SEEK, -60), + 'RIGHT' : freevo.Event(freevo.SEEK, 60), + 'REW' : freevo.Event(freevo.SEEK, -10), + 'FFWD' : freevo.Event(freevo.SEEK, 10), + 'MENU' : freevo.MENU, + 'DISPLAY' : freevo.TOGGLE_OSD, + 'REC' : freevo.STORE_BOOKMARK, + '0' : freevo.VIDEO_MANUAL_SEEK, + 'MENU' : freevo.DVDNAV_MENU, + 'NEXT' : freevo.NEXT, + 'PREV' : freevo.PREV } DVDNAV_EVENTS = { - 'PLAY' : PLAY, - 'PAUSE' : PAUSE, - 'STOP' : STOP, - 'EXIT' : STOP, - 'UP' : DVDNAV_UP, - 'DOWN' : DVDNAV_DOWN, - 'LEFT' : DVDNAV_LEFT, - 'RIGHT' : DVDNAV_RIGHT, - 'ENTER' : DVDNAV_SELECT, - 'SELECT' : DVDNAV_SELECT, - 'DISPLAY' : TOGGLE_OSD, - 'MENU' : DVDNAV_MENU, + 'PLAY' : freevo.PLAY, + 'PAUSE' : freevo.PAUSE, + 'STOP' : freevo.STOP, + 'EXIT' : freevo.STOP, + 'UP' : freevo.DVDNAV_UP, + 'DOWN' : freevo.DVDNAV_DOWN, + 'LEFT' : freevo.DVDNAV_LEFT, + 'RIGHT' : freevo.DVDNAV_RIGHT, + 'ENTER' : freevo.DVDNAV_SELECT, + 'SELECT' : freevo.DVDNAV_SELECT, + 'DISPLAY' : freevo.TOGGLE_OSD, + 'MENU' : freevo.DVDNAV_MENU, } AUDIO_EVENTS = { - 'STOP' : STOP, - 'EXIT' : STOP, - 'PLAY' : PLAY, - 'PAUSE' : PAUSE, - 'LEFT' : Event(SEEK, -60), - 'RIGHT' : Event(SEEK, 60), - 'REW' : Event(SEEK, -10), - 'FFWD' : Event(SEEK, 10), - 'UP' : PLAYLIST_PREV, - 'DOWN' : PLAYLIST_NEXT, - 'CH+' : PLAYLIST_PREV, - 'CH-' : PLAYLIST_NEXT, - '1' : INPUT_1, - '2' : INPUT_2, - '3' : INPUT_3, - '4' : INPUT_4, - '5' : INPUT_5, - '6' : INPUT_6, - '7' : INPUT_7, - '8' : INPUT_8, - '9' : INPUT_9, + 'STOP' : freevo.STOP, + 'EXIT' : freevo.STOP, + 'PLAY' : freevo.PLAY, + 'PAUSE' : freevo.PAUSE, + 'LEFT' : freevo.Event(freevo.SEEK, -60), + 'RIGHT' : freevo.Event(freevo.SEEK, 60), + 'REW' : freevo.Event(freevo.SEEK, -10), + 'FFWD' : freevo.Event(freevo.SEEK, 10), + 'UP' : freevo.PLAYLIST_PREV, + 'DOWN' : freevo.PLAYLIST_NEXT, + 'CH+' : freevo.PLAYLIST_PREV, + 'CH-' : freevo.PLAYLIST_NEXT, + '1' : freevo.INPUT_1, + '2' : freevo.INPUT_2, + '3' : freevo.INPUT_3, + '4' : freevo.INPUT_4, + '5' : freevo.INPUT_5, + '6' : freevo.INPUT_6, + '7' : freevo.INPUT_7, + '8' : freevo.INPUT_8, + '9' : freevo.INPUT_9, } IMAGE_EVENTS = { - 'STOP' : STOP, - 'EXIT' : STOP, - 'PLAY' : PLAY, - 'PAUSE' : PAUSE, - 'LEFT' : Event(IMAGE_ROTATE, 'left'), - 'RIGHT' : Event(IMAGE_ROTATE, 'right'), - '1' : Event(ZOOM_IN, 1.2), - '2' : Event(ZOOM_OUT, -1.2), - '3' : Event(ZOOM, 1.0), - 'DISPLAY' : TOGGLE_OSD, - 'REC' : IMAGE_SAVE, - 'UP' : PLAYLIST_PREV, - 'DOWN' : PLAYLIST_NEXT, - 'CH+' : PLAYLIST_PREV, - 'CH-' : PLAYLIST_NEXT + 'STOP' : freevo.STOP, + 'EXIT' : freevo.STOP, + 'PLAY' : freevo.PLAY, + 'PAUSE' : freevo.PAUSE, + 'LEFT' : freevo.Event(freevo.IMAGE_ROTATE, 'left'), + 'RIGHT' : freevo.Event(freevo.IMAGE_ROTATE, 'right'), + '1' : freevo.Event(freevo.ZOOM_IN, 1.2), + '2' : freevo.Event(freevo.ZOOM_OUT, -1.2), + '3' : freevo.Event(freevo.ZOOM, 1.0), + 'DISPLAY' : freevo.TOGGLE_OSD, + 'REC' : freevo.IMAGE_SAVE, + 'UP' : freevo.PLAYLIST_PREV, + 'DOWN' : freevo.PLAYLIST_NEXT, + 'CH+' : freevo.PLAYLIST_PREV, + 'CH-' : freevo.PLAYLIST_NEXT } IMAGE_ZOOM_EVENTS = { - 'STOP' : STOP, - 'EXIT' : STOP, - 'PLAY' : PLAY, - 'PAUSE' : PAUSE, - 'LEFT' : Event(IMAGE_MOVE, -50, 0), - 'RIGHT' : Event(IMAGE_MOVE, 50, 0), - 'UP' : Event(IMAGE_MOVE, 0, -50), - 'DOWN' : Event(IMAGE_MOVE, 0, 50), - '1' : Event(ZOOM_IN, 1.2), - '2' : Event(ZOOM_OUT, -1.2), - '3' : Event(ZOOM, 1.0), - 'DISPLAY' : TOGGLE_OSD, - 'REC' : IMAGE_SAVE, - 'CH+' : PLAYLIST_PREV, - 'CH-' : PLAYLIST_NEXT + 'STOP' : freevo.STOP, + 'EXIT' : freevo.STOP, + 'PLAY' : freevo.PLAY, + 'PAUSE' : freevo.PAUSE, + 'LEFT' : freevo.Event(freevo.IMAGE_MOVE, -50, 0), + 'RIGHT' : freevo.Event(freevo.IMAGE_MOVE, 50, 0), + 'UP' : freevo.Event(freevo.IMAGE_MOVE, 0, -50), + 'DOWN' : freevo.Event(freevo.IMAGE_MOVE, 0, 50), + '1' : freevo.Event(freevo.ZOOM_IN, 1.2), + '2' : freevo.Event(freevo.ZOOM_OUT, -1.2), + '3' : freevo.Event(freevo.ZOOM, 1.0), + 'DISPLAY' : freevo.TOGGLE_OSD, + 'REC' : freevo.IMAGE_SAVE, + 'CH+' : freevo.PLAYLIST_PREV, + 'CH-' : freevo.PLAYLIST_NEXT } GAMES_EVENTS = { - 'EXIT' : STOP, - 'STOP' : STOP, - 'SELECT' : STOP, - 'MENU' : MENU, + 'EXIT' : freevo.STOP, + 'STOP' : freevo.STOP, + 'SELECT' : freevo.STOP, + 'MENU' : freevo.MENU, } GLOBAL_EVENTS = { - 'VOL+' : MIXER_VOLUP, - 'VOL-' : MIXER_VOLDOWN, - 'MUTE' : MIXER_MUTE, - 'TOGGLE' : TOGGLE_APPLICATION + 'VOL+' : freevo.MIXER_VOLUP, + 'VOL-' : freevo.MIXER_VOLDOWN, + 'MUTE' : freevo.MIXER_MUTE, + 'TOGGLE' : freevo.TOGGLE_APPLICATION } Modified: branches/candy/ui/src/input/plugins/interface.py ============================================================================== --- branches/candy/ui/src/input/plugins/interface.py (original) +++ branches/candy/ui/src/input/plugins/interface.py Tue Feb 24 15:36:23 2009 @@ -38,16 +38,14 @@ # freevo imports from freevo import plugin -from freevo.ui import config -from freevo.ui.input import EVENTMAP as global_map -from freevo.ui.event import Event -from freevo.ui.application import get_eventmap as current_app +from ... import api as freevo +from .. import EVENTMAP as global_map # get logging object log = logging.getLogger('input') # get config event map -config_map = config.input.eventmap +config_map = freevo.config.input.eventmap class InputPlugin(plugin.Plugin): """ @@ -62,13 +60,13 @@ if not key: return None - for app in (current_app(), 'global'): + for app in (freevo.get_eventmap(), 'global'): # check config file event mapping if app in config_map and key in config_map[app]: - event = Event(*config_map[app][key].split(' ')) + event = freevo.Event(*config_map[app][key].split(' ')) return event.post(event_source='user') # check global pre-defined event mapping if app in global_map and key in global_map[app]: return global_map[app][key].post(event_source='user') - log.warning('no event mapping for key %s in %s' % (key, current_app())) + log.warning('no event mapping for key %s in %s' % (key, freevo.get_eventmap())) Modified: branches/candy/ui/src/input/plugins/joystick.py ============================================================================== --- branches/candy/ui/src/input/plugins/joystick.py (original) +++ branches/candy/ui/src/input/plugins/joystick.py Tue Feb 24 15:36:23 2009 @@ -43,9 +43,8 @@ # freevo imports from freevo.resources import ResourceHandler -from freevo.ui import application +from ... import api as freevo from interface import InputPlugin -from freevo.ui import config import logging log = logging.getLogger('input') @@ -59,7 +58,7 @@ def __init__(self): InputPlugin.__init__(self) - self.config = config.input.plugin.joystick + self.config = freevo.config.input.plugin.joystick self.device_name = self.config.device Modified: branches/candy/ui/src/input/plugins/keyboard.py ============================================================================== --- branches/candy/ui/src/input/plugins/keyboard.py (original) +++ branches/candy/ui/src/input/plugins/keyboard.py Tue Feb 24 15:36:23 2009 @@ -35,10 +35,8 @@ import logging # freevo imports -from freevo.ui import config - -# input imports -from freevo.ui.input import KEYBOARD_MAP +from ... import api as freevo +from .. import KEYBOARD_MAP from freevo.view import signals from interface import InputPlugin @@ -57,7 +55,7 @@ InputPlugin.plugin_activate(self, level) signals["key-press"].connect(self.handle) self.keymap = copy.deepcopy(KEYBOARD_MAP) - for key, mapping in config.input.keyboardmap.items(): + for key, mapping in freevo.config.input.keyboardmap.items(): self.keymap[key] = mapping.upper() Modified: branches/candy/ui/src/input/plugins/lirc.py ============================================================================== --- branches/candy/ui/src/input/plugins/lirc.py (original) +++ branches/candy/ui/src/input/plugins/lirc.py Tue Feb 24 15:36:23 2009 @@ -32,7 +32,7 @@ # ----------------------------------------------------------------------------- import kaa.input.lirc -from freevo.ui import config +from ... import api as freevo from interface import InputPlugin class PluginInterface(InputPlugin): @@ -41,5 +41,5 @@ """ def __init__(self): InputPlugin.__init__(self) - kaa.input.lirc.init('freevo', config.input.plugin.lirc.lircrc) + kaa.input.lirc.init('freevo', freevo.config.input.plugin.lirc.lircrc) kaa.input.lirc.signal.connect(self.post_key) Modified: branches/candy/ui/src/plugins/dpms.py ============================================================================== --- branches/candy/ui/src/plugins/dpms.py (original) +++ branches/candy/ui/src/plugins/dpms.py Tue Feb 24 15:36:23 2009 @@ -39,10 +39,10 @@ # freevo core imports from freevo.plugin import Plugin -# freevo.ui imports -from freevo.ui import config -from freevo.ui.event import Event, DPMS_BLANK_SCREEN -from freevo.ui.application import signals as app_signals +# freevo imports +from .. import api as freevo +# FIXME: api import failure +from ..application import signals as app_signals # blanking modes OFF, AUTO, USER = range(3) @@ -74,7 +74,7 @@ Poll function called every minute to check for timeout. """ self.counter += 1 - if self.counter == config.plugin.dpms.timeout: + if self.counter == freevo.config.plugin.dpms.timeout: # timeout, force dpms and turn off the monitor self._mode = AUTO self.xset('dpms force off') @@ -103,7 +103,7 @@ # user generated event (key/button), reset timeout counter self.counter = 0 if (event.source == 'user' and self._mode == AUTO) or \ - (self._mode == USER and event == DPMS_BLANK_SCREEN): + (self._mode == USER and event == freevo.DPMS_BLANK_SCREEN): # screen is blank right now, restore it self._mode = OFF self.xset('dpms force on s reset') @@ -111,7 +111,7 @@ self.timer.start(60) return - if event == DPMS_BLANK_SCREEN: + if event == freevo.DPMS_BLANK_SCREEN: # event to turn off the monitor self._mode = USER self.xset('dpms force off') Modified: branches/candy/ui/src/plugins/file_ops.py ============================================================================== --- branches/candy/ui/src/plugins/file_ops.py (original) +++ branches/candy/ui/src/plugins/file_ops.py Tue Feb 24 15:36:23 2009 @@ -32,14 +32,13 @@ import logging # freevo imports -from freevo.ui.menu import Action, ItemPlugin -from freevo.ui.application import ConfirmWindow +from .. import api as freevo # get logging object log = logging.getLogger() -class PluginInterface(ItemPlugin): +class PluginInterface(freevo.ItemPlugin): """ Small plugin to delete files """ @@ -59,7 +58,7 @@ actions = [] if item.files.delete_possible(): - a = Action(_('Delete'), self.delete, 'delete') + a = freevo.Action(_('Delete'), self.delete, 'delete') actions.append(a) return actions @@ -67,7 +66,7 @@ def delete(self, item): txt = _('Do you wish to delete\n \'%s\'?') % item.name - box = ConfirmWindow(txt, default_choice=1) + box = freevo.ConfirmWindow(txt, default_choice=1) box.buttons[0].connect(self._delete, item) box.show() Modified: branches/candy/ui/src/plugins/idlebar/plugin.py ============================================================================== --- branches/candy/ui/src/plugins/idlebar/plugin.py (original) +++ branches/candy/ui/src/plugins/idlebar/plugin.py Tue Feb 24 15:36:23 2009 @@ -32,7 +32,8 @@ import logging from freevo import plugin, view -from freevo.ui import application, config +# FIXME: api import failure +from ... import application # get logging object log = logging.getLogger() Modified: branches/candy/ui/src/plugins/lcd.py ============================================================================== --- branches/candy/ui/src/plugins/lcd.py (original) +++ branches/candy/ui/src/plugins/lcd.py Tue Feb 24 15:36:23 2009 @@ -30,8 +30,9 @@ import kaa from freevo import plugin -from freevo.ui import application -from freevo.ui.event import PLAY_START, PLAY_END, STOP, OSD_MESSAGE +from .. import api as freevo +# FIXME: api import failure +from .. import application import logging log = logging.getLogger() @@ -174,16 +175,16 @@ def eventhandler(self, event): self.update() - if event == PLAY_START: + if event == freevo.PLAY_START: if self.running: self.timer.start(0.2) self.playitem = event.arg - elif event == PLAY_END or event == STOP: + elif event == freevo.PLAY_END or event == freevo.STOP: self.playitem = None self.timer.stop() - elif event == OSD_MESSAGE: + elif event == freevo.OSD_MESSAGE: result = [] line = '' for word in re.findall(u'.*?[, -.;\n\m\r]', unicode(event.arg) + u' '): Modified: branches/candy/ui/src/plugins/osd.py ============================================================================== --- branches/candy/ui/src/plugins/osd.py (original) +++ branches/candy/ui/src/plugins/osd.py Tue Feb 24 15:36:23 2009 @@ -40,7 +40,7 @@ # freevo imports from freevo import plugin, view -from freevo.ui.event import OSD_MESSAGE +from .. import api as freevo # get logging object log = logging.getLogger() @@ -57,7 +57,7 @@ init the osd """ super(PluginInterface, self).__init__() - kaa.EventHandler(self.show).register([ OSD_MESSAGE ]) + kaa.EventHandler(self.show).register([ freevo.OSD_MESSAGE ]) self.widget = None self.hide_timer = kaa.OneShotTimer(self.hide) Modified: branches/candy/ui/src/plugins/shoppingcart.py ============================================================================== --- branches/candy/ui/src/plugins/shoppingcart.py (original) +++ branches/candy/ui/src/plugins/shoppingcart.py Tue Feb 24 15:36:23 2009 @@ -38,17 +38,17 @@ import kaa # freevo imports -from freevo.ui.menu import Action, ItemPlugin +from .. import api as freevo -class PluginInterface(ItemPlugin): +class PluginInterface(freevo.ItemPlugin): """ This plugin copies or moves files to directories. Go to a file hit enter pick 'add to cart' and then go to a directory. Press enter and pick what you want to do. """ def __init__(self): - ItemPlugin.__init__(self) + super(PluginInterface, self).__init__() self.cart = [] @@ -107,11 +107,11 @@ break else: # add move action - a = Action(_('Cart: Move Files Here'), self.move_or_copy) + a = freevo.Action(_('Cart: Move Files Here'), self.move_or_copy) a.parameter('move') actions.append(a) # add copy action - a = Action(_('Cart: Copy Files Here'), self.move_or_copy) + a = freevo.Action(_('Cart: Copy Files Here'), self.move_or_copy) a.parameter('copy') actions.append(a) @@ -124,7 +124,7 @@ txt = _('Add Directory to Cart') else: txt = _('Remove Directory to Cart') - a = Action(txt, self.add_or_remove, 'cart:add') + a = freevo.Action(t... [truncated message content] |