Author: dmeyer
Date: Tue May  1 17:18:10 2007
New Revision: 9539

Modified:
   trunk/ui/src/image/imageitem.py
   trunk/ui/src/mainmenu.py
   trunk/ui/src/menu/__init__.py
   trunk/ui/src/menu/item.py
   trunk/ui/src/menu/mediaitem.py

Log:
some cleanup in class Item

Modified: trunk/ui/src/image/imageitem.py
==============================================================================
--- trunk/ui/src/image/imageitem.py     (original)
+++ trunk/ui/src/image/imageitem.py     Tue May  1 17:18:10 2007
@@ -46,8 +46,10 @@
     """
     An item for image files
     """
+    type = 'image'
+    
     def __init__(self, url, parent, duration = config.image.viewer.duration):
-        MediaItem.__init__(self, parent, type='image')
+        MediaItem.__init__(self, parent)
         # set url and parse the name
         self.set_url(url)
         self.duration = duration

Modified: trunk/ui/src/mainmenu.py
==============================================================================
--- trunk/ui/src/mainmenu.py    (original)
+++ trunk/ui/src/mainmenu.py    Tue May  1 17:18:10 2007
@@ -82,20 +82,6 @@
             self.image = gui.theme.getimage(os.path.join(imagedir, skin_type))
 
 
-    def actions(self):
-        """
-        Actions for this item.
-        """
-        return [ Action(self.name, self.select) ]
-
-
-    def select(self):
-        """
-        Select the item (default action). Need to be overloaded by the
-        inherting item or actions() need to be overloaded.
-        """
-        raise RuntimeError("no action defined for %s", self)
-    
 
 class MainMenuPlugin(plugin.Plugin):
     """
@@ -126,7 +112,7 @@
         """
         Setup the main menu and handle events (remote control, etc)
         """
-        Item.__init__(self)
+        Item.__init__(self, None)
         items = []
         for p in MainMenuPlugin.plugins():
             items += p.items(self)

Modified: trunk/ui/src/menu/__init__.py
==============================================================================
--- trunk/ui/src/menu/__init__.py       (original)
+++ trunk/ui/src/menu/__init__.py       Tue May  1 17:18:10 2007
@@ -35,20 +35,10 @@
 
 # import the submodules
 from files import Files
-from item import Item
+from item import Item, ActionItem
 from listing import ItemList
 from mediaitem import MediaItem
 from action import Action
 from menu import Menu
 from stack import MenuStack
 from plugin import ItemPlugin, MediaPlugin
-
-class ActionItem(Item, Action):
-    """
-    A simple item with one action. The first parameter of the function
-    passed to this action is always the parent item if not None.
-    """
-    def __init__(self, name, parent, function, description=''):
-        Action.__init__(self, name, function, description=description)
-        Item.__init__(self, parent, self)
-        self.item = parent

Modified: trunk/ui/src/menu/item.py
==============================================================================
--- trunk/ui/src/menu/item.py   (original)
+++ trunk/ui/src/menu/item.py   Tue May  1 17:18:10 2007
@@ -33,7 +33,7 @@
 #
 # -----------------------------------------------------------------------------
 
-__all__ = [ 'Item' ]
+__all__ = [ 'Item', 'ActionItem' ]
 
 # python imports
 import logging
@@ -45,6 +45,7 @@
 
 # menu imports
 from plugin import ItemPlugin
+from action import Action
 
 # get logging object
 log = logging.getLogger()
@@ -57,24 +58,17 @@
     """
     type = None
     
-    def __init__(self, parent=None, action=None, type=None):
+    def __init__(self, parent):
         """
         Init the item. Sets all needed variables, if parent is given also
         inherit some settings from there.
         """
         self.info = {}
         self.menu = None
-        if type is not None:
-            self.type = type
         self._image = None
 
-        self.action = action
-        if action:
-            self.name = action.name
-            self.description = action.description
-        else:
-            self.name = u''
-            self.description  = ''
+        self.name = u''
+        self.description  = ''
 
         if parent:
             self.parent = weakref(parent)
@@ -152,11 +146,17 @@
         Returns a list of possible actions on this item. The first
         one is autoselected by pressing SELECT
         """
-        if self.action:
-            return [ self.action ]
-        return []
+        return [ Action(self.name, self.select) ]
+
 
+    def select(self):
+        """
+        Select the item (default action). Need to be overloaded by the
+        inherting item or actions() need to be overloaded.
+        """
+        raise RuntimeError("no action defined for %s", self)
 
+    
     def get_actions(self):
         """
         Get all actions for the item. Do not override this function,
@@ -264,3 +264,19 @@
             r = getattr(self, attr, None)
 
         return r
+
+
+
+class ActionItem(Item, Action):
+    """
+    A simple item with one action. The first parameter of the function
+    passed to this action is always the parent item if not None.
+    """
+    def __init__(self, name, parent, function, description=''):
+        Action.__init__(self, name, function, description=description)
+        Item.__init__(self, parent)
+        self.item = parent
+
+
+    def select(self):
+        return self()

Modified: trunk/ui/src/menu/mediaitem.py
==============================================================================
--- trunk/ui/src/menu/mediaitem.py      (original)
+++ trunk/ui/src/menu/mediaitem.py      Tue May  1 17:18:10 2007
@@ -56,8 +56,8 @@
     This item is for a media. It's only a template for image, video
     or audio items
     """
-    def __init__(self, parent=None, type=None):
-        Item.__init__(self, parent, type=type)
+    def __init__(self, parent):
+        Item.__init__(self, parent)
         self.url = 'null://'
         self.filename = None
         self.fxdinfo = {}

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to