Update of /cvsroot/freevo/freevo/src
In directory sc8-pr-cvs1:/tmp/cvs-serv1433

Modified Files:
        plugin.py playlist.py directory.py fxditem.py 
Log Message:
better handling of the MimetypePlugin

Index: plugin.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugin.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** plugin.py   30 Nov 2003 14:38:36 -0000      1.54
--- plugin.py   1 Dec 2003 19:06:46 -0000       1.55
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.55  2003/12/01 19:06:46  dischi
+ # better handling of the MimetypePlugin
+ #
  # Revision 1.54  2003/11/30 14:38:36  dischi
  # o new plugin type: MimetypePlugin to handle what files to display in
***************
*** 186,190 ****
          Plugin.__init__(self)
          self.display_type = []
-         register(self, MIMETYPE, True)
  
  
--- 189,192 ----
***************
*** 219,223 ****
  VIDEO_PLAYER   = 'VIDEO_PLAYER'
  TV             = 'TV'
- MIMETYPE       = 'MIMETYPE'
  
  
--- 221,224 ----
***************
*** 368,371 ****
--- 369,386 ----
  
  
+ def mimetype(display_type):
+     """
+     return all MimetypePlugins for the given display_type. If display_type is
+     None, return all MimetypePlugins.
+     """
+     if not display_type:
+         return __plugin_type_list__['mimetype']
+     ret = []
+     for p in __plugin_type_list__['mimetype']:
+         if not p.display_type or display_type in p.display_type:
+             ret.append(p)
+     return ret
+ 
+         
  def getall():
      """
***************
*** 592,595 ****
--- 607,613 ----
              if isinstance(p, ItemPlugin):
                  __add_to_ptl__('item%s' % special, p)
+ 
+             if isinstance(p, MimetypePlugin):
+                 __add_to_ptl__('mimetype', p)
  
          if p.plugin_name:

Index: playlist.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/playlist.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -d -r1.36 -r1.37
*** playlist.py 30 Nov 2003 14:41:10 -0000      1.36
--- playlist.py 1 Dec 2003 19:06:46 -0000       1.37
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.37  2003/12/01 19:06:46  dischi
+ # better handling of the MimetypePlugin
+ #
  # Revision 1.36  2003/11/30 14:41:10  dischi
  # use new Mimetype plugin interface
***************
*** 82,86 ****
                  line = line.replace('\\', '/') # Fix MSDOS slashes
              if os.path.exists(os.path.join(curdir,line)):
!                 for p in plugin.getbyname(plugin.MIMETYPE, True):
                      for i in p.get(self, [os.path.join(curdir, line)]):
                          self.playlist.append(i)
--- 85,90 ----
                  line = line.replace('\\', '/') # Fix MSDOS slashes
              if os.path.exists(os.path.join(curdir,line)):
!                 # XXX add display_type
!                 for p in plugin.mimetype(None):
                      for i in p.get(self, [os.path.join(curdir, line)]):
                          self.playlist.append(i)
***************
*** 115,119 ****
              if line.endswith('\r\n'):
                  line = line.replace('\\', '/') # Fix MSDOS slashes
!             for p in plugin.getbyname(plugin.MIMETYPE, True):
                  for i in p.get(self, [os.path.join(curdir, line)]):
                      self.playlist.append(i)
--- 119,124 ----
              if line.endswith('\r\n'):
                  line = line.replace('\\', '/') # Fix MSDOS slashes
!             # XXX add display_type
!             for p in plugin.mimetype(None):
                  for i in p.get(self, [os.path.join(curdir, line)]):
                      self.playlist.append(i)
***************
*** 164,168 ****
                      ss_delay += [5]
  
!                 for p in plugin.getbyname(plugin.MIMETYPE, True):
                      for i in p.get(self, [os.path.join(curdir, ss_name[0])]):
                          if i.type == 'image':
--- 169,173 ----
                      ss_delay += [5]
  
!                 for p in plugin.mimetype('image'):
                      for i in p.get(self, [os.path.join(curdir, ss_name[0])]):
                          if i.type == 'image':
***************
*** 236,239 ****
--- 241,247 ----
          
      def actions(self):
+         """
+         return the actions for this item: play and browse
+         """
          if self.autoplay:
              return [ ( self.play, _('Play') ),
***************
*** 245,248 ****
--- 253,259 ----
  
      def browse(self, arg=None, menuw=None):
+         """
+         show the playlist in the menu
+         """
          self.read_playlist()
          moviemenu = menu.Menu(self.name, self.playlist)
***************
*** 251,254 ****
--- 262,268 ----
          
      def play(self, arg=None, menuw=None):
+         """
+         play the playlist
+         """
          self.read_playlist()
          if not self.menuw:
***************
*** 256,259 ****
--- 270,274 ----
  
          if not self.playlist:
+             # XXX PopupBox please
              print _('empty playlist')
              return False
***************
*** 279,282 ****
--- 294,300 ----
  
      def cache_next(self):
+         """
+         cache next item, usefull for image playlists
+         """
          pos = self.playlist.index(self.current_item)
          pos = (pos+1) % len(self.playlist)
***************
*** 286,289 ****
--- 304,310 ----
  
      def eventhandler(self, event, menuw=None):
+         """
+         Handle playlist specific events
+         """
          if not menuw:
              menuw = self.menuw
***************
*** 339,346 ****
  
  class RandomPlaylist(Playlist):
!     def __init__(self, playlist, parent, add_args = None, recursive = True, random = 
True):
          Item.__init__(self, parent)
!         self.type     = 'playlist'
! 
          # variables only for Playlist
          self.current_item = None
--- 360,374 ----
  
  class RandomPlaylist(Playlist):
!     """
!     A playlist that can be played in random mode, recursive in subdirs
!     or a combination of both. It is _not_ possible to browse this playlist
!     right now, only play it.
!     """
!     def __init__(self, name, playlist, parent, recursive = True,
!                  random = True):
          Item.__init__(self, parent)
!         self.type         = 'playlist'
!         self.name         = name
!         
          # variables only for Playlist
          self.current_item = None
***************
*** 350,354 ****
          self.recursive    = recursive
          self.random       = random
- 
          
      def actions(self):
--- 378,381 ----
***************
*** 357,360 ****
--- 384,390 ----
  
      def play_next(self, arg=None, menuw=None):
+         if not self.unplayed:
+             return False
+         
          if self.random:
              element = random.choice(self.unplayed)
***************
*** 364,377 ****
  
          if not callable(element):
!             # try to get the item for this file
              files = [ element, ]
              play_items = []
  
!             for p in plugin.getbyname(plugin.MIMETYPE, True):
                  for i in p.get(self, files):
                      play_items.append(i)
  
              if not play_items:
-                 print 'FIXME: this should never happen'
                  return False
                  
--- 394,407 ----
  
          if not callable(element):
!             # element is a string, make a correct item
              files = [ element, ]
              play_items = []
  
!             # get a real item
!             for p in plugin.mimetype(None):
                  for i in p.get(self, files):
                      play_items.append(i)
  
              if not play_items:
                  return False
                  
***************
*** 386,390 ****
--- 416,425 ----
  
      def play(self, arg=None, menuw=None):
+         if not self.menuw:
+             self.menuw = menuw
+ 
          if isinstance(self.unplayed, tuple):
+             # playlist is a list: dir:prefix
+             # build a correct playlist now
              dir, prefix = self.unplayed
              if self.recursive:
***************
*** 421,432 ****
                          return True
              return self.play_next(menuw=menuw)
          
          # end and no next item
!         if event == PLAY_END:
              if self.current_item:
                  self.current_item.parent = self.parent
              self.current_item = None
              if menuw:
!                 menuw.show()
              return True
              
--- 456,476 ----
                          return True
              return self.play_next(menuw=menuw)
+ 
+         if event == PLAYLIST_NEXT and not self.unplayed:
+             rc.post_event(Event(OSD_MESSAGE, arg=_('no next item in playlist')))
+             return True
          
          # end and no next item
!         if event in (STOP, PLAY_END, USER_END) and menuw:
              if self.current_item:
                  self.current_item.parent = self.parent
              self.current_item = None
              if menuw:
!                 if hasattr(menuw.menustack[-1], 'is_submenu'):
!                     menuw.back_one_menu()
!                 if menuw.visible:
!                     menuw.refresh()
!                 else:
!                     menuw.show()
              return True
              
***************
*** 483,485 ****
  
  # load the MimetypePlugin
! mimetype = Mimetype()
--- 527,530 ----
  
  # load the MimetypePlugin
! plugin.activate(Mimetype())
! 

Index: directory.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/directory.py,v
retrieving revision 1.68
retrieving revision 1.69
diff -C2 -d -r1.68 -r1.69
*** directory.py        30 Nov 2003 14:41:09 -0000      1.68
--- directory.py        1 Dec 2003 19:06:46 -0000       1.69
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.69  2003/12/01 19:06:46  dischi
+ # better handling of the MimetypePlugin
+ #
  # Revision 1.68  2003/11/30 14:41:09  dischi
  # use new Mimetype plugin interface
***************
*** 166,171 ****
          self.add_args = add_args
  
-         self.mimetypes = plugin.getbyname(plugin.MIMETYPE, True)
-         
          # set directory variables to default
          global all_variables
--- 169,172 ----
***************
*** 371,375 ****
              possible_display_types = [ ]
  
!             for p in self.mimetypes:
                  for t in p.display_type:
                      if not t in possible_display_types:
--- 372,376 ----
              possible_display_types = [ ]
  
!             for p in plugin.get('mimetype'):
                  for t in p.display_type:
                      if not t in possible_display_types:
***************
*** 412,418 ****
              display_type = 'video'
  
!         for p in self.mimetypes:
!             if not p.display_type or not display_type or display_type in 
p.display_type:
!                 suffix += p.suffix()
  
          items = [ ( self.cwd, _('Browse directory')),
--- 413,418 ----
              display_type = 'video'
  
!         for p in plugin.mimetype(display_type):
!             suffix += p.suffix()
  
          items = [ ( self.cwd, _('Browse directory')),
***************
*** 428,438 ****
  
          if suffix:
!             items += [ ( RandomPlaylist((self.dir, suffix), self, recursive=False),
!                          _('Random play all items')),
!                        ( RandomPlaylist((self.dir, suffix), self),
!                          _('Recursive random play all items')), 
!                        ( RandomPlaylist((self.dir, suffix), self, random = False),
!                          _('Recursive play all items')) ]
!         
          items.append((self.configure, _('Configure directory'), 'configure'))
          return items
--- 428,438 ----
  
          if suffix:
!             items += [ RandomPlaylist(_('Random play all items'), (self.dir, suffix),
!                                       self, recursive=False),
!                        RandomPlaylist(_('Recursive random play all items'),
!                                       (self.dir, suffix), self),
!                        RandomPlaylist(_('Recursive play all items'), (self.dir, 
suffix),
!                                       self, random = False) ]
! 
          items.append((self.configure, _('Configure directory'), 'configure'))
          return items
***************
*** 613,625 ****
  
          # build play_items, pl_items and dir_items
!         for p in self.mimetypes:
!             if not p.display_type or not display_type or display_type in 
p.display_type:
!                 for i in p.get(self, files):
!                     if i.type == 'playlist':
!                         self.pl_items.append(i)
!                     elif i.type == 'dir':
!                         self.dir_items.append(i)
!                     else:
!                         self.play_items.append(i)
                          
          # normal DirItems
--- 613,624 ----
  
          # build play_items, pl_items and dir_items
!         for p in plugin.mimetype(display_type):
!             for i in p.get(self, files):
!                 if i.type == 'playlist':
!                     self.pl_items.append(i)
!                 elif i.type == 'dir':
!                     self.dir_items.append(i)
!                 else:
!                     self.play_items.append(i)
                          
          # normal DirItems
***************
*** 694,701 ****
  
          # add/delete items based on mimetypes
!         for p in self.mimetypes:
!             if not p.display_type or not display_type or display_type in 
p.display_type:
!                 p.update(self, new_files, del_files, new_items, del_items,
!                          self.play_items + self.dir_items + self.pl_items)
  
          # delete directories
--- 693,699 ----
  
          # add/delete items based on mimetypes
!         for p in plugin.mimetype(display_type):
!             p.update(self, new_files, del_files, new_items, del_items,
!                      self.play_items + self.dir_items + self.pl_items)
  
          # delete directories

Index: fxditem.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/fxditem.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** fxditem.py  30 Nov 2003 14:41:10 -0000      1.4
--- fxditem.py  1 Dec 2003 19:06:46 -0000       1.5
***************
*** 27,30 ****
--- 27,33 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.5  2003/12/01 19:06:46  dischi
+ # better handling of the MimetypePlugin
+ #
  # Revision 1.4  2003/11/30 14:41:10  dischi
  # use new Mimetype plugin interface
***************
*** 261,262 ****
--- 264,267 ----
  plugin.register_callback('fxditem', None, 'container', container_callback)
  mimetype = Mimetype()
+ plugin.activate(mimetype, level=0)
+ 




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to