Changeset 32:46c1a12f72d1 for src/mlx/gui/gui.py
- Timestamp:
- 02/25/12 15:49:27 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/gui.py
r31 r32 2 2 3 3 from statusicon import StatusIcon 4 from statusbar import Statusbar 4 5 from mlx.gui.common import * 5 6 … … 10 11 import mlx.acft as acft 11 12 12 import math13 13 import time 14 14 … … 64 64 logFrame.set_border_width(8) 65 65 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 67 72 win.show_all() 68 73 … … 82 87 """Called when we have connected to the simulator.""" 83 88 self._connected = True 84 self._updateConnState()85 89 self._logger.untimedMessage("Connected to the simulator %s" % (descriptor,)) 90 gobject.idle_add(self._statusbar.updateConnection, 91 self._connecting, self._connected) 86 92 87 93 def disconnected(self): 88 94 """Called when we have disconnected from the simulator.""" 89 95 self._connected = False 90 self._updateConnState()91 96 self._logger.untimedMessage("Disconnected from the simulator") 97 gobject.idle_add(self._statusbar.updateConnection, 98 self._connecting, self._connected) 92 99 93 100 def write(self, msg): … … 101 108 def resetFlightStatus(self): 102 109 """Reset the status of the flight.""" 110 self._statusbar.resetFlightStatus() 103 111 self._statusIcon.resetFlightStatus() 104 112 … … 109 117 def _setStage(self, stage): 110 118 """Set the stage of the flight.""" 119 self._statusbar.setStage(stage) 111 120 self._statusIcon.setStage(stage) 112 121 … … 117 126 def _setRating(self, rating): 118 127 """Set the rating of the flight.""" 128 self._statusbar.setRating(rating) 119 129 self._statusIcon.setRating(rating) 120 130 … … 125 135 def _setNoGo(self, reason): 126 136 """Set the rating of the flight.""" 137 self._statusbar.setNoGo(reason) 127 138 self._statusIcon.setNoGo(reason) 128 139 … … 156 167 self.showMainWindow() 157 168 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.width172 height = connStateArea.get_allocated_height() if pygobject \173 else connStateArea.allocation.height174 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 182 169 def _connectToggled(self, button): 183 170 """Callback for the connection button.""" … … 211 198 self._flight = None 212 199 213 self._ updateConnState()200 self._statusbar.updateConnection(self._connecting, self._connected) 214 201 215 202 def _buildSetupFrame(self): … … 299 286 300 287 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)320 288 321 289 setupBox.pack_start(gtk.VSeparator(), False, False, 8)
Note:
See TracChangeset
for help on using the changeset viewer.