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

Modified Files:
        directory.py 
Log Message:
add configure option to write a folder.fxd

Index: directory.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/directory.py,v
retrieving revision 1.38
retrieving revision 1.39
diff -C2 -d -r1.38 -r1.39
*** directory.py        21 Sep 2003 13:17:49 -0000      1.38
--- directory.py        1 Oct 2003 18:56:56 -0000       1.39
***************
*** 10,56 ****
  # -----------------------------------------------------------------------
  # $Log$
  # Revision 1.38  2003/09/21 13:17:49  dischi
  # make it possible to change between video, audio, image and games view
  #
- # Revision 1.37  2003/09/20 15:21:08  dischi
- # bugfix
- #
- # Revision 1.36  2003/09/20 15:08:25  dischi
- # some adjustments to the missing testfiles
- #
- # Revision 1.35  2003/09/14 20:09:36  dischi
- # removed some TRUE=1 and FALSE=0 add changed some debugs to _debug_
- #
- # Revision 1.34  2003/09/13 10:08:21  dischi
- # i18n support
- #
- # Revision 1.33  2003/09/05 16:10:46  mikeruelle
- # add an additional arg so new games system is happy
- #
- # Revision 1.32  2003/09/01 18:55:02  dischi
- # use progressbar when scanning
- #
- # Revision 1.31  2003/08/30 12:19:00  dischi
- # new mmpython cache call to only scan the needed directory
- #
- # Revision 1.30  2003/08/24 14:08:58  dischi
- # add import to folder.fxd options
- #
- # Revision 1.29  2003/08/24 10:39:04  dischi
- # fix a bug that the folder.fxd was not loaded anymore
- #
- # Revision 1.28  2003/08/23 18:35:16  dischi
- # new function to set the xml_file to make it possible to parse it later
- #
- # Revision 1.27  2003/08/23 15:16:18  dischi
- # o more infos in folder.fxd: title, cover-img and content info
- # o totalspace and freespace support for getattr
- #
- # Revision 1.26  2003/08/23 12:51:41  dischi
- # removed some old CVS log messages
- #
- # Revision 1.25  2003/08/13 17:33:17  dischi
- # add "please wait" message for rom drives every time
- #
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
--- 10,19 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.39  2003/10/01 18:56:56  dischi
+ # add configure option to write a folder.fxd
+ #
  # Revision 1.38  2003/09/21 13:17:49  dischi
  # make it possible to change between video, audio, image and games view
  #
  # -----------------------------------------------------------------------
  # Freevo - A Home Theater PC framework
***************
*** 79,82 ****
--- 42,46 ----
  import traceback
  import re
+ import codecs
  
  import util
***************
*** 85,89 ****
  import copy
  import rc
- import string
  import skin
  
--- 49,52 ----
***************
*** 147,155 ****
          self.mountpoint   = None
          self.add_args     = add_args
!         
          # set directory variables to default
          global all_variables
          for v in all_variables:
              setattr(self, v, eval('config.%s' % v))
  
          if name:
--- 110,119 ----
          self.mountpoint   = None
          self.add_args     = add_args
! 
          # set directory variables to default
          global all_variables
          for v in all_variables:
              setattr(self, v, eval('config.%s' % v))
+         self.modified_vars = []
  
          if name:
***************
*** 163,166 ****
--- 127,142 ----
              self.name = os.path.basename(directory)
  
+         
+         # check for image in album.xml
+         if os.path.isfile(directory + '/album.xml'):
+             try:
+                 image = bins.get_bins_desc(directory)['desc']['sampleimage']
+                 image = os.path.join(directory, image)
+                 if os.path.isfile(image):
+                     self.image = image
+                     self.handle_type = self.display_type
+             except:
+                 pass
+ 
          # Check for cover in COVER_DIR
          if config.COVER_DIR:
***************
*** 250,256 ****
        <?xml version="1.0" ?>
        <freevo>
!         <folder title="Incoming TV Shows" cover-img="taken.jpg">
            <setvar name="directory_autoplay_single_item" val="0"/>
-           <!-- <setvar name="force_skin_layout" val="1"/> -->
            <info>
              <content>Episodes for current tv shows not seen yet</content>
