Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3802/src

Modified Files:
        item.py menu.py 
Log Message:
add extra Action class for item actions

Index: item.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/item.py,v
retrieving revision 1.85
retrieving revision 1.86
diff -C2 -d -r1.85 -r1.86
*** item.py     20 Nov 2004 18:22:59 -0000      1.85
--- item.py     28 Dec 2004 18:09:58 -0000      1.86
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.86  2004/12/28 18:09:58  dischi
+ # add extra Action class for item actions
+ #
  # Revision 1.85  2004/11/20 18:22:59  dischi
  # use python logger module for debug
***************
*** 157,161 ****
                      log.error('can\'t delete %s' % f)
          
!                 
  
  class Item:
--- 160,184 ----
                      log.error('can\'t delete %s' % f)
          
! 
! class Action:
!     """
!     Action for item.actions()
!     """
!     def __init__(self, name, function=None, arg=None, shortcut=None,
!                  description=None):
!         self.name = name
!         self.function = function
!         self.arg = arg
!         self.shortcut = shortcut
!         self.description = description
! 
! 
!     def __call__(self, menuw=None):
!         """
!         call the function
!         """
!         if self.function:
!             self.function(arg=self.arg, menuw=menuw)
!         
  
  class Item:

Index: menu.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/menu.py,v
retrieving revision 1.111
retrieving revision 1.112
diff -C2 -d -r1.111 -r1.112
*** menu.py     20 Nov 2004 18:22:59 -0000      1.111
--- menu.py     28 Dec 2004 18:09:58 -0000      1.112
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.112  2004/12/28 18:09:58  dischi
+ # add extra Action class for item actions
+ #
  # Revision 1.111  2004/11/20 18:22:59  dischi
  # use python logger module for debug
***************
*** 61,65 ****
  
  from event import *
! from item import Item
  from application import Application
  
--- 64,68 ----
  
  from event import *
! from item import Item, Action
  from application import Application
  
***************
*** 95,99 ****
      def select(self, arg=None, menuw=None):
          """
!         call the default acion
          """
          if self.function:
--- 98,102 ----
      def select(self, arg=None, menuw=None):
          """
!         call the function
          """
          if self.function:
***************
*** 101,104 ****
--- 104,113 ----
  
  
+     def __call__(self, menuw=None):
+         """
+         call the function
+         """
+         if self.function:
+             self.function(arg=self.arg, menuw=menuw)
  
  class Menu:
***************
*** 400,403 ****
--- 409,416 ----
              if isinstance(a, Item):
                  items.append(a)
+             elif isinstance(a, Action):
+                 mi = MenuItem(a.name, a.function, a.arg)
+                 mi.description = a.description
+                 items.append(mi)
              else:
                  items.append(MenuItem(a[1], a[0]))
***************
*** 513,534 ****
          
          if event == MENU_SELECT or event == MENU_PLAY_ITEM:
!             action = None
!             arg    = None
! 
!             try:
!                 action = menu.selected.action
!             except AttributeError:
!                 action = menu.selected.actions()
!                 if action:
!                     action = action[0]
!                     if isinstance(action, MenuItem):
!                         action = action.function
!                         arg    = action.arg
!                     else:
!                         action = action[0]
!             if not action:
                  gui.AlertBox(text=_('No action defined for this 
choice!')).show()
              else:
!                 action( arg=arg, menuw=self )
              return True
  
--- 526,537 ----
          
          if event == MENU_SELECT or event == MENU_PLAY_ITEM:
!             actions = menu.selected.actions()
!             if not actions:
                  gui.AlertBox(text=_('No action defined for this 
choice!')).show()
              else:
!                 if not isinstance(actions[0], (Item, Action)):
!                     actions[0][0](menuw=self)
!                 else:
!                     actions[0](menuw=self)
              return True
  
***************
*** 553,557 ****
              for p in plugins:
                  for a in p.actions(menu.selected):
!                     if isinstance(a, MenuItem):
                          actions.append(a)
                      else:
--- 556,560 ----
              for p in plugins:
                  for a in p.actions(menu.selected):
!                     if isinstance(a, (MenuItem, Action)):
                          actions.append(a)
                      else:
***************
*** 570,574 ****
  
              for a in menu.selected.actions():
!                 if not isinstance(a, Item) and len(a) > 2 and a[2] == 
event.arg:
                      a[0](arg=None, menuw=self)
                      return True
--- 573,581 ----
  
              for a in menu.selected.actions():
!                 if isinstance(a, Action) and a.shortcut == event.arg:
!                     a(menuw=menuw)
!                     return True
!                 if not isinstance(a, (Item, Action)) and len(a) > 2 and \
!                        a[2] == event.arg:
                      a[0](arg=None, menuw=self)
                      return True
***************
*** 581,585 ****
              for p in plugins:
                  for a in p.actions(menu.selected):
!                     if not isinstance(a, MenuItem) and len(a) > 2 and a[2] == 
event.arg:
                          a[0](arg=None, menuw=self)
                          return True
--- 588,596 ----
              for p in plugins:
                  for a in p.actions(menu.selected):
!                     if isinstance(a, Action) and a.shortcut == event.arg:
!                         a(menuw=menuw)
!                         return True
!                     if not isinstance(a, (Item, Action)) and len(a) > 2 and \
!                            a[2] == event.arg:
                          a[0](arg=None, menuw=self)
                          return True



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to