Index: src/mlx/acft.py
===================================================================
--- src/mlx/acft.py	(revision 27)
+++ src/mlx/acft.py	(revision 29)
@@ -481,6 +481,6 @@
         This implementation checks the RPM values to be 0."""
         for rpm in aircraftState.rpm:
-            if rpm>0: return
-        self._setStage(aircraftState, const.STAGE_END)
+            if rpm>0: return False
+        return True
 
     def logFuel(self, aircraftState):
Index: src/mlx/flight.py
===================================================================
--- src/mlx/flight.py	(revision 27)
+++ src/mlx/flight.py	(revision 29)
@@ -23,8 +23,9 @@
     It is also the hub for the other main objects participating in the handling of
     the flight."""
-    def __init__(self, logger):
+    def __init__(self, logger, gui):
         """Construct the flight."""
         self._stage = None
         self.logger = logger
+        self._gui = gui
 
         self.cruiseAltitude = None
Index: src/mlx/gui/common.py
===================================================================
--- src/mlx/gui/common.py	(revision 28)
+++ src/mlx/gui/common.py	(revision 29)
@@ -9,4 +9,5 @@
     pygobject = False
     import pygtk
+    import gtk.gdk as gdk
     import gtk
     import gobject
@@ -19,4 +20,5 @@
     print "Using PyGObject"
     pygobject = True
+    from gi.repository import Gdk as gdk
     from gi.repository import Gtk as gtk
     from gi.repository import GObject as gobject
Index: src/mlx/gui/gui.py
===================================================================
--- src/mlx/gui/gui.py	(revision 28)
+++ src/mlx/gui/gui.py	(revision 29)
@@ -1,5 +1,6 @@
 # The main file for the GUI
 
-from common import *
+from statusicon import StatusIcon
+from mlx.gui.common import *
 
 import mlx.const as const
@@ -32,5 +33,4 @@
     def __init__(self):
         """Construct the GUI."""
-
         gobject.threads_init()
 
@@ -41,10 +41,12 @@
         self._simulator = None
 
-    def build(self):
+    def build(self, iconDirectory):
         """Build the GUI."""
+        
         win = gtk.Window()
         win.set_title("MAVA Logger X " + const.VERSION)
         win.set_icon_from_file("logo.ico")
-        win.connect("delete-event", gtk.main_quit)
+        win.connect("delete-event", lambda a, b: self.hideMainWindow())
+        win.connect("window-state-event", self._handleMainWindowState)
 
         mainVBox = gtk.VBox()
@@ -62,6 +64,10 @@
         logFrame.set_border_width(8)
         mainVBox.pack_start(logFrame, True, True, 0)
-
+        
         win.show_all()        
+
+        self._mainWindow = win
+
+        self._statusIcon = StatusIcon(iconDirectory, self)
 
     def run(self):
@@ -93,4 +99,33 @@
         gobject.idle_add(self._setData, state)
 
+    def _handleMainWindowState(self, window, event):
+        """Hande a change in the state of the window"""
+        iconified = gdk.WindowState.ICONIFIED if pygobject \
+                    else gdk.WINDOW_STATE_ICONIFIED
+        if (event.changed_mask&iconified)!=0 and (event.new_window_state&iconified)!=0:
+            self.hideMainWindow()
+
+    def hideMainWindow(self):
+        """Hide the main window and save its position."""
+        (self._mainWindowX, self._mainWindowY) = \
+            self._mainWindow.get_window().get_root_origin()
+        self._mainWindow.hide()
+        self._statusIcon.mainWindowHidden()
+        return True
+
+    def showMainWindow(self):
+        """Show the main window at its former position."""
+        self._mainWindow.move(self._mainWindowX, self._mainWindowY)
+        self._mainWindow.deiconify()
+        self._mainWindow.show()
+        self._statusIcon.mainWindowShown()
+
+    def toggleMainWindow(self):
+        """Toggle the main window."""
+        if self._mainWindow.get_visible():
+            self.hideMainWindow()
+        else:
+            self.showMainWindow()
+            
     def _drawConnState(self, connStateArea, eventOrContext):
         """Draw the connection state."""
@@ -254,4 +289,13 @@
 
         setupBox.pack_start(alignment, False, False, 8)
+
+        setupBox.pack_start(gtk.VSeparator(), False, False, 8)    
+
+        self._quitButton = gtk.Button(label = "Quit")
+        self._quitButton.set_tooltip_text("Quit the program.")
+        
+        self._quitButton.connect("clicked", gtk.main_quit)
+
+        setupBox.pack_start(self._quitButton, False, False, 0)
 
         return setupFrame
