Changeset 97:f885322fb296 for src/mlx/gui/flight.py
- Timestamp:
- 04/21/12 14:49:45 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r96 r97 7 7 from mlx.checks import PayloadChecker 8 8 import mlx.util as util 9 from mlx.pirep import PIREP 9 10 10 11 import datetime … … 777 778 self._button.connect("clicked", self._forwardClicked) 778 779 780 @property 781 def cargoWeight(self): 782 """Get the cargo weight entered.""" 783 return self._cargoWeight.get_int() 784 779 785 def activate(self): 780 786 """Setup the information.""" … … 996 1002 self._cruiseLevel.set_numeric(True) 997 1003 self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged) 998 label.set_mnemonic_widget(self._cruiseLevel) 1004 label.set_mnemonic_widget(self._cruiseLevel) 1005 self._filedCruiseLevel = 240 999 1006 1000 1007 levelBox.pack_start(self._cruiseLevel, False, False, 8) … … 1044 1051 1045 1052 @property 1053 def filedCruiseLevel(self): 1054 """Get the filed cruise level.""" 1055 return self._filedCruiseLevel 1056 1057 @property 1046 1058 def cruiseLevel(self): 1047 1059 """Get the cruise level.""" 1048 1060 return self._cruiseLevel.get_value_as_int() 1049 1061 1062 @property 1063 def route(self): 1064 """Get the route.""" 1065 return self._getRoute() 1066 1050 1067 def activate(self): 1051 1068 """Setup the route from the booked flight.""" 1052 1069 self._cruiseLevel.set_value(240) 1070 self._filedCruiseLevel = 240 1053 1071 self._route.get_buffer().set_text(self._wizard._bookedFlight.route) 1054 1072 self._updateForwardButton() … … 1083 1101 else: 1084 1102 bookedFlight = self._wizard._bookedFlight 1103 self._filedCruiseLevel = self.cruiseLevel 1085 1104 self._wizard.gui.beginBusy("Downloading NOTAMs...") 1086 1105 self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback, … … 1204 1223 self._button.connect("clicked", self._forwardClicked) 1205 1224 1225 @property 1226 def metar(self): 1227 """Get the METAR on the page.""" 1228 buffer = self._metar.get_buffer() 1229 return buffer.get_text(buffer.get_start_iter(), 1230 buffer.get_end_iter(), True) 1231 1206 1232 def activate(self): 1207 1233 """Activate the page.""" … … 1357 1383 1358 1384 @property 1385 def runway(self): 1386 """Get the runway.""" 1387 return self._runway.get_text() 1388 1389 @property 1390 def sid(self): 1391 """Get the SID.""" 1392 return self._sid.get_text() 1393 1394 @property 1359 1395 def v1(self): 1360 1396 """Get the v1 speed.""" … … 1514 1550 1515 1551 @property 1552 def star(self): 1553 """Get the STAR or None if none entered.""" 1554 return self._star.get_text() if self._starButton.get_active() else None 1555 1556 @property 1557 def transition(self): 1558 """Get the transition or None if none entered.""" 1559 return self._transition.get_text() \ 1560 if self._transitionButton.get_active() else None 1561 1562 @property 1563 def approachType(self): 1564 """Get the approach type.""" 1565 return self._approachType.get_text() 1566 1567 @property 1568 def runway(self): 1569 """Get the runway.""" 1570 return self._runway.get_text() 1571 1572 @property 1516 1573 def vref(self): 1517 1574 """Return the landing reference speed.""" … … 1608 1665 class FinishPage(Page): 1609 1666 """Flight finish page.""" 1667 _flightTypes = [ ("scheduled", const.FLIGHTTYPE_SCHEDULED), 1668 ("old-timer", const.FLIGHTTYPE_OLDTIMER), 1669 ("VIP", const.FLIGHTTYPE_VIP), 1670 ("charter", const.FLIGHTTYPE_CHARTER) ] 1671 1610 1672 def __init__(self, wizard): 1611 1673 """Construct the finish page.""" … … 1698 1760 1699 1761 flightTypeModel = gtk.ListStore(str, int) 1700 index = 1 1701 for type in ["scheduled", "old-timer", "VIP", "charter"]: 1702 flightTypeModel.append([type, index]) 1703 index += 1 1762 for (name, type) in FinishPage._flightTypes: 1763 flightTypeModel.append([name, type]) 1704 1764 1705 1765 self._flightType = gtk.ComboBox(model = flightTypeModel) … … 1734 1794 self._sendButton.set_use_underline(True) 1735 1795 self._sendButton.set_sensitive(False) 1736 #self._sendButton.connect("clicked", self._sendClicked) 1796 self._sendButton.connect("clicked", self._sendClicked) 1797 1798 @property 1799 def flightType(self): 1800 """Get the flight type.""" 1801 index = self._flightType.get_active() 1802 return None if index<0 else self._flightType.get_model()[index][1] 1803 1804 @property 1805 def online(self): 1806 """Get whether the flight was an online flight or not.""" 1807 return self._onlineFlight.get_active() 1737 1808 1738 1809 def activate(self): … … 1770 1841 index = self._flightType.get_active() 1771 1842 flightTypeIsValid = index>=0 1772 self._saveButton.set_sensitive(flightTypeIsValid)1843 #self._saveButton.set_sensitive(flightTypeIsValid) 1773 1844 self._sendButton.set_sensitive(flightTypeIsValid) 1845 1846 def _sendClicked(self, button): 1847 """Called when the Send button is clicked.""" 1848 pirep = PIREP(self._wizard.gui) 1849 gui = self._wizard.gui 1850 gui.beginBusy("Sending PIREP...") 1851 gui.webHandler.sendPIREP(self._pirepSentCallback, pirep) 1852 1853 def _pirepSentCallback(self, returned, result): 1854 """Callback for the PIREP sending result.""" 1855 gobject.idle_add(self._handlePIREPSent, returned, result) 1856 1857 def _handlePIREPSent(self, returned, result): 1858 """Callback for the PIREP sending result.""" 1859 self._wizard.gui.endBusy() 1860 secondaryMarkup = None 1861 type = MESSAGETYPE_ERROR 1862 if returned: 1863 if result.success: 1864 type = MESSAGETYPE_INFO 1865 messageFormat = "The PIREP was sent successfully." 1866 secondaryMarkup = "Await the thorough scrutiny from our PIREP correctors! :)" 1867 elif result.alreadyFlown: 1868 messageFormat = "The PIREP for this flight has already been sent!" 1869 secondaryMarkup = "You may clear the old PIREP on the MAVA website." 1870 elif result.notAvailable: 1871 messageFormat = "This flight is not available anymore!" 1872 else: 1873 messageFormat = "The MAVA website returned with an unknown error." 1874 secondaryMarkup = "See the debug log for more information." 1875 else: 1876 print "PIREP sending failed", result 1877 messageFormat = "Could not send the PIREP to the MAVA website." 1878 secondaryMarkup = "This can be a network problem, in which case\n" \ 1879 "you may try again later. Or it can be a bug;\n" \ 1880 "see the debug log for more information." 1881 1882 dialog = gtk.MessageDialog(type = type, buttons = BUTTONSTYPE_OK, 1883 message_format = messageFormat) 1884 if secondaryMarkup is not None: 1885 dialog.format_secondary_markup(secondaryMarkup) 1886 1887 dialog.run() 1888 dialog.hide() 1774 1889 1775 1890 #----------------------------------------------------------------------------- … … 1795 1910 self._routePage = RoutePage(self) 1796 1911 self._pages.append(self._routePage) 1797 self._pages.append(BriefingPage(self, True)) 1798 self._pages.append(BriefingPage(self, False)) 1912 self._departureBriefingPage = BriefingPage(self, True) 1913 self._pages.append(self._departureBriefingPage) 1914 self._arrivalBriefingPage = BriefingPage(self, False) 1915 self._pages.append(self._arrivalBriefingPage) 1799 1916 self._takeoffPage = TakeoffPage(self) 1800 1917 self._pages.append(self._takeoffPage) 1801 1918 self._landingPage = LandingPage(self) 1802 1919 self._pages.append(self._landingPage) 1803 self._pages.append(FinishPage(self)) 1920 self._finishPage = FinishPage(self) 1921 self._pages.append(self._finishPage) 1804 1922 1805 1923 maxWidth = 0 … … 1845 1963 1846 1964 @property 1965 def bookedFlight(self): 1966 """Get the booked flight selected.""" 1967 return self._bookedFlight 1968 1969 @property 1970 def cargoWeight(self): 1971 """Get the calculated ZFW value.""" 1972 return self._payloadPage.cargoWeight 1973 1974 @property 1847 1975 def zfw(self): 1848 1976 """Get the calculated ZFW value.""" … … 1851 1979 1852 1980 @property 1981 def filedCruiseAltitude(self): 1982 """Get the filed cruise altitude.""" 1983 return self._routePage.filedCruiseLevel * 100 1984 1985 @property 1853 1986 def cruiseAltitude(self): 1854 1987 """Get the cruise altitude.""" … … 1856 1989 1857 1990 @property 1991 def route(self): 1992 """Get the route.""" 1993 return self._routePage.route 1994 1995 @property 1996 def departureMETAR(self): 1997 """Get the METAR of the departure airport.""" 1998 return self._departureBriefingPage.metar 1999 2000 @property 2001 def arrivalMETAR(self): 2002 """Get the METAR of the arrival airport.""" 2003 return self._arrivalBriefingPage.metar 2004 2005 @property 2006 def departureRunway(self): 2007 """Get the departure runway.""" 2008 return self._takeoffPage.runway 2009 2010 @property 2011 def sid(self): 2012 """Get the SID.""" 2013 return self._takeoffPage.sid 2014 2015 @property 1858 2016 def v1(self): 1859 2017 """Get the V1 speed.""" … … 1871 2029 1872 2030 @property 2031 def arrivalRunway(self): 2032 """Get the arrival runway.""" 2033 return self._landingPage.runway 2034 2035 @property 2036 def star(self): 2037 """Get the STAR.""" 2038 return self._landingPage.star 2039 2040 @property 2041 def transition(self): 2042 """Get the transition.""" 2043 return self._landingPage.transition 2044 2045 @property 2046 def approachType(self): 2047 """Get the approach type.""" 2048 return self._landingPage.approachType 2049 2050 @property 1873 2051 def vref(self): 1874 2052 """Get the Vref speed.""" 1875 2053 return self._landingPage.vref 2054 2055 @property 2056 def flightType(self): 2057 """Get the flight type.""" 2058 return self._finishPage.flightType 2059 2060 @property 2061 def online(self): 2062 """Get whether the flight was online or not.""" 2063 return self._finishPage.online 1876 2064 1877 2065 def nextPage(self, finalize = True):
Note:
See TracChangeset
for help on using the changeset viewer.