Changeset 586:6e5ba20962e3 for src/mlx
- Timestamp:
- 12/21/14 14:33:17 (10 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r584 r586 1938 1938 else gtk.POLICY_AUTOMATIC) 1939 1939 1940 self._up percasingMETAR = False1940 self._updatingMETAR = False 1941 1941 1942 1942 self._metar = gtk.TextView() … … 1968 1968 1969 1969 def setMETAR(self, metar): 1970 """Set the metar."""1970 """Set the METAR.""" 1971 1971 self._metar.get_buffer().set_text(metar) 1972 1972 self.metarEdited = False 1973 1974 def changeMETAR(self, metar): 1975 """Change the METAR as a result of an edit on one of the other 1976 pages.""" 1977 self._updatingMETAR = True 1978 self._metar.get_buffer().set_text(metar) 1979 self._updatingMETAR = False 1980 self.metarEdited = True 1973 1981 1974 1982 def activate(self): … … 2003 2011 self._metarFrame.set_label(xstr("briefing_metar_template") % (icao,)) 2004 2012 buffer = self._metar.get_buffer() 2013 self._updatingMETAR = True 2005 2014 if metar is None: 2006 #buffer.set_text(xstr("briefing_metar_failed"))2007 2015 buffer.set_text("") 2008 2016 self.setHelp(xstr("briefing_help_nometar")) 2009 2017 else: 2010 2018 buffer.set_text(metar) 2019 self._updatingMETAR = False 2011 2020 self._updateButton() 2012 2021 … … 2034 2043 def _metarChanged(self, buffer): 2035 2044 """Called when the METAR has changed.""" 2036 if not self._uppercasingMETAR: 2045 print "BriefingPage.metarChanged", self._updatingMETAR 2046 if not self._updatingMETAR: 2037 2047 self.metarEdited = True 2038 2048 self._updateButton() 2049 metar = buffer.get_text(buffer.get_start_iter(), 2050 buffer.get_end_iter(), True) 2051 self._wizard.metarChanged(metar, self) 2039 2052 2040 2053 def _metarInserted(self, textBuffer, iter, text, length): … … 2042 2055 2043 2056 It uppercases all characters.""" 2044 if not self._uppercasingMETAR: 2045 self._uppercasingMETAR = True 2057 print "BriefingPage.metarInserted", self._updatingMETAR 2058 if not self._updatingMETAR: 2059 self._updatingMETAR = True 2046 2060 2047 2061 iter1 = iter.copy() … … 2051 2065 textBuffer.insert(iter, text.upper()) 2052 2066 2053 self._up percasingMETAR = False2067 self._updatingMETAR = False 2054 2068 2055 2069 def _updateButton(self): … … 2077 2091 xscale = 0.0, yscale = 0.0) 2078 2092 2079 table = gtk.Table( 8,4)2093 table = gtk.Table(9, 24) 2080 2094 table.set_row_spacings(4) 2081 2095 table.set_col_spacings(16) … … 2084 2098 self.setMainWidget(alignment) 2085 2099 2100 row = 0 2101 2102 label = gtk.Label(xstr("takeoff_metar")) 2103 label.set_use_underline(True) 2104 label.set_alignment(0.0, 0.5) 2105 table.attach(label, 0, 1, row, row+1) 2106 2107 self._metar = gtk.Entry() 2108 self._metar.set_width_chars(40) 2109 self._metar.connect("changed", self._metarChanged) 2110 self._metar.connect_after("insert-text", self._metarInserted) 2111 table.attach(self._metar, 1, 24, row, row+1) 2112 label.set_mnemonic_widget(self._metar) 2113 2114 self._updatingMETAR = False 2115 2116 row += 1 2117 2086 2118 label = gtk.Label(xstr("takeoff_runway")) 2087 2119 label.set_use_underline(True) 2088 2120 label.set_alignment(0.0, 0.5) 2089 table.attach(label, 0, 1, 0,1)2121 table.attach(label, 0, 1, row, row+1) 2090 2122 2091 2123 self._runway = gtk.Entry() … … 2093 2125 self._runway.set_tooltip_text(xstr("takeoff_runway_tooltip")) 2094 2126 self._runway.connect("changed", self._upperChanged) 2095 table.attach(self._runway, 1, 3, 0,1)2127 table.attach(self._runway, 1, 3, row, row+1) 2096 2128 label.set_mnemonic_widget(self._runway) 2129 2130 row += 1 2097 2131 2098 2132 label = gtk.Label(xstr("takeoff_sid")) 2099 2133 label.set_use_underline(True) 2100 2134 label.set_alignment(0.0, 0.5) 2101 table.attach(label, 0, 1, 1, 2)2135 table.attach(label, 0, 1, row, row+1) 2102 2136 2103 2137 self._sid = gtk.Entry() … … 2105 2139 self._sid.set_tooltip_text(xstr("takeoff_sid_tooltip")) 2106 2140 self._sid.connect("changed", self._upperChanged) 2107 table.attach(self._sid, 1, 3, 1, 2)2141 table.attach(self._sid, 1, 3, row, row+1) 2108 2142 label.set_mnemonic_widget(self._sid) 2143 2144 row += 1 2109 2145 2110 2146 label = gtk.Label(xstr("takeoff_v1")) … … 2112 2148 label.set_use_underline(True) 2113 2149 label.set_alignment(0.0, 0.5) 2114 table.attach(label, 0, 1, 2, 3)2150 table.attach(label, 0, 1, row, row+1) 2115 2151 2116 2152 self._v1 = IntegerEntry() … … 2118 2154 self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip_knots")) 2119 2155 self._v1.connect("integer-changed", self._valueChanged) 2120 table.attach(self._v1, 2, 3, 2, 3)2156 table.attach(self._v1, 2, 3, row, row+1) 2121 2157 label.set_mnemonic_widget(self._v1) 2122 2158 2123 2159 self._v1Unit = gtk.Label(xstr("label_knots")) 2124 2160 self._v1Unit.set_alignment(0.0, 0.5) 2125 table.attach(self._v1Unit, 3, 4, 2, 3) 2161 table.attach(self._v1Unit, 3, 4, row, row+1) 2162 2163 row += 1 2126 2164 2127 2165 label = gtk.Label(xstr("takeoff_vr")) … … 2129 2167 label.set_use_underline(True) 2130 2168 label.set_alignment(0.0, 0.5) 2131 table.attach(label, 0, 1, 3, 4)2169 table.attach(label, 0, 1, row, row+1) 2132 2170 2133 2171 self._vr = IntegerEntry() … … 2135 2173 self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip_knots")) 2136 2174 self._vr.connect("integer-changed", self._valueChanged) 2137 table.attach(self._vr, 2, 3, 3, 4)2175 table.attach(self._vr, 2, 3, row, row+1) 2138 2176 label.set_mnemonic_widget(self._vr) 2139 2177 2140 2178 self._vrUnit = gtk.Label(xstr("label_knots")) 2141 2179 self._vrUnit.set_alignment(0.0, 0.5) 2142 table.attach(self._vrUnit, 3, 4, 3, 4) 2180 table.attach(self._vrUnit, 3, 4, row, row+1) 2181 2182 row += 1 2143 2183 2144 2184 label = gtk.Label(xstr("takeoff_v2")) … … 2146 2186 label.set_use_underline(True) 2147 2187 label.set_alignment(0.0, 0.5) 2148 table.attach(label, 0, 1, 4, 5)2188 table.attach(label, 0, 1, row, row+1) 2149 2189 2150 2190 self._v2 = IntegerEntry() … … 2152 2192 self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip_knots")) 2153 2193 self._v2.connect("integer-changed", self._valueChanged) 2154 table.attach(self._v2, 2, 3, 4, 5)2194 table.attach(self._v2, 2, 3, row, row+1) 2155 2195 label.set_mnemonic_widget(self._v2) 2156 2196 2157 2197 self._v2Unit = gtk.Label(xstr("label_knots")) 2158 2198 self._v2Unit.set_alignment(0.0, 0.5) 2159 table.attach(self._v2Unit, 3, 4, 4, 5) 2199 table.attach(self._v2Unit, 3, 4, row, row+1) 2200 2201 row += 1 2160 2202 2161 2203 self._derateType = acft.DERATE_NONE … … 2165 2207 self._derateLabel.set_markup(xstr("takeoff_derate_tupolev")) 2166 2208 self._derateLabel.set_alignment(0.0, 0.5) 2167 table.attach(self._derateLabel, 0, 1, 5, 6)2209 table.attach(self._derateLabel, 0, 1, row, row+1) 2168 2210 2169 2211 self._derate = gtk.Alignment() 2170 table.attach(self._derate, 2, 4, 5, 6)2212 table.attach(self._derate, 2, 4, row, row+1) 2171 2213 self._derateWidget = None 2172 2214 self._derateEntry = None … … 2174 2216 self._derateButtons = None 2175 2217 2218 row += 1 2219 2176 2220 self._antiIceOn = gtk.CheckButton(xstr("takeoff_antiice")) 2177 2221 self._antiIceOn.set_use_underline(True) 2178 2222 self._antiIceOn.set_tooltip_text(xstr("takeoff_antiice_tooltip")) 2179 table.attach(self._antiIceOn, 2, 4, 6, 7) 2223 table.attach(self._antiIceOn, 2, 4, row, row+1) 2224 2225 row += 1 2180 2226 2181 2227 self._rto = gtk.CheckButton(xstr("takeoff_rto")) … … 2183 2229 self._rto.set_tooltip_text(xstr("takeoff_rto_tooltip")) 2184 2230 self._rto.connect("toggled", self._rtoToggled) 2185 table.attach(self._rto, 2, 4, 7, 8, ypadding = 8)2231 table.attach(self._rto, 2, 4, row, row+1, ypadding = 8) 2186 2232 2187 2233 self.addCancelFlightButton() … … 2190 2236 2191 2237 self._button = self.addNextButton(clicked = self._forwardClicked) 2238 2239 self._active = False 2192 2240 2193 2241 @property … … 2255 2303 print "TakeoffPage.activate" 2256 2304 2305 self._updatingMETAR = True 2306 self._metar.get_buffer().set_text(self._wizard.departureMETAR, -1) 2307 self._updatingMETAR = False 2308 2257 2309 self._runway.set_text("") 2258 2310 self._runway.set_sensitive(True) … … 2286 2338 self._forwardAllowed = False 2287 2339 2340 self._active = True 2341 2288 2342 def allowForward(self): 2289 2343 """Allow going to the next page.""" … … 2302 2356 self._hasDerate = False 2303 2357 self._antiIceOn.set_active(False) 2358 self._active = False 2304 2359 2305 2360 def setRTOEnabled(self, enabled): … … 2308 2363 self._rto.set_active(False) 2309 2364 self._rto.set_sensitive(enabled) 2365 2366 def changeMETAR(self, metar): 2367 """Change the METAR as a result of an edit on one of the other 2368 pages.""" 2369 if self._active: 2370 print "TakeoffPage.changeMETAR" 2371 self._updatingMETAR = True 2372 self._metar.get_buffer().set_text(metar, -1) 2373 self._updatingMETAR = False 2310 2374 2311 2375 def _updateForwardButton(self): … … 2450 2514 self._derateLabel.set_text("") 2451 2515 self._derateLabel.set_sensitive(False) 2516 2517 def _metarChanged(self, entry): 2518 """Called when the METAR has changed.""" 2519 print "TakeoffPage.metarChanged", self._updatingMETAR 2520 if not self._updatingMETAR: 2521 self._updateForwardButton() 2522 self._wizard.metarChanged(entry.get_text(), self) 2523 2524 def _metarInserted(self, entry, text, length, position): 2525 """Called when new characters are inserted into the METAR. 2526 2527 It uppercases all characters.""" 2528 print "TakeoffPage.metarInserted", self._updatingMETAR 2529 if not self._updatingMETAR: 2530 self._updatingMETAR = True 2531 2532 position = entry.get_position() 2533 entry.delete_text(position, position + length) 2534 entry.insert_text(text.upper(), position) 2535 2536 self._updatingMETAR = False 2452 2537 2453 2538 #----------------------------------------------------------------------------- … … 3729 3814 """Called when the cruise level is changed.""" 3730 3815 return self.gui.cruiseLevelChanged() 3816 3817 def metarChanged(self, metar, originator): 3818 """Called when a METER is changed on on of the pages. 3819 3820 originator is the page that originated the changed. It will be used to 3821 determine which METAR (departure or arrival) has changed.""" 3822 metar = metar.upper() 3823 if originator in [self._departureBriefingPage, self._takeoffPage]: 3824 self._departureMETARChanged(metar, originator) 3825 else: 3826 self._arrivalMETARChanged(metar, originator) 3827 3828 def _departureMETARChanged(self, metar, originator): 3829 """Called when the departure METAR has been edited on one of the 3830 pages. 3831 3832 originator is the page that originated the change. It will not be 3833 called to set the METAR, while others will be.""" 3834 for page in [self._departureBriefingPage, self._takeoffPage]: 3835 if page is not originator: 3836 page.changeMETAR(metar) 3837 3838 def _arrivalMETARChanged(self, metar, originator): 3839 """Called when the arrival METAR has been edited on one of the 3840 pages. 3841 3842 originator is the page that originated the change. It will not be 3843 called to set the METAR, while others will be.""" 3844 for page in [self._arrivalBriefingPage]: 3845 if page is not originator: 3846 page.changeMETAR(metar) 3731 3847 3732 3848 def _loginResultCallback(self, returned, result):
Note:
See TracChangeset
for help on using the changeset viewer.