Author: dmeyer
Date: Thu Mar 29 17:09:39 2007
New Revision: 9418
Modified:
trunk/ui/src/application/handler.py
trunk/ui/src/menu/menu.py
trunk/ui/src/menu/stack.py
Log:
block event handling for InProgress objects
Modified: trunk/ui/src/application/handler.py
==============================================================================
--- trunk/ui/src/application/handler.py (original)
+++ trunk/ui/src/application/handler.py Thu Mar 29 17:09:39 2007
@@ -39,7 +39,6 @@
# python imports
import sys
-import time
import logging
# kaa imports
@@ -52,9 +51,6 @@
# the logging object
log = logging.getLogger()
-# debug stuff
-_TIME_DEBUG = False
-
# the global object
handler = None
@@ -188,40 +184,38 @@
Event handling function.
"""
log.debug('handling event %s' % str(event))
- if _TIME_DEBUG:
- t1 = time.clock()
-
- try:
- if event == TOGGLE_APPLICATION and len(self.applications) > 1 and \
- self.applications[-1].has_capability(CAPABILITY_TOGGLE):
- log.info('Toggle application')
- self.applications.insert(0, self.applications.pop())
- self.set_focus()
-
- elif event.handler:
- # event has it's own handler function, call this
- # function and do not pass it on the the normal
- # handling.
- event.handler(event=event)
-
- elif len(self.windows) and
self.windows[-1].eventhandler(event=event):
- # handled by the current popup
- pass
-
- else:
- # handle by the current appliaction
- self.applications[-1].eventhandler(event=event)
- if _TIME_DEBUG:
- print time.clock() - t1
+ if event == TOGGLE_APPLICATION and len(self.applications) > 1 and \
+ self.applications[-1].has_capability(CAPABILITY_TOGGLE):
+ log.info('Toggle application')
+ self.applications.insert(0, self.applications.pop())
+ self.set_focus()
return True
- except (SystemExit, KeyboardInterrupt):
- sys.exit(0)
+ result = None
- except Exception, e:
- log.exception('application.handler')
- sys.exit(1)
+ if event.handler:
+ # event has it's own handler function, call this
+ # function and do not pass it on the the normal
+ # handling.
+ result = event.handler(event=event) or True
+
+ if not result and len(self.windows):
+ # maybe handled by the current popup
+ result = self.windows[-1].eventhandler(event=event)
+
+ if not result:
+ # handle by the current application
+ result = self.applications[-1].eventhandler(event=event)
+
+ # This function has to return True or it will be deleted from
+ # the kaa.notifier eventhandler. The kaa.notifier event code
+ # is not aware of InProgress objects so if result is an InProgress
+ # object we wait here using step(). This is ugly and needs to be
+ # fixed.
+ if isinstance(result, kaa.notifier.InProgress):
+ while not result.is_finished:
+ kaa.notifier.step()
# create the global object
handler = Handler()
Modified: trunk/ui/src/menu/menu.py
==============================================================================
--- trunk/ui/src/menu/menu.py (original)
+++ trunk/ui/src/menu/menu.py Thu Mar 29 17:09:39 2007
@@ -186,7 +186,12 @@
if not actions:
OSD_MESSAGE.post(_('No action defined for this choice!'))
else:
- actions[0]()
+ result = actions[0]()
+ if result:
+ # action handed this event and returned either True or
+ # an InProgress object
+ return result
+ # in any case, return True because this event is handled here
return True
if event == MENU_SUBMENU:
@@ -219,8 +224,7 @@
log.info('calling action %s' % event.arg)
for action in self.selected.get_actions():
if action.shortcut == event.arg:
- action()
- return True
+ return action() or True
log.info('action %s not found' % event.arg)
return True
Modified: trunk/ui/src/menu/stack.py
==============================================================================
--- trunk/ui/src/menu/stack.py (original)
+++ trunk/ui/src/menu/stack.py Thu Mar 29 17:09:39 2007
@@ -177,9 +177,12 @@
"""
menu = self.menustack[-1]
- if menu.eventhandler(event):
+ result = menu.eventhandler(event)
+ if result:
+ # menu handed this event and returned either True or
+ # an InProgress object
self.refresh()
- return True
+ return result
if event == MENU_GOTO_MAINMENU:
while len(self.menustack) > 1:
@@ -217,11 +220,12 @@
self.back_one_menu()
return True
selected = getattr(self.menustack[-2], 'selected', None)
- if selected and selected.eventhandler(event):
- return True
+ if selected:
+ return selected.eventhandler(event)
return False
- if menu.selected and menu.selected.eventhandler(event):
- return True
+ # pass to selected eventhandler
+ if menu.selected:
+ return menu.selected.eventhandler(event)
return False
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog