Changeset 91:c3fc045d7aeb


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

Reworked the GUI reset

Location:
src/mlx/gui
Files:
2 edited

Legend:

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

    r89 r91  
    17981798        self.nextPage()
    17991799
    1800     def connectionFailed(self):
    1801         """Called when the connection could not be made to the simulator."""
    1802         self._initialize()
    1803 
    1804     def disconnected(self):
    1805         """Called when we have disconnected from the simulator."""
     1800    def reset(self):
     1801        """Resets the wizard to go back to the login page."""
    18061802        self._initialize()
    18071803
  • src/mlx/gui/gui.py

    r90 r91  
    157157        gtk.main()
    158158
    159         if self._flight is not None and self._connected:
    160             self.stopMonitoring()
    161             self._flight.simulator.disconnect()                       
     159        self._disconnect()
    162160
    163161    def connected(self, fsType, descriptor):
     
    203201            self._simulator.reconnect()
    204202        else:
    205             self._connecting = False
    206             self._reconnecting = False
    207             self._statusbar.updateConnection(self._connecting, self._connected)
    208             self._wizard.connectionFailed()
    209             self._flightInfo.reset()
     203            self.reset()
    210204       
    211205    def disconnected(self):
     
    241235            self._simulator.reconnect()
    242236        else:
    243             self._connecting = False
    244             self._reconnecting = False
    245             self._statusbar.updateConnection(self._connecting, self._connected)
    246             self._wizard.disconnected()
    247             self._flightInfo.reset()
    248 
     237            self.reset()
     238
     239    def reset(self):
     240        """Reset the GUI."""
     241        self._disconnect()
     242        self._wizard.reset()
     243        self._flightInfo.reset()
     244        self.resetFlightStatus()
     245
     246    def _disconnect(self):
     247        """Disconnect from the simulator if connected."""
     248        if self._connected:
     249            self.stopMonitoring()
     250            self._flight.simulator.disconnect()
     251            self._connected = False
     252
     253        self._connecting = False
     254        self._reconnecting = False
     255        self._statusbar.updateConnection(False, False)
     256           
    249257    def write(self, msg):
    250258        """Write the given message to the log."""
     
    272280        self._wizard.setStage(stage)
    273281        if stage==const.STAGE_END:
    274             self.stopMonitoring()
    275             self.simulator.disconnect()
    276             self._connecting = False
    277             self._connected = False
    278             self._statusbar.updateConnection(self._connecting, self._connected)
     282            self._disconnect()
    279283
    280284    def setRating(self, rating):
Note: See TracChangeset for help on using the changeset viewer.