Changeset 28:66fcd9294ab0
- Timestamp:
- 02/25/12 10:46:38 (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 4 added
- 5 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
MANIFEST.in
r27 r28 3 3 include license.txt 4 4 include runmlx.py 5 include logo.ico 6 include logo_uninst.ico -
mlx.nsi
r27 r28 33 33 ;Interface Settings 34 34 35 !define MUI_ICON " src/mlx/logo.ico"36 !define MUI_UNICON " src/mlx/logo_uninst.ico"35 !define MUI_ICON "logo.ico" 36 !define MUI_UNICON "logo_uninst.ico" 37 37 !define MUI_ABORTWARNING 38 38 -
setup.py
r27 r28 14 14 import py2exe 15 15 16 data_files.append(("", [" src/mlx/logo.ico"]))16 data_files.append(("", ["logo.ico"])) 17 17 18 18 msvcrDir = os.environ["MSVCRDIR"] if "MSVCRDIR" in os.environ else None … … 46 46 url = "http://mlx.varadiistvan.hu", 47 47 package_dir = { "" : "src" }, 48 packages = ["mlx"], 49 package_data = { "mlx" : ["logo.ico", "logo_uninst.ico"] }, 48 packages = ["mlx", "mlx.gui"], 50 49 requires = ["pyuipc"], 51 50 windows = [{ "script" : "runmlx.py", 52 "icon_resources" : [(1, " src/mlx/logo.ico")]}],51 "icon_resources" : [(1, "logo.ico")]}], 53 52 options = { "py2exe" : { "includes": "gio, pango, atk, pangocairo"} }, 54 53 data_files = data_files, -
src/mlx/const.py
r27 r28 4 4 5 5 # The version of the program 6 VERSION="0.00 1"6 VERSION="0.002" 7 7 8 8 #------------------------------------------------------------------------------- -
src/mlx/mlx.py
r27 r28 1 1 # The main program 2 2 3 import const 4 import fs 5 import flight 6 import logger 7 import acft 8 import sys 9 10 import os 11 import math 12 import time 13 14 appIndicator = False 15 16 if os.name=="nt" or "FORCE_PYGTK" in os.environ: 17 print "Using PyGTK" 18 pygobject = False 19 import pygtk 20 import gtk 21 import gobject 22 try: 23 import appindicator 24 appIndicator = True 25 except Exception, e: 26 pass 27 else: 28 print "Using PyGObject" 29 pygobject = True 30 from gi.repository import Gtk as gtk 31 from gi.repository import GObject as gobject 32 from gi.repository import AppIndicator3 as appindicator 33 appIndicator = True 34 35 import cairo 36 37 acftTypes = [ ("Boeing 737-600", const.AIRCRAFT_B736), 38 ("Boeing 737-700", const.AIRCRAFT_B737), 39 ("Boeing 737-800", const.AIRCRAFT_B738), 40 ("Bombardier Dash 8-Q400", const.AIRCRAFT_DH8D), 41 ("Boeing 737-300", const.AIRCRAFT_B733), 42 ("Boeing 737-400", const.AIRCRAFT_B734), 43 ("Boeing 737-500", const.AIRCRAFT_B735), 44 ("Boeing 767-200", const.AIRCRAFT_B762), 45 ("Boeing 767-300", const.AIRCRAFT_B763), 46 ("Bombardier CRJ200", const.AIRCRAFT_CRJ2), 47 ("Fokker 70", const.AIRCRAFT_F70), 48 ("Lisunov Li-2", const.AIRCRAFT_DC3), 49 ("Tupolev Tu-134", const.AIRCRAFT_T134), 50 ("Tupolev Tu-154", const.AIRCRAFT_T154), 51 ("Yakovlev Yak-40", const.AIRCRAFT_YK40) ] 52 53 class GUI(fs.ConnectionListener): 54 """The main GUI class.""" 55 def __init__(self): 56 """Construct the GUI.""" 57 self._connecting = False 58 self._connected = False 59 self._logger = logger.Logger(output = self) 60 self._flight = None 61 self._simulator = None 62 63 def build(self): 64 """Build the GUI.""" 65 win = gtk.Window() 66 win.set_title("MAVA Logger X " + const.VERSION) 67 win.set_icon_from_file("logo.ico") 68 win.connect("delete-event", gtk.main_quit) 69 70 mainVBox = gtk.VBox() 71 win.add(mainVBox) 72 73 setupFrame = self._buildSetupFrame() 74 setupFrame.set_border_width(8) 75 mainVBox.pack_start(setupFrame, False, False, 0) 76 77 dataFrame = self._buildDataFrame() 78 dataFrame.set_border_width(8) 79 mainVBox.pack_start(dataFrame, False, False, 0) 80 81 logFrame = self._buildLogFrame() 82 logFrame.set_border_width(8) 83 mainVBox.pack_start(logFrame, True, True, 0) 84 85 win.show_all() 86 87 def run(self): 88 """Run the GUI.""" 89 gtk.main() 90 if self._flight is not None: 91 simulator = self._flight.simulator 92 simulator.stopMonitoring() 93 simulator.disconnect() 94 95 def connected(self, fsType, descriptor): 96 """Called when we have connected to the simulator.""" 97 self._connected = True 98 self._updateConnState() 99 self._logger.untimedMessage("Connected to the simulator %s" % (descriptor,)) 100 101 def disconnected(self): 102 """Called when we have disconnected from the simulator.""" 103 self._connected = False 104 self._updateConnState() 105 self._logger.untimedMessage("Disconnected from the simulator") 106 107 def write(self, msg): 108 """Write the given message to the log.""" 109 gobject.idle_add(self._writeLog, msg) 110 111 def check(self, flight, aircraft, logger, oldState, state): 112 """Update the data.""" 113 gobject.idle_add(self._setData, state) 114 115 def _drawConnState(self, connStateArea, eventOrContext): 116 """Draw the connection state.""" 117 context = eventOrContext if pygobject else connStateArea.window.cairo_create() 118 119 if self._connecting: 120 if self._connected: 121 context.set_source_rgb(0.0, 1.0, 0.0) 122 else: 123 context.set_source_rgb(1.0, 0.0, 0.0) 124 else: 125 context.set_source_rgb(0.75, 0.75, 0.75) 126 127 width = connStateArea.get_allocated_width() if pygobject \ 128 else connStateArea.allocation.width 129 height = connStateArea.get_allocated_height() if pygobject \ 130 else connStateArea.allocation.height 131 context.arc(width/2, height/2, 8, 0, 2*math.pi) 132 133 context.fill() 134 135 def _updateConnState(self): 136 """Initiate the updating of the connection state icon.""" 137 self._connStateArea.queue_draw() 138 139 def _connectToggled(self, button): 140 """Callback for the connection button.""" 141 if self._connectButton.get_active(): 142 self._logger.reset() 143 self._flight = flight.Flight(self._logger) 144 145 acftListModel = self._acftList.get_model() 146 self._flight.aircraftType = \ 147 acftListModel[self._acftList.get_active()][1] 148 self._flight.aircraft = acft.Aircraft.create(self._flight) 149 self._flight.aircraft._checkers.append(self) 150 151 self._flight.cruiseAltitude = self._flSpinButton.get_value_as_int() * 100 152 153 self._flight.zfw = self._zfwSpinButton.get_value_as_int() 154 155 if self._simulator is None: 156 self._simulator = fs.createSimulator(const.SIM_MSFS9, self) 157 158 self._flight.simulator = self._simulator 159 160 self._connecting = True 161 self._simulator.connect(self._flight.aircraft) 162 self._simulator.startMonitoring() 163 else: 164 self._connecting = False 165 self._simulator.stopMonitoring() 166 self._simulator.disconnect() 167 self._flight = None 168 169 self._updateConnState() 170 171 def _buildSetupFrame(self): 172 """Build the setup frame.""" 173 setupFrame = gtk.Frame(label = "Setup") 174 175 frameAlignment = gtk.Alignment(xalign = 0.5) 176 177 frameAlignment.set_padding(padding_top = 4, padding_bottom = 10, 178 padding_left = 16, padding_right = 16) 179 180 setupFrame.add(frameAlignment) 181 182 setupBox = gtk.HBox() 183 frameAlignment.add(setupBox) 184 185 # self._fs9Button = gtk.RadioButton(label = "FS9") 186 # self._fs9Button.set_tooltip_text("Use MS Flight Simulator 2004") 187 # setupBox.pack_start(self._fs9Button, False, False, 0) 188 189 # self._fsxButton = gtk.RadioButton(group = self._fs9Button, label = "FSX") 190 # self._fsxButton.set_tooltip_text("Use MS Flight Simulator X") 191 # setupBox.pack_start(self._fsxButton, False, False, 0) 192 193 # setupBox.pack_start(gtk.VSeparator(), False, False, 8) 194 195 alignment = gtk.Alignment(yalign = 0.5) 196 alignment.set_padding(padding_top = 0, padding_bottom = 0, 197 padding_left = 0, padding_right = 16) 198 alignment.add(gtk.Label("Aicraft:")) 199 setupBox.pack_start(alignment, False, False, 0) 200 201 acftListModel = gtk.ListStore(str, int) 202 for (name, type) in acftTypes: 203 acftListModel.append([name, type]) 204 205 self._acftList = gtk.ComboBox(model = acftListModel) 206 renderer_text = gtk.CellRendererText() 207 self._acftList.pack_start(renderer_text, True) 208 self._acftList.add_attribute(renderer_text, "text", 0) 209 self._acftList.set_active(0) 210 self._acftList.set_tooltip_text("Select the type of the aircraft used for the flight.") 211 212 setupBox.pack_start(self._acftList, True, True, 0) 213 214 setupBox.pack_start(gtk.VSeparator(), False, False, 8) 215 216 alignment = gtk.Alignment(yalign = 0.5) 217 alignment.set_padding(padding_top = 0, padding_bottom = 0, 218 padding_left = 0, padding_right = 16) 219 alignment.add(gtk.Label("Cruise FL:")) 220 setupBox.pack_start(alignment, False, False, 0) 221 222 self._flSpinButton = gtk.SpinButton() 223 self._flSpinButton.set_increments(step = 10, page = 100) 224 self._flSpinButton.set_range(min = 0, max = 500) 225 self._flSpinButton.set_value(240) 226 self._flSpinButton.set_tooltip_text("The cruise flight level.") 227 self._flSpinButton.set_numeric(True) 228 229 setupBox.pack_start(self._flSpinButton, False, False, 0) 230 231 setupBox.pack_start(gtk.VSeparator(), False, False, 8) 232 233 alignment = gtk.Alignment(yalign = 0.5) 234 alignment.set_padding(padding_top = 0, padding_bottom = 0, 235 padding_left = 0, padding_right = 16) 236 alignment.add(gtk.Label("ZFW:")) 237 setupBox.pack_start(alignment, False, False, 0) 238 239 self._zfwSpinButton = gtk.SpinButton() 240 self._zfwSpinButton.set_increments(step = 100, page = 1000) 241 self._zfwSpinButton.set_range(min = 0, max = 500000) 242 self._zfwSpinButton.set_value(50000) 243 self._zfwSpinButton.set_tooltip_text("The Zero Fuel Weight for the flight in kgs") 244 self._zfwSpinButton.set_numeric(True) 245 246 setupBox.pack_start(self._zfwSpinButton, False, False, 0) 247 248 setupBox.pack_start(gtk.VSeparator(), False, False, 8) 249 250 self._connectButton = gtk.ToggleButton(label = "Connect") 251 self._connectButton.set_tooltip_text("Push to connect to Flight Simulator and start a new flight.\n" 252 "Push again to disconnect from FS.") 253 254 self._connectButton.connect("toggled", self._connectToggled) 255 256 setupBox.pack_start(self._connectButton, False, False, 0) 257 258 setupBox.pack_start(gtk.VSeparator(), False, False, 8) 259 260 self._connStateArea = gtk.DrawingArea() 261 self._connStateArea.set_size_request(16, 16) 262 self._connStateArea.set_tooltip_markup('The state of the connection.\n' 263 '<span foreground="grey">Grey</span> means idle.\n' 264 '<span foreground="red">Red</span> means trying to connect.\n' 265 '<span foreground="green">Green</span> means connected.') 266 267 if pygobject: 268 self._connStateArea.connect("draw", self._drawConnState) 269 else: 270 self._connStateArea.connect("expose_event", self._drawConnState) 271 272 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5) 273 alignment.add(self._connStateArea) 274 275 setupBox.pack_start(alignment, False, False, 8) 276 277 return setupFrame 278 279 def _createLabeledEntry(self, label, width = 8, xalign = 1.0): 280 """Create a labeled entry. 281 282 Return a tuple consisting of: 283 - the box 284 - the entry.""" 285 286 alignment = gtk.Alignment(xalign = 1.0, yalign = 0.5, xscale = 1.0) 287 alignment.set_padding(padding_top = 0, padding_bottom = 0, 288 padding_left = 0, padding_right = 16) 289 alignment.add(gtk.Label(label)) 290 291 entry = gtk.Entry() 292 entry.set_editable(False) 293 entry.set_width_chars(width) 294 entry.set_max_length(width) 295 entry.set_alignment(xalign) 296 297 return (alignment, entry) 298 299 def _buildDataFrame(self): 300 """Build the frame for the data.""" 301 dataFrame = gtk.Frame(label = "Data") 302 303 frameAlignment = gtk.Alignment(xscale = 1.0, yscale = 1.0) 304 305 frameAlignment.set_padding(padding_top = 4, padding_bottom = 10, 306 padding_left = 16, padding_right = 16) 307 308 table = gtk.Table(rows = 7, columns = 12) 309 table.set_homogeneous(False) 310 table.set_row_spacings(4) 311 table.set_col_spacings(8) 312 313 (label, self._timestamp) = self._createLabeledEntry("Time:") 314 table.attach(label, 0, 1, 0, 1) 315 table.attach(self._timestamp, 1, 2, 0, 1) 316 317 self._paused = gtk.Label("PAUSED") 318 table.attach(self._paused, 2, 4, 0, 1) 319 320 self._trickMode = gtk.Label("TRICKMODE") 321 table.attach(self._trickMode, 4, 6, 0, 1, xoptions = 0) 322 323 self._overspeed = gtk.Label("OVERSPEED") 324 table.attach(self._overspeed, 6, 8, 0, 1) 325 326 self._stalled = gtk.Label("STALLED") 327 table.attach(self._stalled, 8, 10, 0, 1) 328 329 self._onTheGround = gtk.Label("ONTHEGROUND") 330 table.attach(self._onTheGround, 10, 12, 0, 1) 331 332 (label, self._zfw) = self._createLabeledEntry("ZFW:", 6) 333 table.attach(label, 0, 1, 1, 2) 334 table.attach(self._zfw, 1, 2, 1, 2) 335 336 (label, self._grossWeight) = self._createLabeledEntry("Weight:", 6) 337 table.attach(label, 2, 3, 1, 2) 338 table.attach(self._grossWeight, 3, 4, 1, 2) 339 340 (label, self._heading) = self._createLabeledEntry("Heading:", 3) 341 table.attach(label, 4, 5, 1, 2) 342 table.attach(self._heading, 5, 6, 1, 2) 343 344 (label, self._pitch) = self._createLabeledEntry("Pitch:", 3) 345 table.attach(label, 6, 7, 1, 2) 346 table.attach(self._pitch, 7, 8, 1, 2) 347 348 (label, self._bank) = self._createLabeledEntry("Bank:", 3) 349 table.attach(label, 8, 9, 1, 2) 350 table.attach(self._bank, 9, 10, 1, 2) 351 352 (label, self._vs) = self._createLabeledEntry("VS:", 5) 353 table.attach(label, 10, 11, 1, 2) 354 table.attach(self._vs, 11, 12, 1, 2) 355 356 (label, self._ias) = self._createLabeledEntry("IAS:", 4) 357 table.attach(label, 0, 1, 2, 3) 358 table.attach(self._ias, 1, 2, 2, 3) 359 360 (label, self._mach) = self._createLabeledEntry("Mach:", 4) 361 table.attach(label, 2, 3, 2, 3) 362 table.attach(self._mach, 3, 4, 2, 3) 363 364 (label, self._groundSpeed) = self._createLabeledEntry("GS:", 4) 365 table.attach(label, 4, 5, 2, 3) 366 table.attach(self._groundSpeed, 5, 6, 2, 3) 367 368 (label, self._radioAltitude) = self._createLabeledEntry("Radio alt.:", 6) 369 table.attach(label, 6, 7, 2, 3) 370 table.attach(self._radioAltitude, 7, 8, 2, 3) 371 372 (label, self._altitude) = self._createLabeledEntry("Altitude:", 6) 373 table.attach(label, 8, 9, 2, 3) 374 table.attach(self._altitude, 9, 10, 2, 3) 375 376 (label, self._gLoad) = self._createLabeledEntry("G-Load:", 4) 377 table.attach(label, 10, 11, 2, 3) 378 table.attach(self._gLoad, 11, 12, 2, 3) 379 380 (label, self._flapsSet) = self._createLabeledEntry("Flaps set:", 2) 381 table.attach(label, 0, 1, 3, 4) 382 table.attach(self._flapsSet, 1, 2, 3, 4) 383 384 (label, self._flaps) = self._createLabeledEntry("Flaps:", 2) 385 table.attach(label, 2, 3, 3, 4) 386 table.attach(self._flaps, 3, 4, 3, 4) 387 388 (label, self._altimeter) = self._createLabeledEntry("Altimeter:", 4) 389 table.attach(label, 4, 5, 3, 4) 390 table.attach(self._altimeter, 5, 6, 3, 4) 391 392 (label, self._squawk) = self._createLabeledEntry("Squawk:", 4) 393 table.attach(label, 6, 7, 3, 4) 394 table.attach(self._squawk, 7, 8, 3, 4) 395 396 (label, self._nav1) = self._createLabeledEntry("NAV1:", 5) 397 table.attach(label, 8, 9, 3, 4) 398 table.attach(self._nav1, 9, 10, 3, 4) 399 400 (label, self._nav2) = self._createLabeledEntry("NAV2:", 5) 401 table.attach(label, 10, 11, 3, 4) 402 table.attach(self._nav2, 11, 12, 3, 4) 403 404 (label, self._fuel) = self._createLabeledEntry("Fuel:", 40, xalign = 0.0) 405 table.attach(label, 0, 1, 4, 5) 406 table.attach(self._fuel, 1, 4, 4, 5) 407 408 (label, self._n1) = self._createLabeledEntry("N1/RPM:", 20, xalign = 0.0) 409 table.attach(label, 4, 5, 4, 5) 410 table.attach(self._n1, 5, 8, 4, 5) 411 412 (label, self._reverser) = self._createLabeledEntry("Reverser:", 20, xalign = 0.0) 413 table.attach(label, 8, 9, 4, 5) 414 table.attach(self._reverser, 9, 12, 4, 5) 415 416 self._navLightsOn = gtk.Label("NAV") 417 table.attach(self._navLightsOn, 0, 1, 5, 6) 418 419 self._antiCollisionLightsOn = gtk.Label("ANTICOLLISION") 420 table.attach(self._antiCollisionLightsOn, 1, 3, 5, 6) 421 422 self._strobeLightsOn = gtk.Label("STROBE") 423 table.attach(self._strobeLightsOn, 3, 4, 5, 6) 424 425 self._landingLightsOn = gtk.Label("LANDING") 426 table.attach(self._landingLightsOn, 4, 5, 5, 6) 427 428 self._pitotHeatOn = gtk.Label("PITOT HEAT") 429 table.attach(self._pitotHeatOn, 5, 7, 5, 6) 430 431 self._parking = gtk.Label("PARKING") 432 table.attach(self._parking, 7, 8, 5, 6) 433 434 self._gearsDown = gtk.Label("GEARS DOWN") 435 table.attach(self._gearsDown, 8, 10, 5, 6) 436 437 self._spoilersArmed = gtk.Label("SPOILERS ARMED") 438 table.attach(self._spoilersArmed, 10, 12, 5, 6) 439 440 (label, self._spoilersExtension) = self._createLabeledEntry("Spoilers:", 3) 441 table.attach(label, 0, 1, 6, 7) 442 table.attach(self._spoilersExtension, 1, 2, 6, 7) 443 444 (label, self._windSpeed) = self._createLabeledEntry("Wind speed:", 3) 445 table.attach(label, 2, 3, 6, 7) 446 table.attach(self._windSpeed, 3, 4, 6, 7) 447 448 (label, self._windDirection) = self._createLabeledEntry("Wind from:", 3) 449 table.attach(label, 4, 5, 6, 7) 450 table.attach(self._windDirection, 5, 6, 6, 7) 451 452 frameAlignment.add(table) 453 454 dataFrame.add(frameAlignment) 455 456 self._setData() 457 458 return dataFrame 459 460 def _setData(self, aircraftState = None): 461 """Set the data. 462 463 If aircraftState is None, everything will be set to its default.""" 464 if aircraftState is None: 465 self._timestamp.set_text("--:--:--") 466 self._paused.set_sensitive(False) 467 self._trickMode.set_sensitive(False) 468 self._overspeed.set_sensitive(False) 469 self._stalled.set_sensitive(False) 470 self._onTheGround.set_sensitive(False) 471 self._zfw.set_text("-") 472 self._grossWeight.set_text("-") 473 self._heading.set_text("-") 474 self._pitch.set_text("-") 475 self._bank.set_text("-") 476 self._vs.set_text("-") 477 self._ias.set_text("-") 478 self._mach.set_text("-") 479 self._groundSpeed.set_text("-") 480 self._radioAltitude.set_text("-") 481 self._altitude.set_text("-") 482 self._gLoad.set_text("-") 483 self._flapsSet.set_text("-") 484 self._flaps.set_text("-") 485 self._altimeter.set_text("-") 486 self._squawk.set_text("-") 487 self._nav1.set_text("-") 488 self._nav2.set_text("-") 489 self._fuel.set_text("-") 490 self._n1.set_text("-") 491 self._reverser.set_text("-") 492 self._navLightsOn.set_sensitive(False) 493 self._antiCollisionLightsOn.set_sensitive(False) 494 self._strobeLightsOn.set_sensitive(False) 495 self._landingLightsOn.set_sensitive(False) 496 self._pitotHeatOn.set_sensitive(False) 497 self._parking.set_sensitive(False) 498 self._gearsDown.set_sensitive(False) 499 self._spoilersArmed.set_sensitive(False) 500 self._spoilersExtension.set_text("-") 501 self._windSpeed.set_text("-") 502 self._windDirection.set_text("-") 503 else: 504 self._timestamp.set_text(time.strftime("%H:%M:%S", 505 time.gmtime(aircraftState.timestamp))) 506 self._paused.set_sensitive(aircraftState.paused) 507 self._trickMode.set_sensitive(aircraftState.trickMode) 508 self._overspeed.set_sensitive(aircraftState.overspeed) 509 self._stalled.set_sensitive(aircraftState.stalled) 510 self._onTheGround.set_sensitive(aircraftState.onTheGround) 511 self._zfw.set_text("%.0f" % (aircraftState.zfw,)) 512 self._grossWeight.set_text("%.0f" % (aircraftState.grossWeight,)) 513 self._heading.set_text("%03.0f" % (aircraftState.heading,)) 514 self._pitch.set_text("%.0f" % (aircraftState.pitch,)) 515 self._bank.set_text("%.0f" % (aircraftState.bank,)) 516 self._vs.set_text("%.0f" % (aircraftState.vs,)) 517 self._ias.set_text("%.0f" % (aircraftState.ias,)) 518 self._mach.set_text("%.2f" % (aircraftState.mach,)) 519 self._groundSpeed.set_text("%.0f" % (aircraftState.groundSpeed,)) 520 self._radioAltitude.set_text("%.0f" % (aircraftState.radioAltitude,)) 521 self._altitude.set_text("%.0f" % (aircraftState.altitude,)) 522 self._gLoad.set_text("%.2f" % (aircraftState.gLoad,)) 523 self._flapsSet.set_text("%.0f" % (aircraftState.flapsSet,)) 524 self._flaps.set_text("%.0f" % (aircraftState.flaps,)) 525 self._altimeter.set_text("%.0f" % (aircraftState.altimeter,)) 526 self._squawk.set_text(aircraftState.squawk) 527 self._nav1.set_text(aircraftState.nav1) 528 self._nav2.set_text(aircraftState.nav2) 529 530 fuelStr = "" 531 for fuel in aircraftState.fuel: 532 if fuelStr: fuelStr += ", " 533 fuelStr += "%.0f" % (fuel,) 534 self._fuel.set_text(fuelStr) 535 536 if hasattr(aircraftState, "n1"): 537 n1Str = "" 538 for n1 in aircraftState.n1: 539 if n1Str: n1Str += ", " 540 n1Str += "%.0f" % (n1,) 541 elif hasattr(aircraftState, "rpm"): 542 n1Str = "" 543 for rpm in aircraftState.rpm: 544 if n1Str: n1Str += ", " 545 n1Str += "%.0f" % (rpm,) 546 else: 547 n1Str = "-" 548 self._n1.set_text(n1Str) 549 550 reverserStr = "" 551 for reverser in aircraftState.reverser: 552 if reverserStr: reverserStr += ", " 553 reverserStr += "ON" if reverser else "OFF" 554 self._reverser.set_text(reverserStr) 555 556 self._navLightsOn.set_sensitive(aircraftState.navLightsOn) 557 self._antiCollisionLightsOn.set_sensitive(aircraftState.antiCollisionLightsOn) 558 self._strobeLightsOn.set_sensitive(aircraftState.strobeLightsOn) 559 self._landingLightsOn.set_sensitive(aircraftState.landingLightsOn) 560 self._pitotHeatOn.set_sensitive(aircraftState.pitotHeatOn) 561 self._parking.set_sensitive(aircraftState.parking) 562 self._gearsDown.set_sensitive(aircraftState.gearsDown) 563 self._spoilersArmed.set_sensitive(aircraftState.spoilersArmed) 564 self._spoilersExtension.set_text("%.0f" % (aircraftState.spoilersExtension,)) 565 self._windSpeed.set_text("%.0f" % (aircraftState.windSpeed,)) 566 self._windDirection.set_text("%03.0f" % (aircraftState.windDirection,)) 567 568 def _buildLogFrame(self): 569 """Build the frame for the log.""" 570 logFrame = gtk.Frame(label = "Log") 571 572 frameAlignment = gtk.Alignment(xscale = 1.0, yscale = 1.0) 573 574 frameAlignment.set_padding(padding_top = 4, padding_bottom = 10, 575 padding_left = 16, padding_right = 16) 576 577 logFrame.add(frameAlignment) 578 579 logScroller = gtk.ScrolledWindow() 580 self._logView = gtk.TextView() 581 self._logView.set_editable(False) 582 logScroller.add(self._logView) 583 584 logBox = gtk.VBox() 585 logBox.pack_start(logScroller, True, True, 0) 586 logBox.set_size_request(-1, 200) 587 588 frameAlignment.add(logBox) 589 590 return logFrame 591 592 def _writeLog(self, msg): 593 """Write the given message to the log.""" 594 buffer = self._logView.get_buffer() 595 buffer.insert(buffer.get_end_iter(), msg) 596 self._logView.scroll_mark_onscreen(buffer.get_insert()) 597 598 class TrackerStatusIcon(gtk.StatusIcon): 599 def __init__(self): 600 gtk.StatusIcon.__init__(self) 601 menu = ''' 602 <ui> 603 <menubar name="Menubar"> 604 <menu action="Menu"> 605 <menuitem action="Search"/> 606 <menuitem action="Preferences"/> 607 <separator/> 608 <menuitem action="About"/> 609 </menu> 610 </menubar> 611 </ui> 612 ''' 613 actions = [ 614 ('Menu', None, 'Menu'), 615 ('Search', None, '_Search...', None, 'Search files with MetaTracker', self.on_activate), 616 ('Preferences', gtk.STOCK_PREFERENCES, '_Preferences...', None, 'Change MetaTracker preferences', self.on_preferences), 617 ('About', gtk.STOCK_ABOUT, '_About...', None, 'About MetaTracker', self.on_about)] 618 ag = gtk.ActionGroup('Actions') 619 ag.add_actions(actions) 620 self.manager = gtk.UIManager() 621 self.manager.insert_action_group(ag, 0) 622 self.manager.add_ui_from_string(menu) 623 self.menu = self.manager.get_widget('/Menubar/Menu/About').props.parent 624 search = self.manager.get_widget('/Menubar/Menu/Search') 625 search.get_children()[0].set_markup('<b>_Search...</b>') 626 search.get_children()[0].set_use_underline(True) 627 search.get_children()[0].set_use_markup(True) 628 #search.get_children()[1].set_from_stock(gtk.STOCK_FIND, gtk.ICON_SIZE_MENU) 629 self.set_from_stock(gtk.STOCK_FIND) 630 self.set_tooltip('Tracker Desktop Search') 631 self.set_visible(True) 632 self.connect('activate', self.on_activate) 633 self.connect('popup-menu', self.on_popup_menu) 634 635 def on_activate(self, data): 636 os.spawnlpe(os.P_NOWAIT, 'tracker-search-tool', os.environ) 637 638 def on_popup_menu(self, status, button, time): 639 self.menu.popup(None, None, None, button, time) 640 641 def on_preferences(self, data): 642 print 'preferences' 643 644 def on_about(self, data): 645 dialog = gtk.AboutDialog() 646 dialog.set_name('Tracker') 647 dialog.set_version('0.5.0') 648 dialog.set_comments('A desktop indexing and search tool') 649 dialog.set_website('www.freedesktop.org/Tracker') 650 dialog.run() 651 dialog.destroy() 3 from .gui.gui import GUI 652 4 653 5 def main(): 654 6 """The main operation of the program.""" 655 gobject.threads_init()656 657 7 # menu = gtk.Menu() 658 8 # item = gtk.MenuItem()
Note:
See TracChangeset
for help on using the changeset viewer.