Ignore:
Timestamp:
04/28/12 15:25:51 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

The fleet is now retrieved centrally and is updated on the Gates page all the time

Location:
src/mlx/gui
Files:
3 edited

Legend:

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

    r118 r119  
    416416        flight = self._wizard._bookedFlight
    417417        if flight.departureICAO=="LHBP":
    418             self._wizard._getFleet(self._fleetRetrieved)
     418            self._wizard.gui.getFleet(self._fleetRetrieved)
    419419        else:
    420420            self._nextDistance = 2
     
    532532            dialog.hide()
    533533
    534             self._wizard._getFleet(self._fleetRetrieved)
     534            self._wizard.gui.getFleet(self._fleetRetrieved)
    535535
    536536    def _fleetRetrieved(self, fleet):
     
    21212121        self.setCurrentPage(0)
    21222122       
    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 will
    2128         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 = callback
    2135         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.fleet
    2146         else:
    2147             self._fleet = None
    2148 
    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 
    21592123    def _updatePlane(self, callback, tailNumber, status, gateNumber = None):
    21602124        """Update the given plane's gate information."""
  • src/mlx/gui/gates.py

    r118 r119  
    124124    def _refreshClicked(self, button):
    125125        """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)
    129127
    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.
    133130
    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.fleet
     131        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:       
    140137            for plane in fleet:
    141138                conflicting = False
     
    169166                self._gateLabels[gateNumber].set_markup(markup)
    170167           
    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)
    173170
    174171
  • src/mlx/gui/gui.py

    r118 r119  
    4747        self._simulator = None
    4848        self._monitoring = False
     49        self._fleet = None
     50        self._fleetCallback = None
    4951
    5052        self._stdioLock = threading.Lock()
     
    551553        self._weightHelp.reset()
    552554        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)
    553592
    554593    def _writeStdIO(self):
Note: See TracChangeset for help on using the changeset viewer.