Author: dmeyer
Date: Wed Feb 7 21:02:53 2007
New Revision: 9176
Modified:
trunk/ui/share/freevo_config.py
trunk/ui/src/audio/audiodiskitem.py
trunk/ui/src/config.cxml
trunk/ui/src/directory.py
trunk/ui/src/menu/mediaitem.py
Log:
convert directory config to kaa.config style
Modified: trunk/ui/share/freevo_config.py
==============================================================================
--- trunk/ui/share/freevo_config.py (original)
+++ trunk/ui/share/freevo_config.py Wed Feb 7 21:02:53 2007
@@ -106,83 +106,6 @@
# ======================================================================
-# Freevo directory settings:
-# ======================================================================
-
-#
-# Should directories sorted by date instead of filename?
-# 0 = No, always sort by filename.
-# 1 = Yes, sort by date
-# 2 = No, don't sory by date for normal directories,
-# but sort by date for TV_RECORD_DIR.
-#
-DIRECTORY_SORT_BY_DATE = 2
-
-#
-# Should directory items be sorted in reverse order?
-#
-DIRECTORY_REVERSE_SORT = 0
-
-#
-# Should we use "smart" sorting?
-# Smart sorting ignores the word "The" in item names.
-#
-DIRECTORY_SMART_SORT = 0
-
-#
-# Should Freevo autoplay an item if only one item is in the directory?
-#
-DIRECTORY_AUTOPLAY_SINGLE_ITEM = 1
-
-#
-# Force the skin to use a specific layout number. -1 == no force. The layout
-# toggle with DISPLAY will be disabled
-#
-DIRECTORY_FORCE_SKIN_LAYOUT = -1
-
-#
-# Format string for the audio item names.
-#
-# Possible strings:
-# a = artist, n = tracknumber, t = title, y = year, f = filename
-#
-# Example:
-# This will show the title and the track number:
-# DIRECTORY_AUDIO_FORMAT_STRING = '%(n)s - %(t)s'
-#
-DIRECTORY_AUDIO_FORMAT_STRING = '%(t)s'
-
-#
-# Use media id tags to generate the name of the item. This should be
-# enabled all the time. It should only be disabled for directories with
-# broken tags.
-#
-DIRECTORY_USE_MEDIADB_NAMES = 1
-
-#
-# Make all items a playlist. So when one is finished, the next one will
-# start. It's also possible to browse through the list with UP and DOWN
-#
-DIRECTORY_CREATE_PLAYLIST = [ 'audio', 'image' ]
-
-#
-# Add playlist files ('m3u') to the directory
-#
-DIRECTORY_ADD_PLAYLIST_FILES = [ 'audio', 'image' ]
-
-#
-# Add the item 'Random Playlist' to the directory
-#
-DIRECTORY_ADD_RANDOM_PLAYLIST = [ 'audio' ]
-
-#
-# Make 'Play' not 'Browse' the default action when only items and not
-# subdirectories are in the directory
-#
-DIRECTORY_AUTOPLAY_ITEMS = [ ]
-
-
-# ======================================================================
# Freevo remote control settings:
# ======================================================================
Modified: trunk/ui/src/audio/audiodiskitem.py
==============================================================================
--- trunk/ui/src/audio/audiodiskitem.py (original)
+++ trunk/ui/src/audio/audiodiskitem.py Wed Feb 7 21:02:53 2007
@@ -37,7 +37,7 @@
import os
# Freevo imports
-from freevo.ui import config
+from freevo.ui.config import config
from freevo.ui.menu import Action, Menu
from audioitem import AudioItem
@@ -82,8 +82,7 @@
items = []
# random playlist (only active for audio)
- if 'audio' in config.DIRECTORY_ADD_RANDOM_PLAYLIST and \
- len(play_items) > 1:
+ if 'audio' in config.directory.playlist.random and len(play_items) > 1:
pl = Playlist(_('Random playlist'), play_items, self, random=True)
pl.autoplay = True
items += [ pl ]
Modified: trunk/ui/src/config.cxml
==============================================================================
--- trunk/ui/src/config.cxml (original)
+++ trunk/ui/src/config.cxml Wed Feb 7 21:02:53 2007
@@ -1,7 +1,64 @@
<?xml version="1.0"?>
-<config name="audio.plugin">
- <desc lang="en">audio plugins</desc>
- <group name="artist" plugin="10">
- <desc>Show audio files sorted by artist and album</desc>
+<config name="">
+ <group name="directory">
+ <desc>Directory settings</desc>
+
+ <group name="sort">
+ <desc>Settings how to sort items in a directory</desc>
+ <var name="type" default="tv-by-date">
+ <desc>
+ How to sort the items in a directory. Valid values are
+ 'name' (sort by name), 'date' (sort by date) and
+ 'tv-by-date' (sort by name and only sort directories in the
+ tv menu by date)
+ </desc>
+ <values>
+ <value>name</value>
+ <value>date</value>
+ <value>tv-by-date</value>
+ </values>
+ </var>
+ <var name="reverse" default="False">
+ <desc>Sort directory items in reverse order</desc>
+ </var>
+ <var name="smart" default="True">
+ <desc>Ignore 'The' and 'A' when sorting by name</desc>
+ </var>
+ </group>
+
+ <group name="playlist">
+ <desc>Setting for handling a directory as playlist</desc>
+
+ <var name="autoplay" default="True">
+ <desc>Autoplay an item if only one item is in the
directory</desc>
+ </var>
+
+ <var name="isplaylist" default="audio,image">
+ <desc>
+ Make all items a playlist. So when one is finished, the
+ next one will start. It's also possible to browse through
+ the list with UP and DOWN. The value is a comma sperated
+ list of media types.
+ </desc>
+ </var>
+
+ <var name="include" default="audio,image">
+ <desc>
+ Add playlist file from the directory. The value is a comma
+ sperated list of media types.
+ </desc>
+ </var>
+ <var name="random" default="audio">
+ <desc>
+ Add a random playlist item. The value is a comma sperated
+ list of media types.
+ </desc>
+ </var>
+ </group>
+
+ <var name="use-metadata" default="True">
+ <desc>Use names from metadata and not the filename</desc>
+ </var>
</group>
+
</config>
Modified: trunk/ui/src/directory.py
==============================================================================
--- trunk/ui/src/directory.py (original)
+++ trunk/ui/src/directory.py Wed Feb 7 21:02:53 2007
@@ -44,7 +44,7 @@
from kaa.strutils import str_to_unicode
# freevo imports
-import config
+from config import config
import util
import menu
@@ -60,32 +60,39 @@
log = logging.getLogger()
# variables for 'configure' submenu
-_variables = [
- ('SORT_BY_DATE', _('Sort By Date'),
+CONFIGURE = [
+ ('sort_type', _('Sort By Date'),
_('Sort directory by date and not by name.')),
- ('AUTOPLAY_SINGLE_ITEM', _('Autoplay Single Item'),
+ ('autoplay_single_item', _('Autoplay Single Item'),
_('Don\'t show directory if only one item exists and auto select the
item.')),
- ('USE_MEDIADB_NAMES', _('Use Tag Names'),
+ ('use_metadata', _('Use Tag Names'),
_('Use the names from the media files tags as display name.')),
- ('REVERSE_SORT', _('Reverse Sort'),
+ ('sort_reverse', _('Reverse Sort'),
_('Show the items in the list in reverse order.')),
- ('CREATE_PLAYLIST', _('Create Playlist'),
+ ('isplaylist', _('Is Playlist'),
_('Handle the directory as playlist and play the next item when ine is
done.')) ,
- ('AUTOPLAY_ITEMS', _('Autoplay Items'),
+ ('autoplay_items', _('Autoplay Items'),
_('Autoplay the whole directory (as playlist) when it contains only
files.')),
- ('HIDE_PLAYED', _('Hide Played Items'),
+ ('hide_played', _('Hide Played Items'),
_('Hide items already played.'))]
+# get config object directory
+config = config.directory
+
+# mapping from internal names to config file
+CONFIG_MAPPING = {
+ 'sort_type': config.sort.type,
+ 'autoplay_single_item': config.playlist.autoplay,
+ 'use_metadata': config.use_metadata,
+ 'sort_reverse': config.sort.reverse,
+ 'isplaylist': config.playlist.isplaylist,
+ }
+
+# register to beacon as string: on/off/auto
kaa.beacon.register_file_type_attrs('dir',
freevo_num_items = (dict, kaa.beacon.ATTR_SIMPLE),
- freevo_sort_by_date = (str, kaa.beacon.ATTR_SIMPLE),
- freevo_autoplay_single_item = (str, kaa.beacon.ATTR_SIMPLE),
- freevo_use_mediadb_names = (str, kaa.beacon.ATTR_SIMPLE),
- freevo_reverse_sort = (str, kaa.beacon.ATTR_SIMPLE),
- freevo_create_playlist = (str, kaa.beacon.ATTR_SIMPLE),
- freevo_autoplay_items = (str, kaa.beacon.ATTR_SIMPLE),
- freevo_hide_played = (str, kaa.beacon.ATTR_SIMPLE),
+ **dict([ ('freevo_' + x[0], (str, kaa.beacon.ATTR_SIMPLE)) for x in
CONFIGURE ])
)
def smartsort(x,y):
@@ -256,7 +263,8 @@
return value == 'yes'
if isinstance(self.parent, DirItem):
return self.parent[key]
- value = getattr(config, 'DIRECTORY_%s' % key[7:].upper(), False)
+ # config does not know about autoplay_items and hide_played
+ value = CONFIG_MAPPING.get(key[7:], False)
if not isinstance(value, (list, tuple)):
if value in (1, True):
return True
@@ -454,7 +462,7 @@
#
# sort directories
- if config.DIRECTORY_SMART_SORT:
+ if config.sort.smart:
dir_items.sort(lambda l, o: smartsort(l.dir,o.dir))
else:
dir_items.sort(lambda l, o: cmp(l.dir.upper(), o.dir.upper()))
@@ -463,10 +471,10 @@
pl_items.sort(lambda l, o: cmp(l.name.upper(), o.name.upper()))
# sort normal items
- sort_by_date = self['config:sort_by_date']
- if sort_by_date == 2 and not self.display_type == 'tv':
- sort_by_date = False
- if sort_by_date:
+ sort_type = self['config:sort_type']
+ if sort_type == 'tv-by-date' and not self.display_type == 'tv':
+ sort_type = False
+ if sort_type:
play_items.sort(lambda l, o: cmp(l.sort('date').upper(),
o.sort('date').upper()))
else:
@@ -482,19 +490,19 @@
num_items[2] = len(dir_items)
self.info['freevo_num_items'] = copy.copy(num_items_all)
- if self['config:reverse_sort']:
+ if self['config:sort_reverse']:
dir_items.reverse()
play_items.reverse()
pl_items.reverse()
# delete pl_items if they should not be displayed
if self.display_type and not self.display_type in \
- config.DIRECTORY_ADD_PLAYLIST_FILES:
+ config.playlist.include:
pl_items = []
# add all playable items to the playlist of the directory
# to play one files after the other
- if self['config:create_playlist']:
+ if self['config:isplaylist']:
self.playlist = play_items
@@ -503,8 +511,7 @@
# random playlist (only active for audio)
if self.display_type and self.display_type in \
- config.DIRECTORY_ADD_RANDOM_PLAYLIST \
- and len(play_items) > 1:
+ config.playlist.random and len(play_items) > 1:
pl = Playlist(_('Random playlist'), play_items, self,
random=True)
pl.autoplay = True
@@ -571,7 +578,7 @@
show the configure dialog for folder specific settings
"""
items = []
- for i, name, descr in _variables:
+ for i, name, descr in CONFIGURE:
name += '\t' + self.configure_get_status(i)
action = ActionItem(name, self, self.configure_set_var, descr)
action.parameter(var=i)
Modified: trunk/ui/src/menu/mediaitem.py
==============================================================================
--- trunk/ui/src/menu/mediaitem.py (original)
+++ trunk/ui/src/menu/mediaitem.py Wed Feb 7 21:02:53 2007
@@ -100,7 +100,7 @@
# FIXME: this is slow. Maybe handle this in the gui code
# and choose to print self.info.get('name')
if self.parent and \
- self.parent['config:use_mediadb_names'] in (None, True):
+ self.parent['config:use_metadata'] in (None, True):
self.name = self.info.get('title')
if not self.name:
self.name = str_to_unicode(self.info.get('name'))
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog