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

Modified Files:
        directory.py item.py main.py menu.py osd.py playlist.py 
        plugin.py rc.py 
Log Message:
Added new event handler module


Index: directory.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/directory.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** directory.py        11 May 2003 18:08:06 -0000      1.10
--- directory.py        27 May 2003 17:53:33 -0000      1.11
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.11  2003/05/27 17:53:33  dischi
+ # Added new event handler module
+ #
  # Revision 1.10  2003/05/11 18:08:06  dischi
  # added AUDIO_FORMAT_STRING to format the audio items
***************
*** 569,573 ****
          # reload the menu, use an event to avoid problems because this function
          # was called by a thread
!         rc.post_event(rc.REBUILD_SCREEN)
  
  
--- 572,576 ----
          # reload the menu, use an event to avoid problems because this function
          # was called by a thread
!         rc.post_event('REBUILD_SCREEN')
  
  
***************
*** 611,615 ****
  
              # send EXIT to go one menu up:
!             rc.post_event(rc.EXIT)
              self.lock.release()
              return
--- 614,618 ----
  
              # send EXIT to go one menu up:
!             rc.post_event(em.MENU_BACK_ONE_MENU)
              self.lock.release()
              return

Index: item.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/item.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** item.py     24 Apr 2003 19:55:46 -0000      1.14
--- item.py     27 May 2003 17:53:33 -0000      1.15
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.15  2003/05/27 17:53:33  dischi
+ # Added new event handler module
+ #
  # Revision 1.14  2003/04/24 19:55:46  dischi
  # comment cleanup for 1.3.2-pre4
***************
*** 59,63 ****
  
  
! import rc
  
  TRUE  = 1
--- 62,66 ----
  
  
! import event as em
  
  TRUE  = 1
***************
*** 159,163 ****
  
          else:
!             if event == rc.PLAY_END or event == rc.USER_END and menuw:
                  if menuw.visible:
                      menuw.refresh()
--- 162,166 ----
  
          else:
!             if event == em.PLAY_END or event == em.USER_END and menuw:
                  if menuw.visible:
                      menuw.refresh()

Index: main.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/main.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** main.py     27 Apr 2003 17:59:06 -0000      1.42
--- main.py     27 May 2003 17:53:33 -0000      1.43
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.43  2003/05/27 17:53:33  dischi
+ # Added new event handler module
+ #
  # Revision 1.42  2003/04/27 17:59:06  dischi
  # better plugin poll() handling
***************
*** 85,88 ****
--- 88,92 ----
  
  from item import Item
+ import event as em
  
  
***************
*** 219,223 ****
          # pressing DISPLAY on the main menu will open a skin selector
          # (only for the new skin code)
!         if event == rc.DISPLAY:
              items = []
              for name, image, skinfile in skin.GetSkins():
--- 223,227 ----
          # pressing DISPLAY on the main menu will open a skin selector
          # (only for the new skin code)
!         if event == em.MENU_CHANGE_STYLE:
              items = []
              for name, image, skinfile in skin.GetSkins():
***************
*** 269,275 ****
          while 1:
  
-             event = osd._cb()
-             if event:
-                 break
              event = rc_object.poll()
              if event:
--- 273,276 ----
***************
*** 300,304 ****
                          break
                  else:
!                     print 'no eventhandler for event %s' % event
  
          else:
--- 301,305 ----
                          break
                  else:
!                     print 'no eventhandler for event %s' % event.name
  
          else:

Index: menu.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/menu.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -d -r1.46 -r1.47
*** menu.py     28 Apr 2003 18:07:45 -0000      1.46
--- menu.py     27 May 2003 17:53:33 -0000      1.47
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.47  2003/05/27 17:53:33  dischi
+ # Added new event handler module
+ #
  # Revision 1.46  2003/04/28 18:07:45  dischi
  # restore the correct item
***************
*** 77,83 ****
  import skin
  
! # The RemoteControl class, sets up a UDP daemon that the remote control client
! # sends commands to
! import rc
  
  from gui.GUIObject import *
--- 80,84 ----
  import skin
  
