Author: dmeyer
Date: Fri Feb  2 18:51:27 2007
New Revision: 9128

Modified:
   trunk/ui/src/audio/interface.py
   trunk/ui/src/config.py
   trunk/ui/src/image/interface.py
   trunk/ui/src/plugin.py
   trunk/ui/src/plugins/mediamenu.py
   trunk/ui/src/tv/tvmenu.py
   trunk/ui/src/video/interface.py

Log:
more plugin/config cleanup

Modified: trunk/ui/src/audio/interface.py
==============================================================================
--- trunk/ui/src/audio/interface.py     (original)
+++ trunk/ui/src/audio/interface.py     Fri Feb  2 18:51:27 2007
@@ -60,15 +60,16 @@
     """
     Plugin to handle all kinds of audio items
     """
-    def __init__(self):
-        plugin.MimetypePlugin.__init__(self)
-        self.display_type = [ 'audio' ]
+    display_type = [ 'audio' ]
 
+    def plugin_activate(self, level):
+        """
+        Activate the plugin.
+        """
         # add fxd parser callback
         fxditem.add_parser(['audio'], 'audio', fxdhandler)
 
         # activate the mediamenu for audio
-        level = plugin.is_active('audio')[2]
         args = _('Audio Main Menu'), 'audio', config.AUDIO_ITEMS
         plugin.activate('mediamenu', level=level, args=args)
 

Modified: trunk/ui/src/config.py
==============================================================================
--- trunk/ui/src/config.py      (original)
+++ trunk/ui/src/config.py      Fri Feb  2 18:51:27 2007
@@ -205,78 +205,6 @@
 GUI_FONT_DEFAULT_NAME = os.path.join(FONT_DIR, GUI_FONT_DEFAULT_NAME)
 
 #
-# set data dirs
-# if not set, set it to root and home dir
-# if set, make all path names absolute
-#
-for type in ('video', 'audio', 'image', 'games'):
-    n = '%s_ITEMS' % type.upper()
-    x = eval(n)
-    if x == None:
-        x = []
-        if os.environ.has_key('HOME') and os.environ['HOME']:
-            x.append(('Home', os.environ['HOME']))
-        x.append(('Root', '/'))
-        exec('%s = x' % n)
-        if plugin.is_active('mediamenu', type):
-            log.warning('%s not set, set it to Home directory' % n)
-
-    elif type == 'games':
-        abs = []
-        for d in x:
-            dirs = []
-
-            for p in d[2]:
-                pos = p.find(':')
-
-                if pos == -1:
-                    dirs.append(os.path.abspath(p))
-                else:
-                    if pos > p.find('/'):
-                        dirs.append(os.path.abspath(p))
-                    else:
-                        dirs.append(p[0:pos + 1] + os.path.abspath(p[pos + 
1:]))
-
-            abs.append(( d[0], d[1], dirs, d[3], d[4], d[5] ))
-
-        exec ('%s = abs' % n)
-    else:
-        # The algorithm doesn't work for GAMES_ITEMS, so we leave it out
-        abs = []
-        for d in x:
-            if isinstance(d, (str, unicode)):
-                pos = d.find(':')
-                if pos == -1:
-                    abs.append(os.path.abspath(d))
-                else:
-                    if pos > d.find('/'):                        
-                        abs.append(os.path.abspath(d))
-                    else:
-                        abs.append(d[0:pos+1] + os.path.abspath(d[pos+1:]))
-            else:
-                pos = d[1].find(':')
-                if pos == -1:
-                    abs.append((d[0], os.path.abspath(d[1])))
-                else:
-                    if pos > d[1].find('/'):                        
-                        abs.append((d[0], os.path.abspath(d[1])))
-                    else:
-                        abs.append((d[0], d[1][0:pos+1] + \
-                                    os.path.abspath(d[1][pos+1:])))
-        exec ('%s = abs' % n)
-            
-
-        
-if not TV_RECORD_DIR:
-    TV_RECORD_DIR = VIDEO_ITEMS[0][1]
-    msg = ('TV_RECORD_DIR not set\n' +
-           '  Please set TV_RECORD_DIR to the directory, where recordings\n' +
-           '  should be stored or remove the tv plugin. Autoset variable\n' +
-           '  to %s.') % TV_RECORD_DIR
-    if plugin.is_active('tv'):
-        log.warning(msg)
-        
-#
 # compile the regexp
 #
 VIDEO_SHOW_REGEXP_MATCH = re.compile("^.*" + VIDEO_SHOW_REGEXP).match

Modified: trunk/ui/src/image/interface.py
==============================================================================
--- trunk/ui/src/image/interface.py     (original)
+++ trunk/ui/src/image/interface.py     Fri Feb  2 18:51:27 2007
@@ -53,15 +53,16 @@
     """
     Plugin to handle all kinds of image items
     """
-    def __init__(self):
-        plugin.MimetypePlugin.__init__(self)
-        self.display_type = [ 'image' ]
+    display_type = [ 'image' ]
 
+    def plugin_activate(self, level):
+        """
+        Activate the plugin.
+        """
         # register the callbacks
         fxditem.add_parser(['image'], 'slideshow', fxdhandler)
 
         # activate the mediamenu for image
