Mercurial > enso_core
changeset 50:51181fe08fea
The event manager is now passed-in to primary and mini-message implementations, which decouples the enso.ui.messages package from ui.events.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 25 Feb 2008 12:39:19 -0600 |
parents | 7cb24dbb8c91 |
children | 525fb0abcb4d |
files | enso/ui/__init__.py enso/ui/messages/__init__.py enso/ui/messages/miniwindows.py enso/ui/messages/primarywindow.py |
diffstat | 4 files changed, 34 insertions(+), 37 deletions(-) [+] |
line wrap: on
line diff
--- a/enso/ui/__init__.py Mon Feb 25 12:22:47 2008 -0600 +++ b/enso/ui/__init__.py Mon Feb 25 12:39:19 2008 -0600 @@ -114,7 +114,7 @@ events.init( enso.config.QUASIMODE_KEYCODE ) commands.init() - messages.init() + messages.init( events.eventManager ) quasimode.init() _isUserInterfaceInited = True
--- a/enso/ui/messages/__init__.py Mon Feb 25 12:22:47 2008 -0600 +++ b/enso/ui/messages/__init__.py Mon Feb 25 12:39:19 2008 -0600 @@ -276,22 +276,21 @@ Singleton class for managing the various forms of messages Enso uses. """ - # These are set to None so that the module initialization can - # choose between a "real" window class for the application, - # and a "false" window class for testing purposes. - - # The class that will be used to display primary messages. - primaryMsgWindClass = None - - # The class that will be used to display mini messages. - miniMsgWindClass = None - - def __init__( self ): + def __init__( self, eventManager, primaryMsgWindClass, + miniMsgWindClass ): """ Instantiates the message manager and any windows used to display messages. """ + self.__evtManager = eventManager + + # The class that will be used to display primary messages. + self.__primaryMsgWindClass = primaryMsgWindClass + + # The class that will be used to display mini messages. + self.__miniMsgWindClass = miniMsgWindClass + # The singleton primary message object. This saves # a reference to the Message that is being displayed # as the primary message for as long as it is displayed. @@ -300,8 +299,10 @@ # The window that will display primary messages. self.__primaryMsgWind = None # The window that will display mini messages. - self.__miniMessageWind = self.miniMsgWindClass( self ) - + self.__miniMessageWind = self.__miniMsgWindClass( + self, + self.__evtManager + ) def newMessage( self, msg ): """ @@ -324,7 +325,6 @@ fade-out animation). """ - # The following message may be used by system tests. logging.info( "Primary message dismissed." ) oldMsg = self.__primaryMessage @@ -378,7 +378,10 @@ """ if not self.__primaryMsgWind: - self.__primaryMsgWind = self.primaryMsgWindClass( self ) + self.__primaryMsgWind = self.__primaryMsgWindClass( + self, + self.__evtManager + ) oldMsg = self.__primaryMessage if oldMsg != None: @@ -421,21 +424,19 @@ messageManager = None -def init( primaryMsgWindClass = None, +def init( eventManager, + primaryMsgWindClass = None, miniMsgWindClass = None ): """ Initializes the message manager. + eventManager is an event manager instance. + If primaryMsgWindClass is supplied, uses that class instead of the - standard class for displaying primary messages. (This is - primarily for testing purposes). This class should implement a - setMessage(msg) method, and may call the message manager's - onDismissal() method. + standard class for displaying primary messages. If miniMsgWindClass is supplied, uses that class instead of the - standard class for displaying mini messages. (This is primarily - for testing purposes). This class should implement a - newMessage(msg) method. + standard class for displaying mini messages. """ global messageManager @@ -443,18 +444,16 @@ if primaryMsgWindClass == None: from enso.ui.messages import primarywindow - _TheMessageManager.primaryMsgWindClass = primarywindow.PrimaryMsgWind - else: - _TheMessageManager.primaryMsgWindClass = primaryMsgWindClass + primaryMsgWindClass = primarywindow.PrimaryMsgWind if miniMsgWindClass == None: from enso.ui.messages import miniwindows - _TheMessageManager.miniMsgWindClass = miniwindows.MiniMessageQueue - else: - _TheMessageManager.miniMsgWindClass = miniMsgWindClass + miniMsgWindClass = miniwindows.MiniMessageQueue - messageManager = _TheMessageManager() + messageManager = _TheMessageManager( eventManager, + primaryMsgWindClass, + miniMsgWindClass ) def isInitialized():
--- a/enso/ui/messages/miniwindows.py Mon Feb 25 12:22:47 2008 -0600 +++ b/enso/ui/messages/miniwindows.py Mon Feb 25 12:39:19 2008 -0600 @@ -48,7 +48,6 @@ from enso import graphics from enso.graphics.measurement import pointsToPixels, pixelsToPoints from enso.ui.graphics import UPPER_LEFT, drawRoundedRect -from enso.ui import events from enso.ui.messages.windows import MessageWindow, computeWidth from enso.ui.messages.primarywindow import layoutMessageXml from enso.ui.messages import Message @@ -82,8 +81,8 @@ APPEARING = 2 VANISHING = 3 - def __init__( self, msgMan ): - self.__evtManager = events.eventManager + def __init__( self, msgMan, eventManager ): + self.__evtManager = eventManager self.__msgManager = msgMan self.__newMessages = [] self.__visibleMessages = []
--- a/enso/ui/messages/primarywindow.py Mon Feb 25 12:22:47 2008 -0600 +++ b/enso/ui/messages/primarywindow.py Mon Feb 25 12:39:19 2008 -0600 @@ -47,7 +47,6 @@ from enso.graphics.measurement import inchesToPoints from enso.ui.graphics import drawRoundedRect, ALL_CORNERS from enso.utils.xml_tools import escapeXml -from enso.ui import events from enso.ui.messages.windows import MessageWindow, computeWidth @@ -110,7 +109,7 @@ message has been dismissed. """ - def __init__( self, msgMan ): + def __init__( self, msgMan, eventManager ): """ Initializes the PrimaryMessage singleton """ @@ -126,7 +125,7 @@ maxSize = ( width, height ) MessageWindow.__init__( self, maxSize ) - self.__evtManager = events.eventManager + self.__evtManager = eventManager self.__msgManager = msgMan self.__msg = None self.__waiting = False