Changeset 130:f3b2a892af5a
- Timestamp:
- 04/30/12 08:25:14 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r126 r130 416 416 self._wizard.getFleet(self._fleetRetrieved) 417 417 else: 418 self._ nextDistance = 2419 self._wizard.jumpPage(2)420 418 self._wizard.updatePlane(self._planeUpdated, 419 flight.tailNumber, 420 const.PLANE_AWAY) 421 421 def _fleetRetrieved(self, fleet): 422 422 """Called when the fleet has been retrieved.""" … … 437 437 self._nextDistance = 1 438 438 self._wizard.nextPage() 439 440 def _planeUpdated(self, success): 441 """Callback for the plane updating.""" 442 self._nextDistance = 2 443 self._wizard.jumpPage(2) 439 444 440 445 #----------------------------------------------------------------------------- … … 509 514 self._wizard._departureGate = gateNumber 510 515 511 #self._wizard._updatePlane(self._planeUpdated, 512 # self._wizard._bookedFlight.tailNumber, 513 # const.PLANE_HOME, 514 # gateNumber) 515 516 self._wizard.nextPage() 516 self._wizard.updatePlane(self._planeUpdated, 517 self._wizard._bookedFlight.tailNumber, 518 const.PLANE_HOME, gateNumber) 519 else: 520 self._wizard.nextPage() 517 521 518 522 def _planeUpdated(self, success): … … 1665 1669 def _forwardClicked(self, button): 1666 1670 """Called when the forward button is clicked.""" 1671 if not self._completed and \ 1672 self._wizard.bookedFlight.arrivalICAO=="LHBP": 1673 self._wizard.getFleet(callback = self._fleetRetrieved, 1674 force = True) 1675 else: 1676 self._wizard.nextPage() 1677 1678 def _fleetRetrieved(self, fleet): 1679 """Callback for the fleet retrieval.""" 1667 1680 self._wizard.nextPage() 1668 1681 … … 1684 1697 xscale = 0.0, yscale = 0.0) 1685 1698 1686 table = gtk.Table( 7, 2)1699 table = gtk.Table(8, 2) 1687 1700 table.set_row_spacings(4) 1688 1701 table.set_col_spacings(16) … … 1786 1799 table.attach(onlineFlightAlignment, 1, 2, 6, 7) 1787 1800 1801 labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0, 1802 yalign = 0.5, yscale = 0.0) 1803 self._gateLabel = gtk.Label(xstr("finish_gate")) 1804 self._gateLabel.set_use_underline(True) 1805 labelAlignment.add(self._gateLabel) 1806 table.attach(labelAlignment, 0, 1, 7, 8) 1807 1808 self._gatesModel = gtk.ListStore(str) 1809 1810 self._gate = gtk.ComboBox(model = self._gatesModel) 1811 renderer = gtk.CellRendererText() 1812 self._gate.pack_start(renderer, True) 1813 self._gate.add_attribute(renderer, "text", 0) 1814 self._gate.set_tooltip_text(xstr("finish_gate_tooltip")) 1815 self._gate.connect("changed", self._gateChanged) 1816 gateAlignment = gtk.Alignment(xalign=0.0, xscale=1.0) 1817 gateAlignment.add(self._gate) 1818 table.attach(gateAlignment, 1, 2, 7, 8) 1819 self._gateLabel.set_mnemonic_widget(self._gate) 1820 1788 1821 self.addPreviousButton(clicked = self._backClicked) 1789 1822 … … 1834 1867 self._onlineFlight.set_active(True) 1835 1868 1869 self._gatesModel.clear() 1870 if self._wizard.bookedFlight.arrivalICAO=="LHBP": 1871 occupiedGates = self._wizard._fleet.getOccupiedGateNumbers() 1872 for gateNumber in const.lhbpGateNumbers: 1873 if gateNumber not in occupiedGates: 1874 self._gatesModel.append([gateNumber]) 1875 self._gateLabel.set_sensitive(True) 1876 self._gate.set_sensitive(True) 1877 self._gate.set_active(-1) 1878 else: 1879 self._gateLabel.set_sensitive(False) 1880 self._gate.set_sensitive(False) 1881 1836 1882 def _backClicked(self, button): 1837 1883 """Called when the Back button is pressed.""" 1838 1884 self.goBack() 1839 1885 1886 def _updateButtons(self): 1887 """Update the sensitivity state of the buttons.""" 1888 sensitive = self._flightType.get_active()>=0 and \ 1889 (self._gatesModel.get_iter_first() is None or 1890 self._gate.get_active()>=0) 1891 1892 #self._saveButton.set_sensitive(sensitive) 1893 self._sendButton.set_sensitive(sensitive) 1894 1840 1895 def _flightTypeChanged(self, comboBox): 1841 1896 """Called when the flight type has changed.""" 1842 index = self._flightType.get_active() 1843 flightTypeIsValid = index>=0 1844 #self._saveButton.set_sensitive(flightTypeIsValid) 1845 self._sendButton.set_sensitive(flightTypeIsValid) 1897 self._updateButtons() 1898 1899 def _gateChanged(self, comboBox): 1900 """Called when the arrival gate has changed.""" 1901 self._updateButtons() 1846 1902 1847 1903 def _sendClicked(self, button): … … 1888 1944 dialog.run() 1889 1945 dialog.hide() 1946 1947 if returned and result.success: 1948 bookedFlight = self._wizard.bookedFlight 1949 if bookedFlight.arrivalICAO=="LHBP": 1950 iter = self._gate.get_active_iter() 1951 gateNumber = None if iter is None \ 1952 else self._gatesModel.get_value(iter, 0) 1953 1954 status = const.PLANE_PARKING if gateNumber is None \ 1955 else const.PLANE_HOME 1956 else: 1957 gateNumber = None 1958 status = const.PLANE_AWAY 1959 1960 self._wizard.updatePlane(self._planeUpdated, 1961 bookedFlight.tailNumber, 1962 status, gateNumber = gateNumber) 1963 1964 def _planeUpdated(self, success): 1965 """Callback for the plane updating.""" 1966 pass 1890 1967 1891 1968 #----------------------------------------------------------------------------- … … 2096 2173 [self._bookedFlight.arrivalICAO]) 2097 2174 2098 self._takeoffPage.allowForward()2099 2175 elif stage==const.STAGE_END: 2100 2176 self._landingPage.flightEnded() … … 2104 2180 self._fleet = None 2105 2181 self._fleetCallback = None 2106 self._updatePlaneCallback = None2107 2182 2108 2183 self._loginResult = None … … 2119 2194 self.setCurrentPage(0) 2120 2195 2121 def getFleet(self, callback ):2196 def getFleet(self, callback, force = False): 2122 2197 """Get the fleet via the GUI and call the given callback.""" 2123 2198 self._fleetCallback = callback 2124 self.gui.getFleet( self._fleetRetrieved)2199 self.gui.getFleet(callback = self._fleetRetrieved, force = force) 2125 2200 2126 2201 def _fleetRetrieved(self, fleet): … … 2131 2206 self._fleetCallback = None 2132 2207 2133 def _updatePlane(self, callback, tailNumber, status, gateNumber = None):2208 def updatePlane(self, callback, tailNumber, status, gateNumber = None): 2134 2209 """Update the given plane's gate information.""" 2135 self.gui.beginBusy(xstr("fleet_update_busy")) 2136 self._updatePlaneCallback = callback 2137 self.gui.webHandler.updatePlane(self._updatePlaneResultCallback, 2138 tailNumber, status, gateNumber) 2139 2140 def _updatePlaneResultCallback(self, returned, result): 2141 """Callback for the plane updating operation.""" 2142 gobject.idle_add(self._handleUpdatePlaneResult, returned, result) 2143 2144 def _handleUpdatePlaneResult(self, returned, result): 2145 """Handle the result of a plane update operation.""" 2146 self.gui.endBusy() 2147 if returned: 2148 success = result.success 2149 else: 2150 success = None 2151 2152 dialog = gtk.MessageDialog(parent = self.gui.mainWindow, 2153 type = MESSAGETYPE_ERROR, 2154 message_format = 2155 xstr("fleet_update_failed")) 2156 dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK) 2157 dialog.set_title(WINDOW_TITLE_BASE) 2158 dialog.run() 2159 dialog.hide() 2160 2161 self._updatePlaneCallback(success) 2210 self.gui.updatePlane(tailNumber, status, gateNumber = gateNumber, 2211 callback = callback) 2162 2212 2163 2213 def _connectSimulator(self): -
src/mlx/gui/gui.py
r128 r130 48 48 self._simulator = None 49 49 self._monitoring = False 50 50 51 self._fleet = None 52 51 53 self._fleetCallback = None 54 55 self._updatePlaneCallback = None 56 self._updatePlaneTailNumber = None 57 self._updatePlaneStatus = None 58 self._updatePlaneGateNumber = None 52 59 53 60 self._stdioLock = threading.Lock() … … 583 590 type = MESSAGETYPE_ERROR, 584 591 message_format = xstr("fleet_failed")) 592 dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK) 593 dialog.set_title(WINDOW_TITLE_BASE) 594 dialog.run() 595 dialog.hide() 596 597 callback = self._fleetCallback 598 self._fleetCallback = None 599 if callback is not None: 600 callback(self._fleet) 601 self._fleetGateStatus.handleFleet(self._fleet) 602 603 def updatePlane(self, tailNumber, status, 604 gateNumber = None, callback = None): 605 """Update the status of the given plane.""" 606 self.beginBusy(xstr("fleet_update_busy")) 607 608 self._updatePlaneCallback = callback 609 610 self._updatePlaneTailNumber = tailNumber 611 self._updatePlaneStatus = status 612 self._updatePlaneGateNumber = gateNumber 613 614 self.webHandler.updatePlane(self._updatePlaneResultCallback, 615 tailNumber, status, gateNumber) 616 617 def _updatePlaneResultCallback(self, returned, result): 618 """Called when the status of a plane has been updated.""" 619 gobject.idle_add(self._handleUpdatePlaneResult, returned, result) 620 621 def _handleUpdatePlaneResult(self, returned, result): 622 """Handle the plane update result.""" 623 self.endBusy() 624 if returned: 625 success = result.success 626 if success: 627 if self._fleet is not None: 628 self._fleet.updatePlane(self._updatePlaneTailNumber, 629 self._updatePlaneStatus, 630 self._updatePlaneGateNumber) 631 self._fleetGateStatus.handleFleet(self._fleet) 632 else: 633 dialog = gtk.MessageDialog(parent = self.mainWindow, 634 type = MESSAGETYPE_ERROR, 635 message_format = xstr("fleet_update_failed")) 585 636 dialog.add_button(xstr("button_ok"), RESPONSETYPE_ACCEPT) 586 637 dialog.set_title(WINDOW_TITLE_BASE) … … 588 639 dialog.hide() 589 640 590 if self._fleetCallback is not None: 591 self._fleetCallback(self._fleet) 592 self._fleetCallback = None 593 self._fleetGateStatus.handleFleet(self._fleet) 641 success = None 642 643 callback = self._updatePlaneCallback 644 self._updatePlaneCallback = None 645 if callback is not None: 646 callback(success) 594 647 595 648 def _writeStdIO(self): -
src/mlx/i18n.py
r128 r130 387 387 self.add("finish_online_tooltip", 388 388 "Check if your flight was online, uncheck otherwise.") 389 self.add("finish_gate", "_Arrival gate:") 390 self.add("finish_gate_tooltip", 391 "Select the gate or stand at which you have arrived to LHBP.") 389 392 self.add("finish_save", "S_ave PIREP...") 390 393 self.add("finish_save_tooltip", … … 848 851 "Jelöld be, ha a repülésed a hálózaton történt, egyébként " \ 849 852 "szűntesd meg a kijelölést.") 853 self.add("finish_gate", "_Érkezési kapu:") 854 self.add("finish_gate_tooltip", 855 "Válaszd ki azt a kaput vagy állóhelyet, ahová érkeztél LHBP-n.") 850 856 self.add("finish_save", "PIREP _mentése...") 851 857 self.add("finish_save_tooltip", -
src/mlx/web.py
r118 r130 179 179 gateNumbers.add(p.gateNumber) 180 180 return gateNumbers 181 181 182 def updatePlane(self, tailNumber, status, gateNumber = None): 183 """Update the status of the given plane.""" 184 if tailNumber in self._planes: 185 plane = self._planes[tailNumber] 186 plane.status = status 187 plane.gateNumber = gateNumber 188 182 189 def __iter__(self): 183 190 """Get an iterator over the planes."""
Note:
See TracChangeset
for help on using the changeset viewer.