Changeset 2023 for trunk/source/gui/__init__.py
- Timestamp:
- 05/07/08 09:04:04 (7 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
. (modified) (3 props)
-
source/gui/__init__.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property bzr:revision-id:v3-list-QlpoOTFBWSZTWbrL2vUAAB1VgAAQABCAQDrrnqAgAFCgaaGRkxBoTIJ6mmaNRwhndFAoNhZjh_YY4a01fOg1ulgNNC2UrzPdXXEnDpX8XckU4UJC6y9r1A..
-
old new 87 87 1813 jamie@jantrid.net-20080502122842-u2xfo1in3euux4ci 88 88 1825 jamie@jantrid.net-20080506061049-3qk3r33c6a8dc4jo 89 1828 jamie@jantrid.net-20080507090220-y1fjk3t08rbcx18z
-
- Property bzr:revision-info
-
old new 1 timestamp: 2008-05-0 6 16:10:49.217000008+10001 timestamp: 2008-05-07 19:02:20.607000113 +1000 2 2 committer: James Teh <jamie@jantrid.net> 3 3 properties:
-
- Property bzr:ancestry:v3-list-QlpoOTFBWSZTWbrL2vUAAB1VgAAQABCAQDrrnqAgAFCgaaGRkxBoTIJ6mmaNRwhndFAoNhZjh_YY4a01fOg1ulgNNC2UrzPdXXEnDpX8XckU4UJC6y9r1A..
-
old new 3 3 jamie@jantrid.net-20080212104116-78n366kl7diwve24 4 4 jamie@jantrid.net-20080229050825-20q1xhb2t4c0zcza 5 jamie@jantrid.net-20080507074841-cxoldzwvz389fete
-
- Property bzr:revision-id:v3-list-QlpoOTFBWSZTWbrL2vUAAB1VgAAQABCAQDrrnqAgAFCgaaGRkxBoTIJ6mmaNRwhndFAoNhZjh_YY4a01fOg1ulgNNC2UrzPdXXEnDpX8XckU4UJC6y9r1A..
-
trunk/source/gui/__init__.py
r1958 r2023 20 20 import languageHandler 21 21 import logViewer 22 import winUser 22 23 23 24 ### Constants … … 29 30 id_showGuiCommand=wx.NewId() 30 31 id_abortCommand=wx.NewId() 31 evt_externalExecute = wx.NewEventType() 32 evtid_externalExecute = wx.NewEventType() 33 evt_externalExecute = wx.PyEventBinder(evtid_externalExecute, 1) 32 34 33 35 ### Globals 34 36 mainFrame = None 35 37 #: A list of top level windows excluding L{mainFrame} which are currently instantiated and which should be destroyed on exit. 36 #: @type: list37 topLevelWindows = []38 38 39 39 class ExternalExecuteEvent(wx.PyCommandEvent): 40 40 def __init__(self, func, args, kwargs, callback): 41 super(ExternalExecuteEvent, self).__init__(evt _externalExecute, wx.ID_ANY)41 super(ExternalExecuteEvent, self).__init__(evtid_externalExecute, wx.ID_ANY) 42 42 self._func = func 43 43 self._args = args … … 97 97 def __init__(self): 98 98 style = wx.DEFAULT_FRAME_STYLE ^ wx.MAXIMIZE_BOX ^ wx.MINIMIZE_BOX | wx.FRAME_NO_TASKBAR 99 super(MainFrame, self).__init__(None, wx.ID_ANY, appTitle, size=( 500,500), style=style)99 super(MainFrame, self).__init__(None, wx.ID_ANY, appTitle, size=(1,1), style=style) 100 100 self.Bind(evt_externalCommand, self.onAbortCommand, id=id_abortCommand) 101 101 self.Bind(evt_externalCommand, self.onExitCommand, id=wx.ID_EXIT) 102 102 self.Bind(evt_externalCommand, self.onShowGuiCommand, id=id_showGuiCommand) 103 wx.EVT_COMMAND(self,wx.ID_ANY,evt_externalExecute,lambda evt: evt.run())103 self.Bind(evt_externalExecute,lambda evt: evt.run()) 104 104 self.sysTrayIcon = SysTrayIcon(self) 105 self.Show(True) 106 self.Show(False) 105 # This makes Windows return to the previous foreground window and also seems to allow NVDA to be brought to the foreground. 106 self.Show() 107 self.Hide() 107 108 108 109 def Destroy(self): 109 global topLevelWindows110 110 self.sysTrayIcon.Destroy() 111 for window in list(topLevelWindows):112 window.Destroy()113 111 super(MainFrame, self).Destroy() 112 113 def prePopup(self): 114 """Prepare for a popup. 115 This should be called before any dialog or menu which should pop up for the user. 116 L{postPopup} should be called after the dialog or menu has been shown. 117 @postcondition: A dialog or menu may be shown. 118 """ 119 if winUser.getWindowThreadProcessID(winUser.getForegroundWindow())[0] != os.getpid(): 120 # This process is not the foreground process, so bring it to the foreground. 121 self.Raise() 122 123 def postPopup(self): 124 """Clean up after a popup dialog or menu. 125 This should be called after a dialog or menu was popped up for the user. 126 """ 127 if not winUser.isWindowVisible(winUser.getForegroundWindow()): 128 # The current foreground window is invisible, so we want to return to the previous foreground window. 129 # Showing and hiding our main window seems to achieve this. 130 self.Show() 131 self.Hide() 114 132 115 133 def onAbortCommand(self,evt): … … 129 147 speech.speakMessage(_("Could not save configuration - probably read only file system"),wait=True) 130 148 149 def _popupSettingsDialog(self, dialog, *args, **kwargs): 150 self.prePopup() 151 dialog(self, *args, **kwargs).Show() 152 self.postPopup() 153 131 154 def onDefaultDictionaryCommand(self,evt): 132 d=DictionaryDialog(None,_("Default dictionary"),speechDictHandler.dictionaries["default"]) 133 d.Show(True) 155 self._popupSettingsDialog(DictionaryDialog,_("Default dictionary"),speechDictHandler.dictionaries["default"]) 134 156 135 157 def onVoiceDictionaryCommand(self,evt): 136 d=DictionaryDialog(None,_("Voice dictionary (%s)")%speechDictHandler.dictionaries["voice"].fileName,speechDictHandler.dictionaries["voice"]) 137 d.Show(True) 158 self._popupSettingsDialog(DictionaryDialog,_("Voice dictionary (%s)")%speechDictHandler.dictionaries["voice"].fileName,speechDictHandler.dictionaries["voice"]) 138 159 139 160 def onTemporaryDictionaryCommand(self,evt): 140 d=DictionaryDialog(None,_("Temporary dictionary"),speechDictHandler.dictionaries["temp"]) 141 d.Show(True) 161 self._popupSettingsDialog(DictionaryDialog,_("Temporary dictionary"),speechDictHandler.dictionaries["temp"]) 142 162 143 163 def onExitCommand(self, evt): 144 164 canExit=False 145 165 if config.conf["general"]["askToExit"]: 146 d = wx.MessageDialog(None, _("Are you sure you want to quit NVDA?"), _("Exit NVDA"), wx.YES|wx.NO|wx.ICON_WARNING) 166 self.prePopup() 167 d = wx.MessageDialog(self, _("Are you sure you want to quit NVDA?"), _("Exit NVDA"), wx.YES|wx.NO|wx.ICON_WARNING) 147 168 if d.ShowModal() == wx.ID_YES: 148 169 canExit=True 170 self.postPopup() 149 171 else: 150 172 canExit=True … … 158 180 159 181 def onGeneralSettingsCommand(self,evt): 160 d=GeneralSettingsDialog(None) 161 d.Show(True) 182 self._popupSettingsDialog(GeneralSettingsDialog) 162 183 163 184 def onSynthesizerCommand(self,evt): 164 d=SynthesizerDialog(None) 165 d.Show(True) 185 self._popupSettingsDialog(SynthesizerDialog) 166 186 167 187 def onVoiceCommand(self,evt): 168 d=VoiceSettingsDialog(None) 169 d.Show(True) 188 self._popupSettingsDialog(VoiceSettingsDialog) 170 189 171 190 def onKeyboardSettingsCommand(self,evt): 172 d=KeyboardSettingsDialog(None) 173 d.Show(True) 191 self._popupSettingsDialog(KeyboardSettingsDialog) 174 192 175 193 def onMouseSettingsCommand(self,evt): 176 d=MouseSettingsDialog(None) 177 d.Show(True) 194 self._popupSettingsDialog(MouseSettingsDialog) 178 195 179 196 def onObjectPresentationCommand(self,evt): 180 d=ObjectPresentationDialog(None) 181 d.Show(True) 197 self._popupSettingsDialog(ObjectPresentationDialog) 182 198 183 199 def onVirtualBuffersCommand(self,evt): 184 d=VirtualBuffersDialog(None) 185 d.Show(True) 200 self._popupSettingsDialog(VirtualBuffersDialog) 186 201 187 202 def onDocumentFormattingCommand(self,evt): 188 d=DocumentFormattingDialog(None) 189 d.Show(True) 203 self._popupSettingsDialog(DocumentFormattingDialog) 190 204 191 205 def onAboutCommand(self,evt): … … 195 209 %s: %s 196 210 %s: %s"""%(versionInfo.longName,_("version"),versionInfo.version,_("url"),versionInfo.url,_("copyright"),versionInfo.copyrightInfo) 197 d = wx.MessageDialog(None, aboutInfo, _("About NVDA"), wx.OK) 211 self.prePopup() 212 d = wx.MessageDialog(self, aboutInfo, _("About NVDA"), wx.OK) 198 213 d.ShowModal() 214 self.postPopup() 199 215 except: 200 216 globalVars.log.error("gui.mainFrame.onAbout", exc_info=True) 201 217 202 218 def onViewLogCommand(self, evt): 203 logViewer. LogViewer().Show()219 logViewer.activate() 204 220 205 221 def onPythonConsoleCommand(self, evt): … … 280 296 self.Bind(wx.EVT_MENU, frame.onExitCommand, item) 281 297 282 self.Bind(wx.EVT_TASKBAR_RIGHT_ UP, self.onActivate)298 self.Bind(wx.EVT_TASKBAR_RIGHT_DOWN, self.onActivate) 283 299 284 300 def Destroy(self): … … 287 303 288 304 def onActivate(self, evt): 305 mainFrame.prePopup() 289 306 self.PopupMenu(self.menu) 290 # Showing and hiding our main frame seems to cause Windows to switch to the previous foreground window. 291 # If we don't do this and no dialog was displayed, the user will be dumped in the invisible system tray window, which is bad. 292 # It is even worse than expected because the user can close the system tray window, breaking the system tray icon. 293 # Even if a dialog is displayed, this does no harm. 294 mainFrame.Show() 295 mainFrame.Hide() 307 mainFrame.postPopup() 296 308 297 309 def initialize(app):

NVDA is supported by