! import event as em
  
  from gui.GUIObject import *
***************
*** 210,214 ****
          self.visible = 1
          self.eventhandler_plugins = None
! 
      def show(self):
          if not self.visible:
--- 211,216 ----
          self.visible = 1
          self.eventhandler_plugins = None
!         self.event_context = 'menu'
!         
      def show(self):
          if not self.visible:
***************
*** 360,368 ****
          menu = self.menustack[-1]
  
!         if event == rc.MENU:
              self.goto_main_menu()
              return
          
!         if event == rc.EXIT:
              self.back_one_menu()
              return
--- 362,370 ----
          menu = self.menustack[-1]
  
!         if event == em.MENU_GOTO_MAINMENU:
              self.goto_main_menu()
              return
          
!         if event == em.MENU_BACK_ONE_MENU:
              self.back_one_menu()
              return
***************
*** 371,379 ****
              return
  
!         if event == rc.REFRESH_SCREEN:
              self.refresh()
              return
          
!         if event == rc.REBUILD_SCREEN:
              self.init_page()
              self.refresh()
--- 373,381 ----
              return
  
!         if event == 'MENU_REFRESH':
              self.refresh()
              return
          
!         if event == 'MENU_REBUILD':
              self.init_page()
              self.refresh()
***************
*** 381,385 ****
          
          if not self.menu_items:
!             if event in ( rc.ENTER, rc.SELECT,event == rc.PLAY):
                  self.back_one_menu()
              return
--- 383,387 ----
          
          if not self.menu_items:
!             if event in ( em.MENU_SELECT, em.MENU_SUBMENU, em.MENU_PLAY_ITEM):
                  self.back_one_menu()
              return
***************
*** 396,400 ****
              return
  
!         if event == rc.UP:
              curr_selected = self.all_items.index(menu.selected)
              if curr_selected-self.cols < 0 and \
--- 398,402 ----
              return
  
!         if event == em.MENU_UP:
              curr_selected = self.all_items.index(menu.selected)
              if curr_selected-self.cols < 0 and \
***************
*** 416,420 ****
  
  
!         elif event == rc.DOWN:
              curr_selected = self.all_items.index(menu.selected)
              if curr_selected+self.cols > len(self.all_items)-1 and \
--- 418,422 ----
  
  
!         elif event == em.MENU_DOWN:
              curr_selected = self.all_items.index(menu.selected)
              if curr_selected+self.cols > len(self.all_items)-1 and \
***************
*** 437,446 ****
  
  
!         elif event == rc.LEFT or event == rc.CHUP:
              # Do nothing for an empty file list
              if not len(self.menu_items):
                  return
              
!             if event == rc.LEFT and self.cols > 1:
                  curr_selected = self.all_items.index(menu.selected)
                  if curr_selected == 0:
--- 439,448 ----
  
  
!         elif event == em.MENU_LEFT or event == em.MENU_PAGEUP:
              # Do nothing for an empty file list
              if not len(self.menu_items):
                  return
              
!             if event == em.MENU_LEFT and self.cols > 1:
                  curr_selected = self.all_items.index(menu.selected)
                  if curr_selected == 0:
***************
*** 469,473 ****
              return
  
!         elif event == rc.RIGHT or event == rc.CHDOWN:
              # Do nothing for an empty file list
              if not len(self.menu_items):
--- 471,475 ----
              return
  
!         elif event == em.MENU_RIGHT or event == em.MENU_PAGEDOWN:
              # Do nothing for an empty file list
              if not len(self.menu_items):
***************
*** 477,481 ****
                  return
              
!             if event == rc.RIGHT and self.cols > 1:
                  curr_selected = self.all_items.index(menu.selected)
                  if curr_selected == len(self.all_items)-1:
--- 479,483 ----
                  return
              
!             if event == em.MENU_RIGHT and self.cols > 1:
                  curr_selected = self.all_items.index(menu.selected)
                  if curr_selected == len(self.all_items)-1:
***************
*** 507,511 ****
  
  
!         elif event == rc.SELECT or event == rc.PLAY:
              try:
                  action = menu.selected.action