Index: src/mlx/gui/statusicon.py
===================================================================
--- src/mlx/gui/statusicon.py	(revision 29)
+++ src/mlx/gui/statusicon.py	(revision 29)
@@ -0,0 +1,69 @@
+# Implementation of the status icon
+
+#-------------------------------------------------------------------------------
+
+from common import *
+
+#-------------------------------------------------------------------------------
+
+class StatusIcon(object):
+    """The class handling the status icon."""
+    def __init__(self, iconDirectory, gui):
+        """Construct the status icon."""
+        self._gui = gui
+        
+        menu = gtk.Menu()
+
+        self._showHideMenuItem = gtk.CheckMenuItem()  
+        self._showHideMenuItem.set_label("Show main window")  
+        self._showHideMenuItem.set_active(True)
+        self._showHideMenuItem.connect("toggled", self._showHideToggled)
+        self._showHideMenuItem.show()  
+        menu.append(self._showHideMenuItem)  
+
+        menu.show()  
+
+        iconFile = os.path.join(iconDirectory, "logo.ico")
+
+        if appIndicator:
+            if pygobject:
+                indicator = appindicator.Indicator.new ("mava-logger-x", iconFile,
+                                                        appindicator.IndicatorCategory.APPLICATION_STATUS)
+                indicator.set_status (appindicator.IndicatorStatus.ACTIVE)
+            else:
+                indicator = appindicator.Indicator ("mava-logger-x", iconFile,
+                                                    appindicator.CATEGORY_APPLICATION_STATUS)
+                indicator.set_status (appindicator.STATUS_ACTIVE)
+
+            indicator.set_menu(menu)
+            self._indicator = indicator
+            self._usingIndicator = True
+        else:
+            def popup_menu(status, button, time):
+                menu.popup(None, None, gtk.status_icon_position_menu,
+                           button, time, status)
+
+            statusIcon = gtk.StatusIcon()
+            statusIcon.set_from_file(iconFile)
+            statusIcon.set_tooltip_markup("MAVA Logger X")
+            statusIcon.set_visible(True)
+            statusIcon.connect('popup-menu', popup_menu)
+            statusIcon.connect('activate',
+                               lambda status: self._gui.toggleMainWindow())
+            self._statusIcon = statusIcon
+            self._usingIndicator = False
+
+    def mainWindowHidden(self):
+        """Called when the main window is hidden."""
+        self._showHideMenuItem.set_active(False)
+
+    def mainWindowShown(self):
+        """Called when the main window is shown."""
+        self._showHideMenuItem.set_active(True)
+        
+    def _showHideToggled(self, menuitem):
+        """Called when the show/hide menu item is toggled."""
+        if self._showHideMenuItem.get_active():
+            self._gui.showMainWindow()
+        else:
+            self._gui.hideMainWindow()
Index: src/mlx/mlx.py
===================================================================
--- src/mlx/mlx.py	(revision 28)
+++ src/mlx/mlx.py	(revision 29)
@@ -2,47 +2,18 @@
 
 from .gui.gui import GUI
+from .gui.common import *
 
-def main():
+import os
+
+def main(iconDirectory):
     """The main operation of the program."""
-    # menu = gtk.Menu()  
-    # item = gtk.MenuItem()  
-    # item.set_label("Menu Item")  
-    # item.show()  
-    # menu.append(item)  
+    gui = GUI()
 
-    # menu.show()  
+    gui.build(iconDirectory)
 
-    # if appIndicator:
-    #     if pygobject:
-    #         ind = appindicator.Indicator.new ("mava-logger-x",
-    #                                           "/home/vi/munka/repules/mlx/src/logo.ico",
-    #                                           #"indicator-messages",
-    #                                           appindicator.IndicatorCategory.APPLICATION_STATUS)
-    #         ind.set_status (appindicator.IndicatorStatus.ACTIVE)
-    #     else:
-    #         ind = appindicator.Indicator ("mava-logger-x",
-    #                                       "/home/vi/munka/repules/mlx/src/logo.ico",
-    #                                       appindicator.CATEGORY_APPLICATION_STATUS)
-    #         ind.set_status (appindicator.STATUS_ACTIVE)
-
-    #     ind.set_menu(menu)
-    #     #ind.set_icon("distributor-logo")
-    # else:
-    #     def popup_menu(status, button, time):
-    #         menu.popup(None, None, gtk.status_icon_position_menu,
-    #                    button, time, status)
-    #     statusIcon = gtk.StatusIcon()
-    #     #statusIcon.set_from_stock(gtk.STOCK_FIND)
-    #     statusIcon.set_from_file("logo.ico")
-    #     statusIcon.set_tooltip_markup("MAVA Logger X")
-    #     statusIcon.set_visible(True)
-    #     statusIcon.connect('popup-menu', popup_menu)
-
-    gui = GUI()
-    gui.build()
     gui.run()
 
 if __name__ == "__main__":
-    main()
+    main(os.path.dirname(__file__))
 
 
