commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r10130 - in trunk/gnue-forms/src: . uidrivers/curses uidrivers/cu


From: reinhard
Subject: [gnue] r10130 - in trunk/gnue-forms/src: . uidrivers/curses uidrivers/curses/widgets uidrivers/qt3/widgets uidrivers/qt4/widgets uidrivers/wx/widgets
Date: Wed, 16 Dec 2009 12:25:59 -0600 (CST)

Author: reinhard
Date: 2009-12-16 12:25:59 -0600 (Wed, 16 Dec 2009)
New Revision: 10130

Modified:
   trunk/gnue-forms/src/GFForm.py
   trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
   trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
   trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
   trunk/gnue-forms/src/uidrivers/qt4/widgets/form.py
   trunk/gnue-forms/src/uidrivers/wx/widgets/form.py
Log:
Make form visible before blocks are populated and On-Activation trigger runs.


Modified: trunk/gnue-forms/src/GFForm.py
===================================================================
--- trunk/gnue-forms/src/GFForm.py      2009-12-16 18:25:19 UTC (rev 10129)
+++ trunk/gnue-forms/src/GFForm.py      2009-12-16 18:25:59 UTC (rev 10130)
@@ -391,10 +391,6 @@
         # build the UI form
         self._instance._uiinstance.buildForm(self, self.name)
 
-        # populate the blocks
-        for block in self._logic._blockList:
-            block.populate()
-
         self.update_insert_status()
 
 
@@ -437,28 +433,37 @@
 
     def execute_open(self, modal):
 
-        # Set initial focus
-        self.__find_and_change_focus([self._currentPage], False)
-
-        assert gDebug(4, "Processing activation trigger")
-        # Switch off editing mode so the On-Activation trigger can cleanly
-        # change the field value even of the first field in the form. Usually,
-        # changing the value of a field while an associated entry is in editing
-        # mode doesn't work.
-        self.endEditing()
-        self.processTrigger('On-Activation')
-        self.beginEditing()
-
         self.__visible = True
 
         assert gDebug(4, "Activating form")    
-        self.uiWidget._ui_show_(modal)
+        self.uiWidget._ui_open_(modal)
 
 
     # -------------------------------------------------------------------------
     # UI events (called from UIForm)
     # -------------------------------------------------------------------------
 
