Index: src/mlx/gui/common.py
===================================================================
--- src/mlx/gui/common.py	(revision 302)
+++ src/mlx/gui/common.py	(revision 345)
@@ -297,5 +297,5 @@
     faultTag.set_property("foreground", "red")
     faultTag.set_property("weight", WEIGHT_BOLD)
-    buffer.get_tag_table().add(faultTag)    
+    buffer.get_tag_table().add(faultTag)
 
 #------------------------------------------------------------------------------
@@ -305,9 +305,16 @@
 
     If isFault is set, use the tag named 'fault'."""
+    insertTextBuffer(buffer, buffer.get_end_iter(), text, isFault)
+
+#------------------------------------------------------------------------------
+
+def insertTextBuffer(buffer, iter, text, isFault = False):
+    """Insert the given line into the given text buffer at the given iterator.
+
+    If isFault is set, use the tag named 'fault'."""
     if isFault:
-        buffer.insert_with_tags_by_name(buffer.get_end_iter(), text,
-                                        "fault")
+        buffer.insert_with_tags_by_name(iter, text, "fault")
     else:
-        buffer.insert(buffer.get_end_iter(), text)
-
-#------------------------------------------------------------------------------
+        buffer.insert(iter, text)
+
+#------------------------------------------------------------------------------
Index: src/mlx/gui/gui.py
===================================================================
--- src/mlx/gui/gui.py	(revision 304)
+++ src/mlx/gui/gui.py	(revision 345)
@@ -90,5 +90,5 @@
     def build(self, iconDirectory):
         """Build the GUI."""
-        
+
         self._mainWindow = window = gtk.Window()
         window.set_title(WINDOW_TITLE_BASE)
@@ -112,5 +112,5 @@
         self._notebook = gtk.Notebook()
         mainVBox.pack_start(self._notebook, True, True, 4)
-        
+
         self._wizard = Wizard(self)
         label = gtk.Label(xstr("tab_flight"))
@@ -131,7 +131,7 @@
         label.set_tooltip_text(xstr("tab_weight_help_tooltip"))
         self._notebook.append_page(self._weightHelp, label)
-        
+
         (logWidget, self._logView)  = self._buildLogWidget()
-        addFaultTag(self._logView.get_buffer())        
+        addFaultTag(self._logView.get_buffer())
         label = gtk.Label(xstr("tab_log"))
         label.set_use_underline(True)
@@ -144,5 +144,5 @@
         label.set_tooltip_text(xstr("tab_gates_tooltip"))
         self._notebook.append_page(self._fleetGateStatus, label)
-        
+
         (self._debugLogWidget, self._debugLogView) = self._buildLogWidget()
         self._debugLogWidget.show_all()
@@ -186,15 +186,15 @@
         """Get the main window of the GUI."""
         return self._mainWindow
-        
+
     @property
     def logger(self):
         """Get the logger used by us."""
         return self._logger
-        
+
     @property
     def simulator(self):
         """Get the simulator used by us."""
         return self._simulator
-        
+
     @property
     def flight(self):
@@ -211,5 +211,5 @@
         """Indicate if the user has logged in properly."""
         return self._wizard.loggedIn
-        
+
     @property
     def loginResult(self):
@@ -251,10 +251,10 @@
         """Get Zero-Fuel Weight calculated for the current flight."""
         return self._wizard.zfw
-        
+
     @property
     def filedCruiseAltitude(self):
         """Get cruise altitude filed for the current flight."""
         return self._wizard.filedCruiseAltitude
-        
+
     @property
     def cruiseAltitude(self):
@@ -271,5 +271,5 @@
         """Get the METAR of the deprature airport."""
         return self._wizard.departureMETAR
-        
+
     @property
     def arrivalMETAR(self):
@@ -281,5 +281,5 @@
         """Get the name of the departure runway."""
         return self._wizard.departureRunway
-        
+
     @property
     def sid(self):
@@ -291,15 +291,15 @@
         """Get the V1 speed calculated for the flight."""
         return self._wizard.v1
-        
+
     @property
     def vr(self):
         """Get the Vr speed calculated for the flight."""
         return self._wizard.vr
-        
+
     @property
     def v2(self):
         """Get the V2 speed calculated for the flight."""
         return self._wizard.v2
-        
+
     @property
     def arrivalRunway(self):
@@ -326,5 +326,5 @@
         """Get the Vref speed calculated for the flight."""
         return self._wizard.vref
-        
+
     @property
     def flightType(self):
@@ -360,5 +360,5 @@
                                     self._mainWindow)
             self._updater.start()
-        
+
         singleton.raiseCallback = self.raiseCallback
         gtk.main()
@@ -398,12 +398,12 @@
                                    type = MESSAGETYPE_ERROR,
                                    message_format = xstr("conn_failed"))
-    
+
         dialog.set_title(WINDOW_TITLE_BASE)
         dialog.format_secondary_markup(xstr("conn_failed_sec"))
-        
+
         dialog.add_button(xstr("button_cancel"), 0)
         dialog.add_button(xstr("button_tryagain"), 1)
         dialog.set_default_response(1)
-        
+
         result = dialog.run()
         dialog.hide()
@@ -413,5 +413,5 @@
         else:
             self.reset()
-        
+
     def disconnected(self):
         """Called when we have disconnected from the simulator."""
@@ -422,5 +422,5 @@
 
     def _disconnected(self):
-        """Called when we have disconnected from the simulator unexpectedly."""        
+        """Called when we have disconnected from the simulator unexpectedly."""
         self._statusbar.updateConnection(self._connecting, self._connected)
 
@@ -460,5 +460,5 @@
         result = dialog.run()
         dialog.hide()
-        
+
         if result==RESPONSETYPE_YES:
             self.reset()
@@ -507,23 +507,30 @@
 
         return True
-            
-    def addFlightLogLine(self, timeStr, line, isFault = False):
-        """Write the given message line to the log."""
-        gobject.idle_add(self._writeLog,
-                         formatFlightLogLine(timeStr, line),
-                         self._logView, isFault)
-
-    def updateFlightLogLine(self, index, timeStr, line):
-        """Update the line with the given index."""
-        gobject.idle_add(self._updateFlightLogLine, index,
-                         formatFlightLogLine(timeStr, line))
-
-    def _updateFlightLogLine(self, index, line):
-        """Replace the contents of the given line in the log."""
+
+    def insertFlightLogLine(self, index, timestampString, text, isFault):
+        """Insert the flight log line with the given data."""
+        gobject.idle_add(self._insertFlightLogLine, index,
+                         formatFlightLogLine(timestampString, text),
+                         isFault)
+
+    def _insertFlightLogLine(self, index, line, isFault):
+        """Perform the real insertion.
+
+        To be called from the event loop."""
+        buffer = self._logView.get_buffer()
+        lineIter = buffer.get_iter_at_line(index)
+        insertTextBuffer(buffer, lineIter, line, isFault = isFault)
+        self._logView.scroll_mark_onscreen(buffer.get_insert())
+
+    def removeFlightLogLine(self, index):
+        """Remove the flight log line with the given index."""
+        gobject.idle_add(self._removeFlightLogLine, index)
+
+    def _removeFlightLogLine(self, index):
+        """Perform the real removal."""
         buffer = self._logView.get_buffer()
         startIter = buffer.get_iter_at_line(index)
-        endIter = buffer.get_iter_at_line(index + 1)
+        endIter = buffer.get_iter_at_line(index+1)
         buffer.delete(startIter, endIter)
-        buffer.insert(startIter, line)
         self._logView.scroll_mark_onscreen(buffer.get_insert())
 
@@ -591,5 +598,5 @@
              (event.new_window_state&WINDOW_STATE_ICONIFIED)==0:
             self._mainWindow.present()
-            
+
     def raiseCallback(self):
         """Callback for the singleton handling code."""
@@ -630,5 +637,5 @@
             self._mainWindow.present()
         self._mainWindow.deiconify()
-            
+
     def toggleMainWindow(self):
         """Toggle the main window."""
@@ -679,5 +686,5 @@
         if self._stdioText:
             sys.__stderr__.write(self._stdioText)
-            
+
     def writeStdIO(self, text):
         """Write the given text into standard I/O log."""
@@ -758,5 +765,5 @@
         self._updatePlaneStatus = status
         self._updatePlaneGateNumber = gateNumber
-        
+
         self.webHandler.updatePlane(self._updatePlaneResultCallback,
                                     tailNumber, status, gateNumber)
@@ -799,5 +806,5 @@
             self._stdioText = ""
         if not text: return
-            
+
         lines = text.splitlines()
         if text[-1]=="\n":
@@ -809,5 +816,5 @@
         now = datetime.datetime.now()
         timeStr = "%02d:%02d:%02d: " % (now.hour, now.minute, now.second)
-            
+
         for line in lines:
             #print >> sys.__stdout__, line
@@ -833,10 +840,10 @@
         self._flight.aircraft = acft.Aircraft.create(self._flight)
         self._flight.aircraft._checkers.append(self)
-        
+
         if self._simulator is None:
             self._simulator = fs.createSimulator(const.SIM_MSFS9, self)
             fs.setupMessageSending(self.config, self._simulator)
             self._setupTimeSync()
-        
+
         self._flight.simulator = self._simulator
 
@@ -845,5 +852,5 @@
 
         self._connecting = True
-        self._simulator.connect(self._flight.aircraft)        
+        self._simulator.connect(self._flight.aircraft)
 
     def startMonitoring(self):
@@ -867,5 +874,5 @@
         """Build the main menu bar."""
         menuBar = gtk.MenuBar()
-        
+
         fileMenuItem = gtk.MenuItem(xstr("menu_file"))
         fileMenu = gtk.Menu()
@@ -965,5 +972,5 @@
 
         helpMenu.append(gtk.SeparatorMenuItem())
-        
+
         aboutMenuItem = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
         aboutMenuItem.set_use_stock(True)
@@ -982,5 +989,5 @@
             label = gtk.Label(xstr("tab_debug_log"))
             label.set_use_underline(True)
-            label.set_tooltip_text(xstr("tab_debug_log_tooltip"))        
+            label.set_tooltip_text(xstr("tab_debug_log_tooltip"))
             self._debugLogPage = self._notebook.append_page(self._debugLogWidget, label)
             self._notebook.set_current_page(self._debugLogPage)
@@ -1037,5 +1044,5 @@
             result = dialog.run()
             dialog.hide()
-        
+
         if result==RESPONSETYPE_YES:
             self._statusIcon.destroy()
@@ -1052,9 +1059,9 @@
         """Callback for editing the checklists."""
         self._checklistEditor.run()
-        
+
     def _editApproachCallouts(self, menuItem):
         """Callback for editing the approach callouts."""
         self._approachCalloutsEditor.run()
-        
+
     def _editPreferences(self, menuItem):
         """Callback for editing the preferences."""
@@ -1084,5 +1091,5 @@
             if pirepDirectory is not None:
                 dialog.set_current_folder(pirepDirectory)
-        
+
         result = dialog.run()
         dialog.hide()
@@ -1132,5 +1139,5 @@
                                            parent = self._mainWindow)
             dialog.set_modal(True)
-            
+
 
             filter = gtk.FileFilter()
@@ -1138,5 +1145,5 @@
             filter.add_pattern("*.pirep")
             dialog.add_filter(filter)
-            
+
             filter = gtk.FileFilter()
             filter.set_name(xstr("file_filter_all"))
@@ -1184,5 +1191,5 @@
         labelAlignment.add(label)
         table.attach(labelAlignment, 0, 1, 0, 1)
-        
+
         label = gtk.Label(bookedFlight.callsign)
         labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
@@ -1197,5 +1204,5 @@
         labelAlignment.add(label)
         table.attach(labelAlignment, 0, 1, 1, 2)
-        
+
         label = gtk.Label(str(bookedFlight.departureTime.date()))
         labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
@@ -1210,5 +1217,5 @@
         labelAlignment.add(label)
         table.attach(labelAlignment, 0, 1, 2, 3)
-        
+
         label = gtk.Label(bookedFlight.departureICAO)
         labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
@@ -1223,5 +1230,5 @@
         labelAlignment.add(label)
         table.attach(labelAlignment, 0, 1, 3, 4)
-        
+
         label = gtk.Label(bookedFlight.arrivalICAO)
         labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
@@ -1243,5 +1250,5 @@
         else:
             label.set_text("%.1f %%" % (rating,))
-        
+
         labelAlignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
                                        xscale = 0.0, yscale = 0.0)
@@ -1252,7 +1259,7 @@
         dialog.add_button(xstr("viewPIREP"), 1)
         dialog.add_button(xstr("sendPIREP"), RESPONSETYPE_OK)
-        
+
         return dialog
-                            
+
     def sendPIREP(self, pirep, callback = None):
         """Send the given PIREP."""
@@ -1287,5 +1294,5 @@
             messageFormat = xstr("sendPIREP_failed")
             secondaryMarkup = xstr("sendPIREP_failed_sec")
-        
+
         dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
                                    type = type, message_format = messageFormat)
@@ -1365,9 +1372,9 @@
             dialog.set_transient_for(self._mainWindow)
             dialog.set_modal(True)
-            
+
             logoPath = os.path.join(self._programDirectory, "logo.png")
             logo = pixbuf_new_from_file(logoPath)
             dialog.set_logo(logo)
-                                
+
             dialog.set_program_name(PROGRAM_NAME)
             dialog.set_version(const.VERSION)
@@ -1396,4 +1403,4 @@
 
     def _showAboutURL(self, dialog, link, user_data):
-        """Show the about URL."""        
+        """Show the about URL."""
         webbrowser.open(url = link, new = 1)