--- 509,516 ----
  
  
!         elif event == em.MENU_PLAY_ITEM and hasattr(menu.selected, 'play'):
!             menu.selected.play(menuw=self)
!             
!         elif event == em.MENU_SELECT or event == em.MENU_PLAY_ITEM:
              try:
                  action = menu.selected.action
***************
*** 524,528 ****
  
  
!         elif event == rc.ENTER:
              actions = menu.selected.actions()
  
--- 529,533 ----
  
  
!         elif event == em.MENU_SUBMENU:
              actions = menu.selected.actions()
  
***************
*** 543,547 ****
              
  
!         elif event == rc.DISPLAY and len(self.menustack) > 1:
              # did the menu change?
              if skin.ToggleDisplayStyle(menu):
--- 548,552 ----
              
  
!         elif event == em.MENU_CHANGE_STYLE and len(self.menustack) > 1:
              # did the menu change?
              if skin.ToggleDisplayStyle(menu):
***************
*** 562,566 ****
                  return
  
!         print 'no eventhandler for event %s' % event
          return 0
  
--- 567,571 ----
                  return
  
!         print 'no eventhandler for event %s' % event.name
          return 0
  

Index: osd.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/osd.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** osd.py      6 May 2003 10:36:46 -0000       1.39
--- osd.py      27 May 2003 17:53:33 -0000      1.40
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.40  2003/05/27 17:53:33  dischi
+ # Added new event handler module
+ #
  # Revision 1.39  2003/05/06 10:36:46  dischi
  # Added OSD_SDL_EXEC_AFTER_CLOSE patch from Petri Damstén
***************
*** 364,368 ****
                      if self._help:
                          self._helpscreen()
- 
                      return cmds_sdl[event.key]
  
--- 367,370 ----

Index: playlist.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/playlist.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** playlist.py 11 May 2003 17:44:13 -0000      1.19
--- playlist.py 27 May 2003 17:53:33 -0000      1.20
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.20  2003/05/27 17:53:33  dischi
+ # Added new event handler module
+ #
  # Revision 1.19  2003/05/11 17:44:13  dischi
  # load playlist only when really needed
***************
*** 78,81 ****
--- 81,85 ----
  import util
  import config
+ import event as em
  
  from item import Item
***************
*** 90,95 ****
  from image import ImageItem
  
- import rc
- 
  TRUE  = 1
  FALSE = 0
--- 94,97 ----
***************
*** 231,235 ****
          Read the playlist from file and create the items
          """
!         if self.filename and not self.playlist:
              f=open(self.filename, "r")
              line = f.readline()
--- 233,237 ----
          Read the playlist from file and create the items
          """
!         if hasattr(self, 'filename') and self.filename and not self.playlist:
              f=open(self.filename, "r")
              line = f.readline()
***************
*** 322,327 ****
              menuw = self.menuw
              
!         if (event == rc.DOWN or event == rc.PLAY_END or event == rc.USER_END) \
!            and self.current_item and self.playlist:
              pos = self.playlist.index(self.current_item)
              pos = (pos+1) % len(self.playlist)
--- 324,329 ----
              menuw = self.menuw
              
!         if event in ( em.PLAYLIST_NEXT, em.PLAY_END, em.USER_END) \
!                and self.current_item and self.playlist:
              pos = self.playlist.index(self.current_item)
              pos = (pos+1) % len(self.playlist)
***************
*** 335,339 ****
  
          # end and no next item
!         if event in (rc.PLAY_END, rc.USER_END, rc.EXIT, rc.STOP):
              self.current_item = None
              if menuw:
--- 337,341 ----
  
          # end and no next item
!         if event in (em.PLAY_END, em.USER_END, em.STOP):
              self.current_item = None
              if menuw:
***************
*** 342,346 ****
              
  
!         if event == rc.UP and self.current_item and self.playlist:
              pos = self.playlist.index(self.current_item)
              if pos:
--- 344,348 ----
              
  
!         if event == em.PLAYLIST_PREV and self.current_item and self.playlist:
              pos = self.playlist.index(self.current_item)
              if pos:
***************
*** 421,425 ****
              menuw = self.menuw
  
