Changeset 119:0185f1446770 for src
- Timestamp:
- 04/28/12 15:25:51 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r118 r119 416 416 flight = self._wizard._bookedFlight 417 417 if flight.departureICAO=="LHBP": 418 self._wizard. _getFleet(self._fleetRetrieved)418 self._wizard.gui.getFleet(self._fleetRetrieved) 419 419 else: 420 420 self._nextDistance = 2 … … 532 532 dialog.hide() 533 533 534 self._wizard. _getFleet(self._fleetRetrieved)534 self._wizard.gui.getFleet(self._fleetRetrieved) 535 535 536 536 def _fleetRetrieved(self, fleet): … … 2121 2121 self.setCurrentPage(0) 2122 2122 2123 def _getFleet(self, callback, force = False):2124 """Get the fleet, if needed.2125 2126 callback is function that will be called, when the feet is retrieved,2127 or the retrieval fails. It should have a single argument that will2128 receive the fleet object on success, None otherwise.2129 """2130 if self._fleet is not None and not force:2131 callback(self._fleet)2132 2133 self.gui.beginBusy(xstr("fleet_busy"))2134 self._fleetCallback = callback2135 self.gui.webHandler.getFleet(self._fleetResultCallback)2136 2137 def _fleetResultCallback(self, returned, result):2138 """Called when the fleet has been queried."""2139 gobject.idle_add(self._handleFleetResult, returned, result)2140 2141 def _handleFleetResult(self, returned, result):2142 """Handle the fleet result."""2143 self.gui.endBusy()2144 if returned:2145 self._fleet = result.fleet2146 else:2147 self._fleet = None2148 2149 dialog = gtk.MessageDialog(parent = self.gui.mainWindow,2150 type = MESSAGETYPE_ERROR,2151 buttons = BUTTONSTYPE_OK,2152 message_format = xstr("fleet_failed"))2153 dialog.set_title(WINDOW_TITLE_BASE)2154 dialog.run()2155 dialog.hide()2156 2157 self._fleetCallback(self._fleet)2158 2159 2123 def _updatePlane(self, callback, tailNumber, status, gateNumber = None): 2160 2124 """Update the given plane's gate information.""" -
src/mlx/gui/gates.py
r118 r119 124 124 def _refreshClicked(self, button): 125 125 """Called when the Refresh data button is clicked.""" 126 self._gui.beginBusy(xstr("fleet_busy")) 127 # FIXME: put this into the GUI, where it refreshes everything 128 self._gui.webHandler.getFleet(self._fleetCallback) 126 self._gui.getFleet(force = True) 129 127 130 def _fleetCallback(self, returned, result): 131 """Callback for the fleet retrieval.""" 132 gobject.idle_add(self._handleFleet, returned, result) 128 def handleFleet(self, fleet): 129 """Handle new fleet information. 133 130 134 def _handleFleet(self, returned, result):135 """Callback for the fleet retrieval."""136 self._gui.endBusy()137 if returned:138 self._fleetStore.clear()139 fleet = result.fleet131 If fleet is None, the data will be cleared.""" 132 self._fleetStore.clear() 133 if fleet is None: 134 for (gateNumber, label) in self._gateLabels.iteritems(): 135 label.set_markup("<b>" + gateNumber + "</b>") 136 else: 140 137 for plane in fleet: 141 138 conflicting = False … … 169 166 self._gateLabels[gateNumber].set_markup(markup) 170 167 171 self._fleetFrame.set_sensitive( True)172 self._gatesFrame.set_sensitive( True)168 self._fleetFrame.set_sensitive(fleet is not None) 169 self._gatesFrame.set_sensitive(fleet is not None) 173 170 174 171 -
src/mlx/gui/gui.py
r118 r119 47 47 self._simulator = None 48 48 self._monitoring = False 49 self._fleet = None 50 self._fleetCallback = None 49 51 50 52 self._stdioLock = threading.Lock() … … 551 553 self._weightHelp.reset() 552 554 self._weightHelp.enable() 555 556 def getFleet(self, callback = None, force = False): 557 """Get the fleet. 558 559 If force is False, and we already have a fleet retrieved, 560 that one will be used.""" 561 if self._fleet is None or force: 562 self._fleetCallback = callback 563 self.beginBusy(xstr("fleet_busy")) 564 self.webHandler.getFleet(self._fleetResultCallback) 565 else: 566 callback(self._fleet) 567 568 def _fleetResultCallback(self, returned, result): 569 """Called when the fleet has been queried.""" 570 gobject.idle_add(self._handleFleetResult, returned, result) 571 572 def _handleFleetResult(self, returned, result): 573 """Handle the fleet result.""" 574 self.endBusy() 575 if returned: 576 self._fleet = result.fleet 577 else: 578 self._fleet = None 579 580 dialog = gtk.MessageDialog(parent = self.gui.mainWindow, 581 type = MESSAGETYPE_ERROR, 582 buttons = BUTTONSTYPE_OK, 583 message_format = xstr("fleet_failed")) 584 dialog.set_title(WINDOW_TITLE_BASE) 585 dialog.run() 586 dialog.hide() 587 588 if self._fleetCallback is not None: 589 self._fleetCallback(self._fleet) 590 self._fleetCallback = None 591 self._fleetGateStatus.handleFleet(self._fleet) 553 592 554 593 def _writeStdIO(self):
Note:
See TracChangeset
for help on using the changeset viewer.