-        level = plugin.is_active('image')[2]
         args = _('Image Main Menu'), 'image', config.IMAGE_ITEMS
         plugin.activate('mediamenu', level=level, args=args)
 

Modified: trunk/ui/src/plugin.py
==============================================================================
--- trunk/ui/src/plugin.py      (original)
+++ trunk/ui/src/plugin.py      Fri Feb  2 18:51:27 2007
@@ -58,7 +58,10 @@
         self._plugin_special = False
 
 
+    def plugin_activate(self, level):
+        pass
 
+    
 class MainMenuPlugin(Plugin):
     """
     Plugin class for plugins to add something to the main menu
@@ -194,29 +197,6 @@
                     self.plugins.remove(p)
 
 
-    def is_active(self, name, arg=None):
-        """
-        Search the list if the given plugin is active. If arg is set,
-        check arg, too.
-        """
-        for p in self.plugins:
-            if p[0] == name:
-                if not arg:
-                    return p
-                if isinstance(arg, list) or isinstance(arg, tuple):
-                    try:
-                        for i in range(len(arg)):
-                            if arg[i] != p[3][i]:
-                                break
-                        else:
-                            return p
-                    except:
-                        pass
-                if arg == p[3]:
-                    return p
-        return False
-
-
     def init(self, callback = None):
         """
         Load and init all the plugins. The function takes the path were the
@@ -377,6 +357,7 @@
             if p._plugin_name:
                 self.names[p._plugin_name] = p
 
+            p.plugin_activate(level)
             self.loaded_plugins.append(p)
 
         except:
@@ -390,7 +371,6 @@
 activate = _loader.activate
 remove = _loader.deactivate
 deactivate = _loader.deactivate
-is_active = _loader.is_active
 init = _loader.init
 get = _loader.get
 getbyname = _loader.getbyname

Modified: trunk/ui/src/plugins/mediamenu.py
==============================================================================
--- trunk/ui/src/plugins/mediamenu.py   (original)
+++ trunk/ui/src/plugins/mediamenu.py   Fri Feb  2 18:51:27 2007
@@ -61,6 +61,9 @@
     the 'video', 'audio', 'image' or 'games' plugin.
     """
     def __init__(self, name, type, items):
+        if items is None:
+            self.reason = 'No items defined for %s menu' % type
+            return
         plugin.MainMenuPlugin.__init__(self)
         self._name = name
         self._type = type
@@ -93,6 +96,7 @@
         for filename in self._items:
             if not isinstance(filename, (str, unicode)):
                 filename = filename[1]
+            filename = os.path.abspath(filename)
             if os.path.isdir(filename) and \
                    not os.environ.get('NO_CRAWLER') and \
                    not filename == os.environ.get('HOME') and \
@@ -134,6 +138,7 @@
                         # ... and add_args
                         add_args = item[2:]
 
+                filename = os.path.abspath(filename)
                 if os.path.isdir(filename):
                     query = kaa.beacon.query(filename=filename)
                     for d in query.get(filter='extmap').get('beacon:dir'):

Modified: trunk/ui/src/tv/tvmenu.py
==============================================================================
--- trunk/ui/src/tv/tvmenu.py   (original)
+++ trunk/ui/src/tv/tvmenu.py   Fri Feb  2 18:51:27 2007
@@ -77,9 +77,10 @@
             # FIXME: change the tvguide into a plugin
             items.append(ActionItem(_('TV Guide'), self, self.start_tvguide))
 
-        items.append(DirItem(config.TV_RECORD_DIR, None,
-                             name = _('Recorded Shows'),
-                             type='tv'))
+        if config.TV_RECORD_DIR:
+            items.append(DirItem(config.TV_RECORD_DIR, None,
+                                 name = _('Recorded Shows'),
+                                 type='tv'))
 
         # XXX: these are becomming plugins
         # items.append(menu.MenuItem(_('Search Guide'),

Modified: trunk/ui/src/video/interface.py
==============================================================================
--- trunk/ui/src/video/interface.py     (original)
+++ trunk/ui/src/video/interface.py     Fri Feb  2 18:51:27 2007
@@ -56,22 +56,24 @@
     """
     Plugin to handle all kinds of video items
     """
-    def __init__(self):
-        plugin.MimetypePlugin.__init__(self)
-        self.display_type = [ 'video' ]
+    display_type = [ 'video' ]
 
+    def plugin_activate(self, level):
+        """
+        Activate the plugin.
+        """
         # load the fxd part of video
         fxditem.add_parser(['video'], 'movie', fxdhandler.parse_movie)
         # fxditem.add_parser(['video'], 'disc-set', fxdhandler.parse_disc_set)
 
         # update the database based on the current mimetypes
         database.update()
+        
         # activate the mediamenu for video
-        level = plugin.is_active('video')[2]
         args = _('Video Main Menu'), 'video', config.VIDEO_ITEMS
         plugin.activate('mediamenu', level=level, args=args)
-        
 
+        
     def suffix(self):
         """
         return the list of suffixes this class handles

-------------------------------------------------------------------------
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

Reply via email to