Ignore:
Timestamp:
03/04/12 09:35:01 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

The status icon is now hidden properly when the program quits, and made restarting nicer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/gui.py

    r36 r38  
    1313
    1414import time
     15import threading
     16import sys
    1517
    1618acftTypes = [ ("Boeing 737-600", const.AIRCRAFT_B736),
     
    4345        self._flight = None
    4446        self._simulator = None
     47
     48        self._stdioLock = threading.Lock()
     49        self._stdioText = ""
    4550        self._stdioAfterNewLine = True
     51
     52        self.toRestart = False
    4653
    4754    def build(self, iconDirectory):
     
    8491        """Run the GUI."""
    8592        if self._config.autoUpdate:
    86             self._updater = Updater(self._programDirectory,
     93            self._updater = Updater(self,
     94                                    self._programDirectory,
    8795                                    self._config.updateURL,
    8896                                    self._mainWindow)
     
    185193            self.showMainWindow()
    186194
     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           
    187205    def writeStdIO(self, text):
    188206        """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):
    192213        """Perform the real writing."""
     214        with self._stdioLock:
     215            text = self._stdioText
     216            self._stdioText = ""
     217        if not text: return
     218           
    193219        lines = text.splitlines()
    194220        if text[-1]=="\n":
     
    335361        self._quitButton.set_tooltip_text("Quit the program.")
    336362       
    337         self._quitButton.connect("clicked", gtk.main_quit)
     363        self._quitButton.connect("clicked", self._quit)
    338364
    339365        setupBox.pack_start(self._quitButton, False, False, 0)
     
    660686        self._logView.scroll_mark_onscreen(buffer.get_insert())
    661687
     688    def _quit(self, what = None):
     689        """Quit from the application."""
     690        self._statusIcon.destroy()
     691        return gtk.main_quit()
     692
    662693class TrackerStatusIcon(gtk.StatusIcon):
    663694        def __init__(self):
Note: See TracChangeset for help on using the changeset viewer.