!         if (event == rc.DOWN or event == rc.PLAY_END) and self.unplayed:
              if self.current_item:
                  self.current_item.parent = self.parent
--- 423,427 ----
              menuw = self.menuw
  
!         if (event == em.PLAYLIST_NEXT or event == em.PLAY_END) and self.unplayed:
              if self.current_item:
                  self.current_item.parent = self.parent
***************
*** 429,433 ****
          
          # end and no next item
!         if event == rc.PLAY_END:
              if self.current_item:
                  self.current_item.parent = self.parent
--- 431,435 ----
          
          # end and no next item
!         if event == em.PLAY_END:
              if self.current_item:
                  self.current_item.parent = self.parent
***************
*** 437,441 ****
              return TRUE
              
!         if event == rc.UP:
              print 'random playlist up: not implemented yet'
  
--- 439,443 ----
              return TRUE
              
!         if event == em.PLAYLIST_PREV:
              print 'random playlist up: not implemented yet'
  

Index: plugin.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/plugin.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** plugin.py   27 Apr 2003 17:59:07 -0000      1.18
--- plugin.py   27 May 2003 17:53:33 -0000      1.19
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.19  2003/05/27 17:53:33  dischi
+ # Added new event handler module
+ #
  # Revision 1.18  2003/04/27 17:59:07  dischi
  # better plugin poll() handling
***************
*** 78,81 ****
--- 81,85 ----
  import os
  import traceback
+ from event import Event
  
  TRUE  = 1
***************
*** 338,342 ****
      create plugin event
      """
!     return 'PLUGIN_EVENT %s' % name
  
  
--- 342,346 ----
      create plugin event
      """
!     return Event('PLUGIN_EVENT %s' % name)
  
  
***************
*** 345,350 ****
      plugin event parsing
      """
!     if event[:12] == 'PLUGIN_EVENT':
!         return event[13:]
      else:
          return None
--- 349,354 ----
      plugin event parsing
      """
!     if event.name[:12] == 'PLUGIN_EVENT':
!         return event.name[13:]
      else:
          return None

Index: rc.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/rc.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** rc.py       27 Apr 2003 17:43:30 -0000      1.14
--- rc.py       27 May 2003 17:53:33 -0000      1.15
***************
*** 10,13 ****
--- 10,16 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.15  2003/05/27 17:53:33  dischi
+ # Added new event handler module
+ #
  # Revision 1.14  2003/04/27 17:43:30  dischi
  # secure RemoteControl against different threads
***************
*** 71,74 ****
--- 74,81 ----
  import config
  import util
+ from event import Event, BUTTON
+ import osd
+ 
+ osd = osd.get_singleton()
  
  PYLIRC = 1
***************
*** 102,179 ****
      return get_singleton().post_event(event)
  
! def app(application=0, func=None):
      if not application == 0:
!         if hasattr(application, 'app_mode') and not func:
!             func = application.app_mode
          if hasattr(application, 'eventhandler'):
              application = application.eventhandler
!         get_singleton().app = application
!         get_singleton().func = func
!         
!     return get_singleton().app
! 
! 
! # Remote control buttons. This is taken from a universal remote
! # that has a large (but not ridiculous) number of buttons.
! # Try to use a common subset for the common operations, and
! # don't add buttons that only exist on a specific remote since
! # no-one else will be able to use it.
! 
! NONE     = ''
! SLEEP    = 'SLEEP'
! MENU     = 'MENU'
! GUIDE    = 'GUIDE'
! EXIT     = 'EXIT'
! UP       = 'UP'
! DOWN     = 'DOWN'
! LEFT     = 'LEFT'
! RIGHT    = 'RIGHT'
! SELECT   = 'SELECT'
! POWER    = 'POWER'
! MUTE     = 'MUTE'
! VOLUP    = 'VOL+'
! VOLDOWN  = 'VOL-'
! CHUP     = 'CH+'
! CHDOWN   = 'CH-'
! K1       = '1'
! K2       = '2'
! K3       = '3'
! K4       = '4'
! K5       = '5'
! K6       = '6'
! K7       = '7'
! K8       = '8'
! K9       = '9'
! K0       = '0'
! DISPLAY  = 'DISPLAY'
! ENTER    = 'ENTER'
! PREV_CH  = 'PREV_CH'
! PIP_ONOFF= 'PIP_ONOFF'
! PIP_SWAP = 'PIP_SWAP'
! PIP_MOVE = 'PIP_MOVE'
! TV_VCR   = 'TV_VCR'
! REW      = 'REW'
! PLAY     = 'PLAY'
! FFWD     = 'FFWD'
! PAUSE    = 'PAUSE'
! STOP     = 'STOP'
! REC      = 'REC'      
! EJECT    = 'EJECT'
! SUBTITLE = 'SUBTITLE'
  