+    def _event_open(self):
+
+        self.event_begin()
+        try:
+            # populate the blocks
+            self.status_message(u_("Loading data..."))
+            for block in self._logic._blockList:
+                block.populate()
+
+            self.processTrigger('On-Activation')
+
+            # If the On-Activation trigger hasn't set the focus explicitly, set
+            # it to the first available control.
+            if self._currentEntry is None:
+                self.__find_and_change_focus([self._currentPage], False)
+        finally:
+            self.event_end()
+
+
+    # -------------------------------------------------------------------------
+
     def _event_focus_changed(self, target, row_offset):
         """
         Notify the form that the user has moved the focus with a mouse click.

Modified: trunk/gnue-forms/src/uidrivers/curses/UIdriver.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/UIdriver.py   2009-12-16 18:25:19 UTC 
(rev 10129)
+++ trunk/gnue-forms/src/uidrivers/curses/UIdriver.py   2009-12-16 18:25:59 UTC 
(rev 10130)
@@ -98,6 +98,8 @@
         self.textWidth = 1
         self.textHeight = 1
 
+        self._focus_widget = None
+
         self.__exiting = False
 
         KeyMapper.setUIKeyMap(self._keymap)

Modified: trunk/gnue-forms/src/uidrivers/curses/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/curses/widgets/form.py       2009-12-16 
18:25:19 UTC (rev 10129)
+++ trunk/gnue-forms/src/uidrivers/curses/widgets/form.py       2009-12-16 
18:25:59 UTC (rev 10130)
@@ -108,11 +108,12 @@
     # Show the form
     # -------------------------------------------------------------------------
 
-    def _ui_show_(self, modal):
+    def _ui_open_(self, modal):
 
         (width, height) = self._uiDriver.screen_size()
         self.set_size_and_fit(width, height)
         self._uiDriver.show_form(self, modal)
+        self._form._event_open()
 
 
     # -------------------------------------------------------------------------
@@ -422,7 +423,7 @@
             if menuitem is not None and menuitem.is_enabled:
                 text.append(menuitem.hotkey + "=" + menuitem._gfObject.label)
 
-        self.__window.addstr(y-1, 0, o(' '.join(text)))
+        self.__window.addstr(y-1, 0, o(' '.join(text)[:x-1]))
         self.__window.clrtoeol()
         self.__window.refresh(y - 1, 0, y - 1, 0, y, x)
 
@@ -466,7 +467,9 @@
         except curses.error:
             pass
 
-        if pages_ok:
+        self.__currentPage.repaint()
+
+        if pages_ok and self._uiDriver._focus_widget:
             self._uiDriver._focus_widget._ui_set_focus_(0)
 
 

Modified: trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py  2009-12-16 18:25:19 UTC 
(rev 10129)
+++ trunk/gnue-forms/src/uidrivers/qt3/widgets/form.py  2009-12-16 18:25:59 UTC 
(rev 10130)
@@ -122,16 +122,23 @@
     # Show the form/dialog
     # -------------------------------------------------------------------------
 
-    def _ui_show_(self, modal):
+    def _ui_open_(self, modal):
 
         self._uiDriver.hide_splash()
         self.sizing_enabled = True
 
         if modal and isinstance(self.main_window, qt.QDialog):
+            self._form._event_open()
             self.main_window.setModal(True)
             self.main_window.exec_loop()
         else:
+            self.main_window.setEnabled(False)
             self.main_window.show()
+            QTApp.getQtApp().processEvents()
+            self._form._event_open()
+            self.main_window.setEnabled(True)
+            if self._form.get_focus_object():
+                self._form.get_focus_object().ui_set_focus()
 
 
     # -------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/qt4/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/qt4/widgets/form.py  2009-12-16 18:25:19 UTC 
(rev 10129)
+++ trunk/gnue-forms/src/uidrivers/qt4/widgets/form.py  2009-12-16 18:25:59 UTC 
(rev 10130)
@@ -135,16 +135,23 @@
     # Show the form/dialog
     # -------------------------------------------------------------------------
 
-    def _ui_show_(self, modal):
+    def _ui_open_(self, modal):
 
         self._uiDriver.hide_splash()
         self.sizing_enabled = True
 
         if modal and isinstance(self.main_window, qt.QDialog):
+            self._form._event_open()
             self.main_window.setModal(True)
             self.main_window.exec_()
         else:
+            self.main_window.setEnabled(False)
             self.main_window.show()
+            QTApp.getQtApp().processEvents()
+            self._form._event_open()
+            self.main_window.setEnabled(True)
+            if self._form.get_focus_object():
+                self._form.get_focus_object().ui_set_focus()
 
 
     # -------------------------------------------------------------------------

Modified: trunk/gnue-forms/src/uidrivers/wx/widgets/form.py
===================================================================
--- trunk/gnue-forms/src/uidrivers/wx/widgets/form.py   2009-12-16 18:25:19 UTC 
(rev 10129)
+++ trunk/gnue-forms/src/uidrivers/wx/widgets/form.py   2009-12-16 18:25:59 UTC 
(rev 10130)
@@ -138,6 +138,7 @@
         self._menubar_ = None
 
         self.main_window.Bind(wx.EVT_ACTIVATE, self.__on_activate)
+        self.main_window.Bind(wx.EVT_INIT_DIALOG, self.__on_init_dialog)
 
         if not self.__embedded:
             self.main_window.Bind(wx.EVT_CLOSE, self.__on_close,
@@ -245,7 +246,7 @@
     # Show the form/dialog
     # -------------------------------------------------------------------------
 
-    def _ui_show_(self, modal):
+    def _ui_open_(self, modal):
 
         self._uiDriver.hide_splash()
         self.main_window.Raise()
@@ -254,7 +255,15 @@
         if modal and isinstance(self.main_window, wx.Dialog):
             self.main_window.ShowModal()
         else:
+            self.main_window.Enable(False)
             self.main_window.Show()
+            wx.GetApp().Yield()
+            self._form._event_open()
+            self.main_window.Enable(True)
+            # Need to set the UI focus now since the focus control was disabled
+            # before and thus hasn't got the focus yet.
+            if self._form.get_focus_object():
+                self._form.get_focus_object().ui_set_focus()
 
 
     # -------------------------------------------------------------------------
@@ -306,6 +315,24 @@
 
     # -------------------------------------------------------------------------
 
+    def __on_init_dialog(self, event):
+
+        # FIXME: This is also called at the time when the Show() in
+        # __on_close() runs, but we don't want this to run then. So whenever
+        # the workaround for issue132 is removed, the following "if" line can
+        # be removed, too.
+        if self.main_window is not None:
+            self.main_window.Enable(False)
+            wx.GetApp().Yield()
+            self._form._event_open()
+            self.main_window.Enable(True)
+            # Need to set the UI focus now since the focus control was disabled
+            # before and thus hasn't got the focus yet.
+            if self._form.get_focus_object():
+                self._form.get_focus_object().ui_set_focus()
+
+    # -------------------------------------------------------------------------
+
     def __on_close(self, event):
 
         if event.CanVeto():
@@ -318,6 +345,13 @@
             # this doesn't work, so we destroy the form manually.
             # event.Skip()
 
+            # FIXME: Workaround for issue131: Calling wx.EndBusyCursor()
+            # at a time when all forms have been destroyed generates a segfault
+            # if the last form that has been shown is open on a non-first page.
+            # So we set main_window to None when destroying the main window and
+            # don't call wx.EndBusyCursor() if main_window is None.
+            self.main_window = None
+
             # FIXME: Workaround for issue132: Destroying Windows that are not
             # visible at the time of being destroyed does not work in wx2.6.x.
             # This workaround shoud be obsolete with wx2.7+
@@ -325,13 +359,6 @@
 
             event.GetEventObject().Destroy()
 
-            # FIXME: Workaround for issue131: Calling wx.EndBusyCursor()
-            # at a time when all forms have been destroyed generates a segfault
-            # if the last form that has been shown is open on a non-first page.
-            # So we set main_window to None when destroying the main window and
-            # don't call wx.EndBusyCursor() if main_window is None.
-            self.main_window = None
-
     # -------------------------------------------------------------------------
 
     def __on_page_changed(self, event):





reply via email to

[Prev in Thread] Current Thread [Next in Thread]