Changeset 38:08f7e6592452 for src/mlx
- Timestamp:
- 03/04/12 09:35:01 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/gui.py
r36 r38 13 13 14 14 import time 15 import threading 16 import sys 15 17 16 18 acftTypes = [ ("Boeing 737-600", const.AIRCRAFT_B736), … … 43 45 self._flight = None 44 46 self._simulator = None 47 48 self._stdioLock = threading.Lock() 49 self._stdioText = "" 45 50 self._stdioAfterNewLine = True 51 52 self.toRestart = False 46 53 47 54 def build(self, iconDirectory): … … 84 91 """Run the GUI.""" 85 92 if self._config.autoUpdate: 86 self._updater = Updater(self._programDirectory, 93 self._updater = Updater(self, 94 self._programDirectory, 87 95 self._config.updateURL, 88 96 self._mainWindow) … … 185 193 self.showMainWindow() 186 194 195 def restart(self): 196 """Quit and restart the application.""" 197 self.toRestart = True 198 self._quit() 199 200 def flushStdIO(self): 201 """Flush any text to the standard error that could not be logged.""" 202 if self._stdioText: 203 sys.__stderr__.write(self._stdioText) 204 187 205 def writeStdIO(self, text): 188 206 """Write the given text into standard I/O log.""" 189 gobject.idle_add(self._writeStdIO, text) 190 191 def _writeStdIO(self, text): 207 with self._stdioLock: 208 self._stdioText += text 209 210 gobject.idle_add(self._writeStdIO) 211 212 def _writeStdIO(self): 192 213 """Perform the real writing.""" 214 with self._stdioLock: 215 text = self._stdioText 216 self._stdioText = "" 217 if not text: return 218 193 219 lines = text.splitlines() 194 220 if text[-1]=="\n": … … 335 361 self._quitButton.set_tooltip_text("Quit the program.") 336 362 337 self._quitButton.connect("clicked", gtk.main_quit)363 self._quitButton.connect("clicked", self._quit) 338 364 339 365 setupBox.pack_start(self._quitButton, False, False, 0) … … 660 686 self._logView.scroll_mark_onscreen(buffer.get_insert()) 661 687 688 def _quit(self, what = None): 689 """Quit from the application.""" 690 self._statusIcon.destroy() 691 return gtk.main_quit() 692 662 693 class TrackerStatusIcon(gtk.StatusIcon): 663 694 def __init__(self): -
src/mlx/gui/statusicon.py
r35 r38 83 83 self._showHideMenuItem.set_active(True) 84 84 85 def destroy(self): 86 """Hide and destroy the status icon.""" 87 if appIndicator: 88 if pygobject: 89 self._indicator.set_status(appindicator.IndicatorStatus.PASSIVE) 90 else: 91 self._indicator.set_status(appindicator.STATUS_PASSIVE) 92 else: 93 self._statusIcon.set_visible(False) 94 85 95 def _showHideToggled(self, menuitem): 86 96 """Called when the show/hide menu item is toggled.""" -
src/mlx/gui/update.py
r37 r38 5 5 from mlx.gui.common import * 6 6 7 from mlx.update import update , restart7 from mlx.update import update 8 8 9 9 import mlx.const as const … … 96 96 else gtk.WIN_POS_CENTER_ON_PARENT) 97 97 98 def __init__(self, programDirectory, updateURL, parentWindow):98 def __init__(self, gui, programDirectory, updateURL, parentWindow): 99 99 """Construct the updater. If not created yet, the windows used by the 100 100 updater are also created.""" 101 101 super(Updater, self).__init__() 102 103 self._gui = gui 102 104 103 105 self._programDirectory = programDirectory … … 280 282 self._progressWindow.hide() 281 283 if self._restart: 282 restart()284 self._gui.restart() 283 285 284 286 #------------------------------------------------------------------------------- -
src/mlx/mlx.py
r36 r38 7 7 import os 8 8 import sys 9 10 if os.name=="nt": 11 import win32api 9 12 10 13 #-------------------------------------------------------------------------------------- … … 28 31 config = Config() 29 32 gui = GUI(programDirectory, config) 30 33 31 34 sys.stdout = StdIOHandler(gui) 32 35 sys.stderr = StdIOHandler(gui) 33 36 34 gui.build(programDirectory) 37 try: 38 gui.build(programDirectory) 39 40 gui.run() 41 finally: 42 gui.flushStdIO() 43 sys.stdout = sys.__stdout__ 44 sys.stderr = sys.__stderr__ 35 45 36 gui.run() 46 if gui.toRestart: 47 programPath = os.path.join(os.path.dirname(sys.argv[0]), 48 "runmlx.exe" if os.name=="nt" else "runmlx.sh") 49 if os.name=="nt": 50 programPath = win32api.GetShortPathName(programPath) 51 52 os.execl(programPath, programPath) 37 53 38 54 #-------------------------------------------------------------------------------------- -
src/mlx/update.py
r37 r38 12 12 import subprocess 13 13 import hashlib 14 15 if os.name=="nt":16 import win32api17 14 18 15 #------------------------------------------------------------------------------ … … 501 498 #------------------------------------------------------------------------------ 502 499 503 def restart():504 """Restart the program."""505 programPath = os.path.join(os.path.dirname(sys.argv[0]),506 "runmlx.exe" if os.name=="nt" else "runmlx.sh")507 if os.name=="nt":508 programPath = win32api.GetShortPathName(programPath)509 os.execl(programPath, programPath)510 511 #------------------------------------------------------------------------------512 513 500 def updateProcess(): 514 501 """This is called in the child process, when we need a child process."""
Note:
See TracChangeset
for help on using the changeset viewer.