--- 226,231 ----
        <?xml version="1.0" ?>
        <freevo>
!         <folder title="Incoming TV Shows" cover-img="foo.jpg">
            <setvar name="directory_autoplay_single_item" val="0"/>
            <info>
              <content>Episodes for current tv shows not seen yet</content>
***************
*** 300,303 ****
--- 275,279 ----
                          except ValueError:
                              setattr(self, v, child.attrs[('', 'val')])
+                         self.modified_vars.append(v)
              # get more info
              if child.name == 'info' and set_all:
***************
*** 308,311 ****
--- 284,321 ----
  
          
+     def write_fxd(self):
+         """
+         save the modified fxd file
+         """
+         self.xml_file = os.path.join(self.dir, 'folder.fxd')
+         try:
+             f = open(self.xml_file)
+             data = f.readlines()
+             f.close()
+         except:
+             data = ('<?xml version="1.0" ?>\n', '<freevo>\n', '  <folder>\n',
+                     '  </folder>\n', '</freevo>\n')
+         
+         try:
+             if os.path.isfile(self.xml_file):
+                 os.unlink(self.xml_file)
+             f = codecs.open(self.xml_file , 'w', encoding='utf-8')
+         except IOError, error:
+             return 0 
+ 
+         for line in data:
+             if line.find('<setvar') != -1:
+                 continue
+             f.write(line)
+             if line.find('<folder') != -1:
+                 for v in self.modified_vars:
+                     for i in range(line.find('<')):
+                         f.write(' '),
+                     f.write('  <setvar name="%s" val="%s"/>\n' % \
+                             (v.lower(), getattr(self, v)))
+         f.close()
+         return 1 
+ 
+ 
      def copy(self, obj):
          """
***************
*** 346,356 ****
          items = [ ( self.cwd, _('Browse directory') ) ]
  
-         # this doen't work right now because we have no playlist
-         # at this point :-(
-         
-         # if self.playlist and len(self.playlist) > 1:
-         #     items += [ (RandomPlaylist(self.playlist, self),
-         #                 _('Random play all items') ) ]
- 
          if ((not self.display_type or self.display_type == 'audio') and
              config.AUDIO_RANDOM_PLAYLIST == 1):
--- 356,359 ----
***************
*** 358,361 ****
--- 361,365 ----
                                         self),
                          _('Recursive random play all items')) ]
+         items.append((self.configure, _('Configure directory'), 'configure'))
          return items
      
***************
*** 371,375 ****
          # are we on a ROM_DRIVE and have to mount it first?
          for media in config.REMOVABLE_MEDIA:
!             if string.find(self.dir, media.mountdir) == 0:
                  util.mount(self.dir)
                  self.media = media
--- 375,379 ----
          # are we on a ROM_DRIVE and have to mount it first?
          for media in config.REMOVABLE_MEDIA:
!             if self.dir.find(media.mountdir) == 0:
                  util.mount(self.dir)
                  self.media = media
***************
*** 457,461 ****
              mmpython.cache_dir(mmpython_dir, callback=callback)
              if self.media:
!                 self.media.cached = TRUE
  
          play_items = []
--- 461,465 ----
              mmpython.cache_dir(mmpython_dir, callback=callback)
              if self.media:
!                 self.media.cached = True
  
          play_items = []
***************
*** 510,514 ****
              for file in util.find_matches(files, config.SUFFIX_IMAGE_SSHOW):
                  pl = Playlist(file, self)
!                 pl.autoplay = TRUE
                  pl_items += [ pl ]
  
--- 514,518 ----
              for file in util.find_matches(files, config.SUFFIX_IMAGE_SSHOW):
                  pl = Playlist(file, self)
!                 pl.autoplay = True
                  pl_items += [ pl ]
  
***************
*** 525,529 ****
              pl = Playlist(play_items, self)
              pl.randomize()
!             pl.autoplay = TRUE
              items += [ pl ]
  
--- 529,533 ----
              pl = Playlist(play_items, self)
              pl.randomize()
!             pl.autoplay = True
              items += [ pl ]
  
***************
*** 667,671 ****
              for file in util.find_matches(new_files, config.SUFFIX_IMAGE_SSHOW):
                  pl = Playlist(file, self)
!                 pl.autoplay = TRUE
                  new_pl_items += [ pl ]
  
--- 671,675 ----
              for file in util.find_matches(new_files, config.SUFFIX_IMAGE_SSHOW):
                  pl = Playlist(file, self)
!                 pl.autoplay = True
                  new_pl_items += [ pl ]
  
***************
*** 687,691 ****
                  pl = Playlist(self.play_items, self)
                  pl.randomize()
!                 pl.autoplay = TRUE
                  items += [ pl ]
  
--- 691,695 ----
                  pl = Playlist(self.play_items, self)
                  pl.randomize()
!                 pl.autoplay = True
                  items += [ pl ]
  
***************
*** 716,719 ****
--- 720,818 ----
  
  
+     def configure_set_var(self, arg=None, menuw=None):
+         """
+         Update the variable in arg and change the menu. This function is used by
+         'configure'
+         """
+ 
+         # get current value, None == no special settings
+         if arg in self.modified_vars:
+             current = getattr(self, arg)
+         else:
+             current = None
+ 
+         # get the max value for toggle
+         max = 1
+ 
+         # for FORCE_SKIN_LAYOUT max = number of styles in the menu
+         if arg == 'FORCE_SKIN_LAYOUT':
+             if self.display_type and skin.settings.menu.has_key(self.display_type):
+                 area = skin.settings.menu[self.display_type]
+             else:
+                 area = skin.settings.menu['default']
+             max = len(area.style) - 1
+ 
+         # switch from no settings to 0
+         if current == None:
+             self.modified_vars.append(arg)
+             setattr(self, arg, 0)
+ 
+         # inc variable
+         elif current < max:
+             setattr(self, arg, current+1)
+ 
+         # back to no special settings
+         elif current == max:
+             setattr(self, arg, getattr(config, arg))
+             self.modified_vars.remove(arg)
+ 
+         # create new item with updated name
+         item = copy.copy(menuw.menustack[-1].selected)
+         item.name = item.name[:item.name.find('\t') + 1]
+         if arg in self.modified_vars:
+             if arg == 'FORCE_SKIN_LAYOUT':
+                 item.name += str(getattr(self, arg))
+             elif getattr(self, arg):
+                 item.name += 'on'
+             else:
+                 item.name += 'off'
+         else:
+             if arg == 'FORCE_SKIN_LAYOUT':
+                 item.name += 'off'
+             else:
+                 item.name += 'auto'
+ 
+         # write folder.fxd
+         if not self.write_fxd():
+             print 'error writing file'
+ 
+         # rebuild menu
+         menuw.menustack[-1].choices[menuw.menustack[-1].choices.\
+                                     index(menuw.menustack[-1].selected)] = item
+         menuw.menustack[-1].selected = item
+         menuw.refresh(reload=1)
+             
+     
+     def configure(self, arg=None, menuw=None):
+         """
+         show the configure dialog for folder specific settings in folder.fxd
+         """
+         items = []
+         for i in all_variables:
+             if i in ('COVER_DIR', 'AUDIO_FORMAT_STRING'):
+                 continue
+             if (self.display_type and not self.display_type == 'audio') and \
+                    i == 'AUDIO_RANDOM_PLAYLIST':
+                 continue
+             
+             name = str(i + '\t').replace('_', ' ').capitalize()
+             if i in self.modified_vars:
+                 if i == 'FORCE_SKIN_LAYOUT':
+                     item.name += str(getattr(self, i))
+                 if getattr(self, i):
+                     name += 'on'
+                 else:
+                     name += 'off'
+             else:
+                 if i == 'FORCE_SKIN_LAYOUT':
+                     name += 'off'
+                 else:
+                     name += 'auto'
+             items.append(menu_module.MenuItem(name, self.configure_set_var, i))
+         m = menu_module.Menu('Configure', items)
+         m.table = (80, 20)
+         menuw.pushmenu(m)
+ 
+         
      # eventhandler for this item
      def eventhandler(self, event, menuw=None):




-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to