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

Update seems to work

Location:
src/mlx/gui
Files:
1 added
1 edited

Legend:

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

    r35 r36  
    33from statusicon import StatusIcon
    44from statusbar import Statusbar
     5from update import Updater
    56from mlx.gui.common import *
    67
     
    3132class GUI(fs.ConnectionListener):
    3233    """The main GUI class."""
    33     def __init__(self):
     34    def __init__(self, programDirectory, config):
    3435        """Construct the GUI."""
    3536        gobject.threads_init()
    3637
     38        self._programDirectory = programDirectory
     39        self._config = config
    3740        self._connecting = False
    3841        self._connected = False
     
    4043        self._flight = None
    4144        self._simulator = None
     45        self._stdioAfterNewLine = True
    4246
    4347    def build(self, iconDirectory):
    4448        """Build the GUI."""
    4549       
    46         win = gtk.Window()
    47         win.set_title("MAVA Logger X " + const.VERSION)
    48         win.set_icon_from_file("logo.ico")
    49         win.connect("delete-event",
    50                     lambda a, b: self.hideMainWindow())
    51         win.connect("window-state-event", self._handleMainWindowState)
     50        window = gtk.Window()
     51        window.set_title("MAVA Logger X " + const.VERSION)
     52        window.set_icon_from_file(os.path.join(iconDirectory, "logo.ico"))
     53        window.connect("delete-event",
     54                       lambda a, b: self.hideMainWindow())
     55        window.connect("window-state-event", self._handleMainWindowState)
    5256
    5357        mainVBox = gtk.VBox()
    54         win.add(mainVBox)
     58        window.add(mainVBox)
    5559
    5660        setupFrame = self._buildSetupFrame()
     
    7175        mainVBox.pack_start(self._statusbar, False, False, 0)
    7276
    73         win.show_all()       
    74 
    75         self._mainWindow = win
     77        window.show_all()       
     78
     79        self._mainWindow = window
    7680
    7781        self._statusIcon = StatusIcon(iconDirectory, self)
     
    7983    def run(self):
    8084        """Run the GUI."""
     85        if self._config.autoUpdate:
     86            self._updater = Updater(self._programDirectory,
     87                                    self._config.updateURL,
     88                                    self._mainWindow)
     89            self._updater.start()
     90
    8191        gtk.main()
     92
    8293        if self._flight is not None:
    8394            simulator = self._flight.simulator
     
    173184        else:
    174185            self.showMainWindow()
     186
     187    def writeStdIO(self, text):
     188        """Write the given text into standard I/O log."""
     189        gobject.idle_add(self._writeStdIO, text)
     190
     191    def _writeStdIO(self, text):
     192        """Perform the real writing."""
     193        lines = text.splitlines()
     194        if text[-1]=="\n":
     195            text = ""
     196        else:
     197            text = lines[-1]
     198            lines = lines[:-1]
     199           
     200        for line in lines:
     201            if self._stdioAfterNewLine:
     202                line = "[STDIO] " + line
     203            self._writeLog(line + "\n")
     204            self._stdioAfterNewLine = True
     205
     206        if text:
     207            if self._stdioAfterNewLine:
     208                text = "[STDIO] " + text
     209            self._writeLog(text)
     210            self._stdioAfterNewLine = False
    175211           
    176212    def _connectToggled(self, button):
Note: See TracChangeset for help on using the changeset viewer.