Ignore:
Timestamp:
02/25/12 15:49:27 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the status bar.

File:
1 edited

Legend:

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

    r31 r32  
    22
    33from statusicon import StatusIcon
     4from statusbar import Statusbar
    45from mlx.gui.common import *
    56
     
    1011import mlx.acft as acft
    1112
    12 import math
    1313import time
    1414
     
    6464        logFrame.set_border_width(8)
    6565        mainVBox.pack_start(logFrame, True, True, 0)
    66        
     66
     67        mainVBox.pack_start(gtk.HSeparator(), False, False, 0)
     68
     69        self._statusbar = Statusbar()
     70        mainVBox.pack_start(self._statusbar, False, False, 0)
     71
    6772        win.show_all()       
    6873
     
    8287        """Called when we have connected to the simulator."""
    8388        self._connected = True
    84         self._updateConnState()
    8589        self._logger.untimedMessage("Connected to the simulator %s" % (descriptor,))
     90        gobject.idle_add(self._statusbar.updateConnection,
     91                         self._connecting, self._connected)
    8692       
    8793    def disconnected(self):
    8894        """Called when we have disconnected from the simulator."""
    8995        self._connected = False
    90         self._updateConnState()
    9196        self._logger.untimedMessage("Disconnected from the simulator")
     97        gobject.idle_add(self._statusbar.updateConnection,
     98                         self._connecting, self._connected)
    9299
    93100    def write(self, msg):
     
    101108    def resetFlightStatus(self):
    102109        """Reset the status of the flight."""
     110        self._statusbar.resetFlightStatus()
    103111        self._statusIcon.resetFlightStatus()
    104112
     
    109117    def _setStage(self, stage):
    110118        """Set the stage of the flight."""
     119        self._statusbar.setStage(stage)
    111120        self._statusIcon.setStage(stage)
    112121
     
    117126    def _setRating(self, rating):
    118127        """Set the rating of the flight."""
     128        self._statusbar.setRating(rating)
    119129        self._statusIcon.setRating(rating)
    120130
     
    125135    def _setNoGo(self, reason):
    126136        """Set the rating of the flight."""
     137        self._statusbar.setNoGo(reason)
    127138        self._statusIcon.setNoGo(reason)
    128139
     
    156167            self.showMainWindow()
    157168           
    158     def _drawConnState(self, connStateArea, eventOrContext):
    159         """Draw the connection state."""
    160         context = eventOrContext if pygobject else connStateArea.window.cairo_create()
    161 
    162         if self._connecting:
    163             if self._connected:
    164                 context.set_source_rgb(0.0, 1.0, 0.0)
    165             else:
    166                 context.set_source_rgb(1.0, 0.0, 0.0)
    167         else:
    168             context.set_source_rgb(0.75, 0.75, 0.75)
    169 
    170         width = connStateArea.get_allocated_width() if pygobject \
    171                 else connStateArea.allocation.width
    172         height = connStateArea.get_allocated_height() if pygobject \
    173                  else connStateArea.allocation.height
    174         context.arc(width/2, height/2, 8, 0, 2*math.pi)
    175 
    176         context.fill()
    177 
    178     def _updateConnState(self):
    179         """Initiate the updating of the connection state icon."""
    180         self._connStateArea.queue_draw()
    181 
    182169    def _connectToggled(self, button):
    183170        """Callback for the connection button."""
     
    211198            self._flight = None
    212199
    213         self._updateConnState()
     200        self._statusbar.updateConnection(self._connecting, self._connected)
    214201
    215202    def _buildSetupFrame(self):
     
    299286
    300287        setupBox.pack_start(self._connectButton, False, False, 0)
    301 
    302         setupBox.pack_start(gtk.VSeparator(), False, False, 8)   
    303 
    304         self._connStateArea = gtk.DrawingArea()
    305         self._connStateArea.set_size_request(16, 16)
    306         self._connStateArea.set_tooltip_markup('The state of the connection.\n'
    307                                                '<span foreground="grey">Grey</span> means idle.\n'
    308                                                '<span foreground="red">Red</span> means trying to connect.\n'
    309                                                '<span foreground="green">Green</span> means connected.')
    310 
    311         if pygobject:
    312             self._connStateArea.connect("draw", self._drawConnState)
    313         else:
    314             self._connStateArea.connect("expose_event", self._drawConnState)
    315 
    316         alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5)
    317         alignment.add(self._connStateArea)
    318 
    319         setupBox.pack_start(alignment, False, False, 8)
    320288
    321289        setupBox.pack_start(gtk.VSeparator(), False, False, 8)   
Note: See TracChangeset for help on using the changeset viewer.