[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8648 - in trunk/gnue-forms/src: . uidrivers/_base uidrivers/curs
From: |
reinhard |
Subject: |
[gnue] r8648 - in trunk/gnue-forms/src: . uidrivers/_base uidrivers/curses uidrivers/gtk2 uidrivers/gtk2/widgets/form uidrivers/html uidrivers/qt uidrivers/win32 uidrivers/win32/widgets/form uidrivers/wx uidrivers/wx/widgets/form uidrivers/wx26 uidrivers/wx26/widgets |
Date: |
Mon, 4 Sep 2006 13:59:24 -0500 (CDT) |
Author: reinhard
Date: 2006-09-04 13:59:22 -0500 (Mon, 04 Sep 2006)
New Revision: 8648
Modified:
trunk/gnue-forms/src/GFForm.py
trunk/gnue-forms/src/GFInstance.py
trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py
trunk/gnue-forms/src/uidrivers/html/UIdriver.py
trunk/gnue-forms/src/uidrivers/qt/UIdriver.py
trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py
trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
Log:
Restructured procedures to close a form and to exit the application.
Application is now generally ended when the last form is closed.
Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py 2006-09-04 14:02:28 UTC (rev 8647)
+++ trunk/gnue-forms/src/GFForm.py 2006-09-04 18:59:22 UTC (rev 8648)
@@ -95,8 +95,8 @@
# Hackery until proper layout support is added
self._standardnamespaces = {'Char': 'GNUe:Forms:Char'}
- # Set to True by GFInstance when we are closing the form
- self._exiting = False
+ # Is this form currently open?
+ self.__visible = False
# The "None" init gives datasources time to setup master/detail
self._inits = [self.phase_1_init, self.phase_2_init, self.phase_3_init]
@@ -247,6 +247,39 @@
# -------------------------------------------------------------------------
+ # Open (activate) the form
+ # -------------------------------------------------------------------------
+
+ def execute_open(self, parameters, modal):
+
+ if not self._currentEntry:
+ raise errors.ApplicationError, u_(
+ "There are no navigable widgets in this form. "
+ "Unable to display.")
+
+ self._parameters = parameters
+
+ assert gDebug(4, "Processing activation trigger")
+ self.processTrigger('On-Activation')
+
+ # First set the current entry to be focused and up to date before
+ # displaying the real UI form.
+ assert gDebug(4, "Initial display setup")
+ self.refreshDisplay(self)
+ self.update_status()
+
+ assert gDebug(4, "Setting initial focus")
+ self.dispatchEvent('gotoENTRY', object = self._currentEntry,
+ _form = self)
+ self.beginEditing()
+
+ self.__visible = True
+
+ assert gDebug(4, "Activating form")
+ self._instance._uiinstance.activateForm(self.name, modal)
+
+
+ # -------------------------------------------------------------------------
# Trigger functions
# -------------------------------------------------------------------------
@@ -529,11 +562,7 @@
Closes this copy of GNUe-Forms.
@return: None, or 1 if error
"""
- event = events.Event('requestEXIT', _form=self)
- #self._instance.dispatchEvent(event)
- self.dispatchEvent(event)
- if event.__error__:
- return 1
+ self.execute_close()
# -------------------------------------------------------------------------
@@ -942,9 +971,9 @@
handled, just like L{event_begin} is called at the beginning.
"""
- if not self._exiting:
- if self.uiWidget:
- self.uiWidget._ui_end_wait_()
+ if self.uiWidget:
+ self.uiWidget._ui_end_wait_()
+ if self.__visible:
self.refreshDisplay(self)
@@ -1725,6 +1754,15 @@
# -------------------------------------------------------------------------
+ # Is this form visible?
+ # -------------------------------------------------------------------------
+
+ def is_visible(self):
+
+ return self.__visible
+
+
+ # -------------------------------------------------------------------------
# Close this window
# -------------------------------------------------------------------------
@@ -1741,10 +1779,14 @@
self.processTrigger('On-Exit')
- self._exiting = True
- self.dispatchEvent('exitApplication', _formName=self.name, _form=self)
+ if self.uiWidget:
+ self.uiWidget._ui_close_()
+ self.__visible = False
+ self._instance.maybe_exit()
+
+
# -------------------------------------------------------------------------
# Ask the user whether to save or to discard changes if there are any
# -------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/GFInstance.py
===================================================================
--- trunk/gnue-forms/src/GFInstance.py 2006-09-04 14:02:28 UTC (rev 8647)
+++ trunk/gnue-forms/src/GFInstance.py 2006-09-04 18:59:22 UTC (rev 8648)
@@ -370,30 +370,7 @@
def activateForm (self, formName = '__main__', parameters = None, modal =
False):
assert gEnter (4)
-
- form = self._formsDictionary [formName]
-
- if not form._currentEntry:
- raise errors.ApplicationError, \
- u_("There are no navigable widgets in this form. Unable to display.")
-
- form._parameters = parameters
-
- assert gDebug (4, "Processing activation trigger")
- form.processTrigger ('On-Activation')
-
- # First set the current entry to be focused and up to date before
- # displaying the real UI form.
- assert gDebug (4, "Initial display setup")
- form.refreshDisplay (form)
- form.update_status()
-
- assert gDebug (4, "Setting initial focus")
- self.dispatchEvent ('gotoENTRY', object = form._currentEntry, _form = form)
- form.beginEditing()
- assert gDebug (4, "Activating form")
- self._uiinstance.activateForm (formName, modal)
-
+ self._formsDictionary[formName].execute_open(parameters, modal)
assert gLeave (4)
@@ -407,6 +384,26 @@
self._uiinstance.buildForm (form, formName)
+ # ---------------------------------------------------------------------------
+ # Exit the application if the last form has been closed
+ # ---------------------------------------------------------------------------
+
+ def maybe_exit(self):
+ """
+ Exit the application if the last form has been closed
+
+ This function is called by each form when it is closed.
+ """
+
+ any_form_open = False
+ for form in self._formsDictionary.values():
+ if form.is_visible():
+ any_form_open = True
+ break
+ if not any_form_open:
+ self._uiinstance._ui_exit_()
+
+
# ===========================================================================
# EVENT FUNCTIONS
# ===========================================================================
Modified: trunk/gnue-forms/src/uidrivers/_base/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/_base/UIdriver.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/_base/UIdriver.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -190,7 +190,6 @@
'updateENTRY' : self.updateEntry,
'updateEntryEditor': self.updateEntryEditor,
'gotoPAGE' : self.goto_page,
- 'exitApplication' : self.exitApplication,
'setTitle' : self.setTitle,
# Clipboard contents
@@ -453,14 +452,6 @@
# ---------------------------------------------------------------------------
- # Form has told the application to close so call the UIs private exit routine
- # ---------------------------------------------------------------------------
-
- def exitApplication (self, event):
- self._exit (event._formName)
-
-
- # ---------------------------------------------------------------------------
# Update the widget creation event
# ---------------------------------------------------------------------------
@@ -633,15 +624,6 @@
# ---------------------------------------------------------------------------
- # Exit the application
- # ---------------------------------------------------------------------------
-
- def _exit(self):
-
- raise ImplementationError, (self.name, '_exit')
-
-
- # ---------------------------------------------------------------------------
# Set the form's displayed title
# ---------------------------------------------------------------------------
Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -315,7 +315,7 @@
# Clean up everything
# ---------------------------------------------------------------------------
- def _exit (self, formName):
+ def _ui_exit_ (self):
self.__exiting = True
Modified: trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/gtk2/UIdriver.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -132,47 +132,8 @@
self.widgetHeight = self.textHeight
-
-
#############################################################################
#
- # Private UIBase support functions
- #
- # Called in UIbase functions to perform UI interaction with this specific
- # widget set.
- #
-
- # ---------------------------------------------------------------------------
- # Tells the application to close it's main window
- # ---------------------------------------------------------------------------
-
- def _exit (self, formName):
-
- _form = None
-
- exitApp = True
- for child in self._children:
- if child._form.name == formName:
- child.mainWindow.hide ()
- child._visible = False
- _form = child._form
-
- exitApp = exitApp and not child._visible
-
- if exitApp:
- for child in self._children:
- if not isinstance (child.mainWindow, gtk.Dialog):
- child.mainWindow.destroy ()
- else:
- child.mainWindow.response (gtk.RESPONSE_CLOSE)
-
- # if the main form is a dialog we do *not* quit the main loop manually
- if formName == '__main__' and _form.style != 'dialog':
- self.app.quit ()
-
-
- #############################################################################
- #
# Incoming Event Processors
#
# Processes the incoming events from other objects
@@ -336,7 +297,28 @@
gtk.main_iteration (False)
+ # ---------------------------------------------------------------------------
+ # Exit the application
+ # ---------------------------------------------------------------------------
+ def _ui_exit_(self):
+ """
+ Exit the application.
+ """
+
+ assert gEnter(6)
+
+ for child in self._children:
+ if not isinstance (child.mainWindow, gtk.Dialog):
+ child.mainWindow.destroy ()
+ else:
+ child.mainWindow.response (gtk.RESPONSE_CLOSE)
+
+ self.app.quit ()
+
+ assert gLeave(6)
+
+
# -----------------------------------------------------------------------------
# Get font metrics and font description for a given font
# -----------------------------------------------------------------------------
@@ -482,6 +464,7 @@
return (min (w * maxW, gtk.gdk.screen_width ()),
min (h * maxH, gtk.gdk.screen_height () - 100))
+
# =============================================================================
# Get the current default application font and it's metrics
# =============================================================================
Modified: trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py 2006-09-04
14:02:28 UTC (rev 8647)
+++ trunk/gnue-forms/src/uidrivers/gtk2/widgets/form/widget.py 2006-09-04
18:59:22 UTC (rev 8648)
@@ -137,7 +137,7 @@
self._eventHandler = event.eventHandler
self._wrapper.finalize ()
- self._visible = 0
+ self._visible = False
return newWidget
@@ -191,23 +191,12 @@
if widget != self.mainWindow.get_focus ():
widget.grab_focus ()
- self._visible = 1
+ self._visible = True
if self._form.style == 'dialog':
self.mainWindow.run ()
# ---------------------------------------------------------------------------
- # Hide the current form
- # ---------------------------------------------------------------------------
-
- def hide (self):
- self.containerFrame.hide ()
- self.mainWindow.hide ()
- self.mainWindow.set_modal (False)
- self._visible = 0
-
-
- # ---------------------------------------------------------------------------
# Show the current form modal
# ---------------------------------------------------------------------------
@@ -223,7 +212,7 @@
if widget != self.mainWindow.get_focus ():
widget.grab_focus ()
- self._visible = 1
+ self._visible = True
if self._form.style == 'dialog':
self.mainWindow.run ()
@@ -323,3 +312,15 @@
def _ui_printout_(self, title, subtitle, user):
pass
+
+
+ # ---------------------------------------------------------------------------
+ # Close the window (actually only hide it)
+ # ---------------------------------------------------------------------------
+
+ def _ui_close_(self):
+
+ self.containerFrame.hide ()
+ self.mainWindow.hide ()
+ self.mainWindow.set_modal (False)
+ self._visible = False
Modified: trunk/gnue-forms/src/uidrivers/html/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/html/UIdriver.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/html/UIdriver.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -52,8 +52,5 @@
self.widgetWidth = self.textWidth # The pixel width of a 1 char widget
(for things like buttons)
self.widgetHeight = self.textHeight + 5 # The pixel height of a 1 char
widget (for things like buttons)
- def _exit(self,formName):
- pass
-
def mainLoop(self):
self._htmlapp.MainLoop() # simply call the wxApp's MainLoop method
Modified: trunk/gnue-forms/src/uidrivers/qt/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt/UIdriver.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/qt/UIdriver.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -133,36 +133,8 @@
self.widgetHeight = self.textHeight + 4
-
#############################################################################
#
- # Private UIBase support functions
- #
- # Called in UIbase functions to perform UI interaction with this specific
- # widget set.
- #
-
- #
- # _exit
- #
- # Tells the application to close it's main window
- #
- def _exit(self, formName):
- exitApp = True
- for child in self._children:
- if child._form.name == formName:
- child.mainWindow.hide()
-
- exitApp = exitApp and not child.mainWindow.isVisible()
-
- if exitApp:
- for child in self._children:
- child.mainWindow.close(True)
-
-
-
- #############################################################################
- #
# Incoming Event Processors
#
# Processes the incoming events from other objects
Modified: trunk/gnue-forms/src/uidrivers/win32/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/UIdriver.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/win32/UIdriver.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -196,44 +196,8 @@
self.widgetHeight = self.textHeight + 5 # The pixel height of a 1
char widget (for things like buttons)
dummyWindow.ReleaseDC(dc)
-
- #############################################################################
- #
- # Private UIBase support functions
- #
- # Called in UIbase functions to perform UI interaction with this specific
- # widget set.
- #
- #
- # _exit
- #
- # Tells the application to close it's main window
- #
- def _exit(self,formName):
- exitApp = 1
- for child in self._children:
- if child._form.name == formName:
- child.mainWindow.Hide()
-
- if child._form.style == 'dialog':
- win32gui.PostQuitMessage(0) # Terminate the dialog
- exitApp = exitApp and not
win32gui.IsWindowVisible(child.mainWindow.GetHwnd())
-
- if exitApp:
- for child in self._children:
- self._win32app._MainWindowList.remove(child.mainWindow)
- child.mainWindow.Destroy()
-
- if len(self._win32app._MainWindowList) == 0:
- win32gui.PostQuitMessage(0) # Terminate the app.
-
- for window in self._win32app._MainWindowList:
- if isinstance(window, Win32Window):
- window.Enable(1)
- win32gui.SetActiveWindow(window.GetHwnd())
-
#############################################################################
#
# Incoming Event Processors
@@ -361,6 +325,28 @@
def _showAbout (self, name, appversion, formversion, author, description):
d = dialogs.AboutBox (name, appversion, formversion, author, description)
d.DoModal ()
+
+
+ # ---------------------------------------------------------------------------
+ # Exit the application
+ # ---------------------------------------------------------------------------
+
+ def _ui_exit_(self):
+ """
+ Exit the application.
+ """
+
+ for child in self._children:
+ self._win32app._MainWindowList.remove(child.mainWindow)
+ child.mainWindow.Destroy()
+
+ if len(self._win32app._MainWindowList) == 0:
+ win32gui.PostQuitMessage(0) # Terminate the app.
+
+ for window in self._win32app._MainWindowList:
+ if isinstance(window, Win32Window):
+ window.Enable(1)
+ win32gui.SetActiveWindow(window.GetHwnd())
# =============================================================================
Modified: trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2006-09-04
14:02:28 UTC (rev 8647)
+++ trunk/gnue-forms/src/uidrivers/win32/widgets/form/widget.py 2006-09-04
18:59:22 UTC (rev 8648)
@@ -216,3 +216,15 @@
def _ui_printout_(self, title, subtitle, user):
pass
+
+
+ # ---------------------------------------------------------------------------
+ # Close the window (actually only hide it)
+ # ---------------------------------------------------------------------------
+
+ def _ui_close_(self):
+
+ child.mainWindow.Hide()
+
+ if child._form.style == 'dialog':
+ win32gui.PostQuitMessage(0) # Terminate the dialog
Modified: trunk/gnue-forms/src/uidrivers/wx/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/UIdriver.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/wx/UIdriver.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -130,31 +130,6 @@
#############################################################################
#
- # Private UIBase support functions
- #
- # Called in UIbase functions to perform UI interaction with this specific
- # widget set.
- #
-
- #
- # _exit
- #
- # Tells the application to close it's main window
- #
- def _exit(self,formName):
- exitApp = 1
- for child in self._children:
- if child._form.name == formName:
- child.mainWindow.Hide()
-
- exitApp = exitApp and not child.mainWindow.IsShown()
-
- if exitApp:
- for child in self._children:
- child.mainWindow.Close(true)
-
- #############################################################################
- #
# Incoming Event Processors
#
# Processes the incoming events from other objects
@@ -283,3 +258,16 @@
def _showException (self, group, name, message, detail):
self._showMessage (wxEncode (detail), 'Error')
+
+
+ # ---------------------------------------------------------------------------
+ # Exit the application
+ # ---------------------------------------------------------------------------
+
+ def _ui_exit_(self):
+ """
+ Exit the application.
+ """
+
+ for child in self._children:
+ child.mainWindow.Close(True)
Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py 2006-09-04
14:02:28 UTC (rev 8647)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/form/widget.py 2006-09-04
18:59:22 UTC (rev 8648)
@@ -241,3 +241,12 @@
def _ui_printout_(self, title, subtitle, user):
printForm(self, title, subtitle, user)
+
+
+ # -------------------------------------------------------------------------
+ # Close the window (actually only hide it)
+ # -------------------------------------------------------------------------
+
+ def _ui_close_(self):
+
+ self.main_window.Hide()
Modified: trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/wx26/UIdriver.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -147,37 +147,6 @@
# ---------------------------------------------------------------------------
- # Close the main window
- # ---------------------------------------------------------------------------
-
- def _exit (self, formName):
- """
- Hide all forms with a given name. If no window is open anymore, close all
- child windows.
- """
-
- assert gEnter (6)
-
- exitApp = True
-
- for child in self._children:
- if child._form.name == formName:
- window = child.main_window
- if isinstance (window, wx.Dialog) and window.IsModal ():
- window.EndModal (-1)
- else:
- window.Hide ()
-
- exitApp = exitApp and not child.main_window.IsShown ()
-
- if exitApp:
- for child in self._children:
- child.main_window.Close (True)
-
- assert gLeave (6)
-
-
- # ---------------------------------------------------------------------------
# Hide the splash screen
# ---------------------------------------------------------------------------
@@ -317,3 +286,20 @@
finally:
dialog.Destroy ()
+
+
+ # ---------------------------------------------------------------------------
+ # Exit the application
+ # ---------------------------------------------------------------------------
+
+ def _ui_exit_(self):
+ """
+ Exit the application.
+ """
+
+ assert gEnter(6)
+
+ for child in self._children:
+ child.main_window.Close(True)
+
+ assert gLeave(6)
Modified: trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-09-04 14:02:28 UTC
(rev 8647)
+++ trunk/gnue-forms/src/uidrivers/wx26/widgets/form.py 2006-09-04 18:59:22 UTC
(rev 8648)
@@ -187,17 +187,17 @@
# Show the form/dialog
# -------------------------------------------------------------------------
- def show (self):
+ def show(self):
"""
Show the form or dialog non-modal. This function raises the Frame or
Dialog into the front, enables processing of wx.EVT_SIZE events and
shows the window.
"""
- self.main_window.Raise ()
+ self.main_window.Raise()
self.sizing_enabled = True
- self.main_window.Show ()
+ self.main_window.Show()
self._uiDriver.hide_splash()
@@ -343,7 +343,10 @@
self.__status_bar.SetStatusText(
"%s/%s" % (page_number, page_count), 4)
+
# -------------------------------------------------------------------------
+ # Change the page
+ # -------------------------------------------------------------------------
def _ui_goto_page_(self, page):
"""
@@ -373,6 +376,19 @@
_Printout(title, subtitle, user, image))
+ # -------------------------------------------------------------------------
+ # Close the window (actually only hide it)
+ # -------------------------------------------------------------------------
+
+ def _ui_close_(self):
+
+ if isinstance(self.main_window, wx.Dialog) \
+ and self.main_window.IsModal():
+ self.main_window.EndModal(-1)
+ else:
+ self.main_window.Hide()
+
+
# =============================================================================
# Helper class for screen dump printing
# =============================================================================
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8648 - in trunk/gnue-forms/src: . uidrivers/_base uidrivers/curses uidrivers/gtk2 uidrivers/gtk2/widgets/form uidrivers/html uidrivers/qt uidrivers/win32 uidrivers/win32/widgets/form uidrivers/wx uidrivers/wx/widgets/form uidrivers/wx26 uidrivers/wx26/widgets,
reinhard <=