Changeset 97:f885322fb296 for src/mlx/gui
- Timestamp:
- 04/21/12 14:49:45 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/common.py
r93 r97 21 21 MESSAGETYPE_ERROR = gtk.MESSAGE_ERROR 22 22 MESSAGETYPE_QUESTION = gtk.MESSAGE_QUESTION 23 MESSAGETYPE_INFO = gtk.MESSAGE_INFO 23 24 BUTTONSTYPE_OK = gtk.BUTTONS_OK 24 25 BUTTONSTYPE_YES_NO = gtk.BUTTONS_YES_NO … … 26 27 ACCEL_VISIBLE = gtk.ACCEL_VISIBLE 27 28 CONTROL_MASK = gdk.CONTROL_MASK 29 30 def text2unicode(text): 31 """Convert the given text, returned by a Gtk widget, to Unicode.""" 32 return unicode(text) 28 33 else: 29 34 print "Using PyGObject" … … 38 43 MESSAGETYPE_ERROR = gtk.MessageType.ERROR 39 44 MESSAGETYPE_QUESTION = gtk.MessageType.QUESTION 45 MESSAGETYPE_INFO = gtk.MessageType.INFO 40 46 BUTTONSTYPE_OK = gtk.ButtonsType.OK 41 47 BUTTONSTYPE_YES_NO = gtk.ButtonsType.YES_NO … … 43 49 ACCEL_VISIBLE = gtk.AccelFlags.VISIBLE 44 50 CONTROL_MASK = gdk.ModifierType.CONTROL_MASK 51 52 import codecs 53 _utf8Decoder = codecs.getdecoder("utf-8") 54 55 def text2unicode(str): 56 """Convert the given text, returned by a Gtk widget, to Unicode.""" 57 return _utf8Decoder(str)[0] 45 58 46 59 import cairo -
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): -
src/mlx/gui/gui.py
r96 r97 120 120 121 121 @property 122 def logger(self): 123 """Get the logger used by us.""" 124 return self._logger 125 126 @property 122 127 def simulator(self): 123 128 """Get the simulator used by us.""" … … 130 135 131 136 @property 137 def bookedFlight(self): 138 """Get the booked flight selected, if any.""" 139 return self._wizard.bookedFlight 140 141 @property 142 def cargoWeight(self): 143 """Get the cargo weight.""" 144 return self._wizard.cargoWeight 145 146 @property 132 147 def zfw(self): 133 148 """Get Zero-Fuel Weight calculated for the current flight.""" … … 135 150 136 151 @property 152 def filedCruiseAltitude(self): 153 """Get cruise altitude filed for the current flight.""" 154 return self._wizard.filedCruiseAltitude 155 156 @property 137 157 def cruiseAltitude(self): 138 """Get cruise altitude calculatedfor the current flight."""158 """Get cruise altitude set for the current flight.""" 139 159 return self._wizard.cruiseAltitude 140 160 161 @property 162 def route(self): 163 """Get the flight route.""" 164 return self._wizard.route 165 166 @property 167 def departureMETAR(self): 168 """Get the METAR of the deprature airport.""" 169 return self._wizard.departureMETAR 170 171 @property 172 def arrivalMETAR(self): 173 """Get the METAR of the deprature airport.""" 174 return self._wizard.arrivalMETAR 175 176 @property 177 def departureRunway(self): 178 """Get the name of the departure runway.""" 179 return self._wizard.departureRunway 180 181 @property 182 def sid(self): 183 """Get the SID.""" 184 return self._wizard.sid 185 141 186 @property 142 187 def v1(self): … … 155 200 156 201 @property 202 def arrivalRunway(self): 203 """Get the arrival runway.""" 204 return self._wizard.arrivalRunway 205 206 @property 207 def star(self): 208 """Get the STAR.""" 209 return self._wizard.star 210 211 @property 212 def transition(self): 213 """Get the transition.""" 214 return self._wizard.transition 215 216 @property 217 def approachType(self): 218 """Get the approach type.""" 219 return self._wizard.approachType 220 221 @property 157 222 def vref(self): 158 223 """Get the Vref speed calculated for the flight.""" 159 224 return self._wizard.vref 160 225 226 @property 227 def flightType(self): 228 """Get the flight type.""" 229 return self._wizard.flightType 230 231 @property 232 def online(self): 233 """Get whether the flight was online or not.""" 234 return self._wizard.online 235 236 @property 237 def comments(self): 238 """Get the comments.""" 239 return self._flightInfo.comments 240 241 @property 242 def flightDefects(self): 243 """Get the flight defects.""" 244 return self._flightInfo.flightDefects 245 161 246 def run(self): 162 247 """Run the GUI.""" -
src/mlx/gui/info.py
r93 r97 23 23 24 24 scroller = gtk.ScrolledWindow() 25 # FIXME: these should be constants 25 26 scroller.set_policy(gtk.PolicyType.AUTOMATIC if pygobject 26 27 else gtk.POLICY_AUTOMATIC, … … 117 118 self.pack_start(self._delayAlignment, False, False, 8) 118 119 120 @property 121 def comments(self): 122 """Get the comments.""" 123 buffer = self._comments.get_buffer() 124 return text2unicode(buffer.get_text(buffer.get_start_iter(), 125 buffer.get_end_iter(), True)) 126 127 @property 128 def flightDefects(self): 129 """Get the flight defects.""" 130 buffer = self._flightDefects.get_buffer() 131 return text2unicode(buffer.get_text(buffer.get_start_iter(), 132 buffer.get_end_iter(), True)) 133 119 134 def enable(self): 120 135 """Enable the flight info tab.""" … … 144 159 self._weatherProblems.set_active(False) 145 160 self._personalReasons.set_active(False) 146
Note:
See TracChangeset
for help on using the changeset viewer.