Changeset 93:fbcbfa72cdb2 for src
- Timestamp:
- 04/19/12 18:06:56 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/common.py
r86 r93 24 24 BUTTONSTYPE_YES_NO = gtk.BUTTONS_YES_NO 25 25 RESPONSETYPE_YES = gtk.RESPONSE_YES 26 ACCEL_VISIBLE = gtk.ACCEL_VISIBLE 27 CONTROL_MASK = gdk.CONTROL_MASK 26 28 else: 27 29 print "Using PyGObject" … … 39 41 BUTTONSTYPE_YES_NO = gtk.ButtonsType.YES_NO 40 42 RESPONSETYPE_YES = gtk.ResponseType.YES 43 ACCEL_VISIBLE = gtk.AccelFlags.VISIBLE 44 CONTROL_MASK = gdk.ModifierType.CONTROL_MASK 41 45 42 46 import cairo -
src/mlx/gui/flight.py
r92 r93 359 359 flight = self._wizard.loginResult.flights[index] 360 360 self._wizard._bookedFlight = flight 361 # FIXME: with PyGObject this call causes error messages to 362 # appear on the standard output 363 self._wizard.gui.enableFlightInfo() 361 364 362 365 self._updateDepartureGate() -
src/mlx/gui/gui.py
r92 r93 40 40 self._stdioLock = threading.Lock() 41 41 self._stdioText = "" 42 self._stdioAfterNewLine = True43 42 44 43 self.webHandler = web.Handler() … … 56 55 lambda a, b: self.hideMainWindow()) 57 56 window.connect("window-state-event", self._handleMainWindowState) 57 accelGroup = gtk.AccelGroup() 58 window.add_accel_group(accelGroup) 58 59 59 60 mainVBox = gtk.VBox() 60 61 window.add(mainVBox) 61 62 63 menuBar = self._buildMenuBar(accelGroup) 64 mainVBox.pack_start(menuBar, False, False, 0) 65 62 66 self._notebook = gtk.Notebook() 63 mainVBox. add(self._notebook)67 mainVBox.pack_start(self._notebook, True, True, 4) 64 68 65 69 self._wizard = Wizard(self) … … 74 78 label.set_tooltip_text("Flight information") 75 79 self._notebook.append_page(self._flightInfo, label) 76 77 logVBox = gtk.VBox() 80 self._flightInfo.disable() 81 82 (logWidget, self._logView) = self._buildLogWidget() 78 83 label = gtk.Label("_Log") 79 84 label.set_use_underline(True) 80 label.set_tooltip_text("Flight log") 81 self._notebook.append_page(logVBox, label) 82 83 logFrame = self._buildLogFrame() 84 logFrame.set_border_width(8) 85 logVBox.pack_start(logFrame, True, True, 0) 85 label.set_tooltip_text("The log of your flight that will be sent to the MAVA website") 86 self._notebook.append_page(logWidget, label) 87 88 (self._debugLogWidget, self._debugLogView) = self._buildLogWidget() 89 self._debugLogWidget.show_all() 86 90 87 91 mainVBox.pack_start(gtk.HSeparator(), False, False, 0) … … 93 97 94 98 self._monitorWindow = MonitorWindow(self, iconDirectory) 99 self._monitorWindow.add_accel_group(accelGroup) 95 100 self._monitorWindowX = None 96 101 self._monitorWindowY = None 102 self._selfToggling = False 97 103 98 104 window.show_all() … … 237 243 self.reset() 238 244 245 def enableFlightInfo(self): 246 """Enable the flight info tab.""" 247 self._flightInfo.enable() 248 239 249 def reset(self): 240 250 """Reset the GUI.""" … … 242 252 243 253 self._flightInfo.reset() 254 self._flightInfo.disable() 244 255 self.resetFlightStatus() 245 256 … … 263 274 def write(self, msg): 264 275 """Write the given message to the log.""" 265 gobject.idle_add(self._writeLog, msg )276 gobject.idle_add(self._writeLog, msg, self._logView) 266 277 267 278 def check(self, flight, aircraft, logger, oldState, state): … … 350 361 self._monitorWindow.hide() 351 362 self._statusIcon.monitorWindowHidden() 363 if self._showMonitorMenuItem.get_active(): 364 self._selfToggling = True 365 self._showMonitorMenuItem.set_active(False) 352 366 return True 353 367 … … 358 372 self._monitorWindow.show_all() 359 373 self._statusIcon.monitorWindowShown() 374 if not self._showMonitorMenuItem.get_active(): 375 self._selfToggling = True 376 self._showMonitorMenuItem.set_active(True) 377 378 def _toggleMonitorWindow(self, menuItem): 379 if self._selfToggling: 380 self._selfToggling = False 381 elif self._monitorWindow.get_visible(): 382 self.hideMonitorWindow() 383 else: 384 self.showMonitorWindow() 360 385 361 386 def restart(self): … … 378 403 def beginBusy(self, message): 379 404 """Begin a period of background processing.""" 405 self._wizard.set_sensitive(False) 380 406 self._mainWindow.get_window().set_cursor(self._busyCursor) 381 407 self._statusbar.updateBusyState(message) … … 384 410 """End a period of background processing.""" 385 411 self._mainWindow.get_window().set_cursor(None) 412 self._wizard.set_sensitive(True) 386 413 self._statusbar.updateBusyState(None) 387 414 … … 401 428 402 429 for line in lines: 403 if self._stdioAfterNewLine: 404 line = "[STDIO] " + line 405 self._writeLog(line + "\n") 406 self._stdioAfterNewLine = True 430 print >> sys.__stdout__, line 431 self._writeLog(line + "\n", self._debugLogView) 407 432 408 433 if text: 409 if self._stdioAfterNewLine: 410 text = "[STDIO] " + text 411 self._writeLog(text) 412 self._stdioAfterNewLine = False 434 print >> sys.__stdout__, line, 435 self._writeLog(text, self._debugLogView) 413 436 414 437 def connectSimulator(self, aircraftType): … … 444 467 self._monitoring = False 445 468 446 def _buildLogFrame(self): 447 """Build the frame for the log.""" 448 logFrame = gtk.Frame(label = "Log") 449 450 frameAlignment = gtk.Alignment(xscale = 1.0, yscale = 1.0) 451 452 frameAlignment.set_padding(padding_top = 4, padding_bottom = 10, 453 padding_left = 16, padding_right = 16) 454 455 logFrame.add(frameAlignment) 469 def _buildMenuBar(self, accelGroup): 470 """Build the main menu bar.""" 471 menuBar = gtk.MenuBar() 472 473 fileMenuItem = gtk.MenuItem("File") 474 fileMenu = gtk.Menu() 475 fileMenuItem.set_submenu(fileMenu) 476 menuBar.append(fileMenuItem) 477 478 quitMenuItem = gtk.ImageMenuItem(gtk.STOCK_QUIT) 479 quitMenuItem.set_use_stock(True) 480 quitMenuItem.add_accelerator("activate", accelGroup, 481 ord("q"), CONTROL_MASK, 482 ACCEL_VISIBLE) 483 quitMenuItem.connect("activate", self._quit) 484 fileMenu.append(quitMenuItem) 485 486 487 viewMenuItem = gtk.MenuItem("View") 488 viewMenu = gtk.Menu() 489 viewMenuItem.set_submenu(viewMenu) 490 menuBar.append(viewMenuItem) 491 492 self._showMonitorMenuItem = gtk.CheckMenuItem() 493 self._showMonitorMenuItem.set_label("Show _monitor window") 494 self._showMonitorMenuItem.set_use_underline(True) 495 self._showMonitorMenuItem.set_active(False) 496 self._showMonitorMenuItem.add_accelerator("activate", accelGroup, 497 ord("m"), CONTROL_MASK, 498 ACCEL_VISIBLE) 499 self._showMonitorMenuItem.connect("toggled", self._toggleMonitorWindow) 500 viewMenu.append(self._showMonitorMenuItem) 501 502 showDebugMenuItem = gtk.CheckMenuItem() 503 showDebugMenuItem.set_label("Show _debug log") 504 showDebugMenuItem.set_use_underline(True) 505 showDebugMenuItem.set_active(False) 506 showDebugMenuItem.add_accelerator("activate", accelGroup, 507 ord("d"), CONTROL_MASK, 508 ACCEL_VISIBLE) 509 showDebugMenuItem.connect("toggled", self._toggleDebugLog) 510 viewMenu.append(showDebugMenuItem) 511 512 return menuBar 513 514 def _toggleDebugLog(self, menuItem): 515 """Toggle the debug log.""" 516 if menuItem.get_active(): 517 label = gtk.Label("_Debug log") 518 label.set_use_underline(True) 519 label.set_tooltip_text("Log with debugging information.") 520 self._debugLogPage = self._notebook.append_page(self._debugLogWidget, label) 521 self._notebook.set_current_page(self._debugLogPage) 522 else: 523 self._notebook.remove_page(self._debugLogPage) 524 525 def _buildLogWidget(self): 526 """Build the widget for the log.""" 527 alignment = gtk.Alignment(xscale = 1.0, yscale = 1.0) 528 529 alignment.set_padding(padding_top = 8, padding_bottom = 8, 530 padding_left = 16, padding_right = 16) 456 531 457 532 logScroller = gtk.ScrolledWindow() 458 self._logView = gtk.TextView() 459 self._logView.set_editable(False) 460 logScroller.add(self._logView) 533 # FIXME: these should be constants in common 534 logScroller.set_policy(gtk.PolicyType.AUTOMATIC if pygobject 535 else gtk.POLICY_AUTOMATIC, 536 gtk.PolicyType.AUTOMATIC if pygobject 537 else gtk.POLICY_AUTOMATIC) 538 logScroller.set_shadow_type(gtk.ShadowType.IN if pygobject 539 else gtk.SHADOW_IN) 540 logView = gtk.TextView() 541 logView.set_editable(False) 542 logScroller.add(logView) 461 543 462 544 logBox = gtk.VBox() … … 464 546 logBox.set_size_request(-1, 200) 465 547 466 frameAlignment.add(logBox)467 468 return logFrame469 470 def _writeLog(self, msg ):548 alignment.add(logBox) 549 550 return (alignment, logView) 551 552 def _writeLog(self, msg, logView): 471 553 """Write the given message to the log.""" 472 buffer = self._logView.get_buffer()554 buffer = logView.get_buffer() 473 555 buffer.insert(buffer.get_end_iter(), msg) 474 self._logView.scroll_mark_onscreen(buffer.get_insert())556 logView.scroll_mark_onscreen(buffer.get_insert()) 475 557 476 558 def _quit(self, what = None, force = False): -
src/mlx/gui/info.py
r90 r93 43 43 self._gui = gui 44 44 45 self._commentsAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 46 xscale = 1.0, yscale = 1.0) 45 47 commentsBox = gtk.HBox() 46 48 … … 51 53 commentsBox.pack_start(frame, True, True, 8) 52 54 53 self.pack_start(commentsBox, True, True, 8) 55 self._commentsAlignment.add(commentsBox) 56 self.pack_start(self._commentsAlignment, True, True, 8) 54 57 55 58 frame = gtk.Frame(label = "Delay codes") … … 108 111 frame.add(alignment) 109 112 110 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,111 xscale = 0.0, yscale = 0.0)112 alignment.add(frame)113 self._delayAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, 114 xscale = 0.0, yscale = 0.0) 115 self._delayAlignment.add(frame) 113 116 114 self.pack_start(alignment, False, False, 8) 117 self.pack_start(self._delayAlignment, False, False, 8) 118 119 def enable(self): 120 """Enable the flight info tab.""" 121 #gobject.idle_add(self.set_sensitive, True) 122 self._commentsAlignment.set_sensitive(True) 123 self._delayAlignment.set_sensitive(True) 124 125 def disable(self): 126 """Enable the flight info tab.""" 127 #gobject.idle_add(self.set_sensitive, False) 128 self._commentsAlignment.set_sensitive(False) 129 self._delayAlignment.set_sensitive(False) 115 130 116 131 def reset(self):
Note:
See TracChangeset
for help on using the changeset viewer.