! # Application generated codes
! PLAY_END = 'PLAY_END'     # Reached end of song, movie, etc
! USER_END = 'USER_END'     # User ended the song, etc
  
! REFRESH_SCREEN = 'REFRESH_SCREEN'
! REBUILD_SCREEN = 'REBUILD_SCREEN'
! DVD_PROTECTED  = 'DVD_PROTECTED' # Cannot play prot. DVDs
  
  
  class RemoteControl:
  
      def __init__(self, port=config.REMOTE_CONTROL_PORT):
          self.pylirc = PYLIRC
-         
          if self.pylirc:
              try:
--- 109,133 ----
      return get_singleton().post_event(event)
  
! 
! def app(application=0):
      if not application == 0:
!         context = 'menu'
!         if hasattr(application, 'app_mode'):
!             context = application.app_mode
          if hasattr(application, 'eventhandler'):
              application = application.eventhandler
!         get_singleton().set_app(application, context)
  
!     return get_singleton().get_app()
  
! def set_context(context):
!     get_singleton().set_context(context)
  
  
+     
  class RemoteControl:
  
      def __init__(self, port=config.REMOTE_CONTROL_PORT):
          self.pylirc = PYLIRC
          if self.pylirc:
              try:
***************
*** 194,203 ****
  
          self.app = None
!         self.func = None
          self.queue = []
          
!     def post_event(self, event):
!         self.queue += [event]
  
          
      def poll(self):
--- 148,188 ----
  
          self.app = None
!         self.context = 'menu'
          self.queue = []
+ 
+ 
+     def set_app(self, app, context):
+         self.app     = app
+         self.context = context
+ 
+ 
+     def get_app(self):
+         return self.app
+ 
+ 
+     def set_context(self, context):
+         self.context = context
          
!     def post_event(self, e):
!         if not isinstance(e, Event):
!             self.queue += [ Event(e, context=self.context) ]
!         self.queue += [ e ]
! 
!     def key_event_mapper(self, key):
!         if not key:
!             return None
! 
!         for c in (self.context, 'global'):
!             try:
!                 e = config.EVENTS[c][key]
!                 e.context = self.context
!                 return e
!             except KeyError:
!                 pass
  
+         print 'no event mapping for key %s in context %s' % (key, self.context)
+         print 'send button event BUTTON arg=%s' % key
+         return Event(BUTTON, arg=key)
+     
          
      def poll(self):
***************
*** 206,215 ****
              del self.queue[0]
              return ret
          if self.pylirc:
              list = pylirc.nextcode()
              if list:
                  for code in list:
!                     data = code
!                     return data
          if config.ENABLE_NETWORK_REMOTE:
              try:
--- 191,207 ----
              del self.queue[0]
              return ret
+ 
+         e = self.key_event_mapper(osd._cb())
+         if e:
+             return e
+         
          if self.pylirc:
              list = pylirc.nextcode()
              if list:
                  for code in list:
!                     e = self.key_event_mapper(osd._cb())
!                     if e:
!                         return e
!                 
          if config.ENABLE_NETWORK_REMOTE:
              try:




-------------------------------------------------------
This SF.net email is sponsored by: ObjectStore.
If flattening out C++ or Java code to make your application fit in a
relational database is painful, don't do it! Check out ObjectStore.
Now part of Progress Software. http://www.objectstore.net/sourceforge
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to