Changeset 138:bc4d9d192a7b for src/mlx/gui
- Timestamp:
- 05/01/12 07:11:34 (13 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r136 r138 1027 1027 else gtk.POLICY_AUTOMATIC) 1028 1028 1029 self._uppercasingRoute = False 1030 1029 1031 self._route = gtk.TextView() 1030 1032 self._route.set_tooltip_text(xstr("route_route_tooltip")) 1033 self._route.set_wrap_mode(WRAP_WORD) 1031 1034 self._route.get_buffer().connect("changed", self._routeChanged) 1035 self._route.get_buffer().connect_after("insert-text", self._routeInserted) 1032 1036 routeWindow.add(self._route) 1033 1037 … … 1079 1083 def _routeChanged(self, textBuffer): 1080 1084 """Called when the route has changed.""" 1081 self._updateForwardButton() 1085 if not self._uppercasingRoute: 1086 self._updateForwardButton() 1087 1088 def _routeInserted(self, textBuffer, iter, text, length): 1089 """Called when new characters are inserted into the route. 1090 1091 It uppercases all characters.""" 1092 if not self._uppercasingRoute: 1093 self._uppercasingRoute = True 1094 1095 iter1 = iter.copy() 1096 iter1.backward_chars(length) 1097 textBuffer.delete(iter, iter1) 1098 1099 textBuffer.insert(iter, text.upper()) 1100 1101 self._uppercasingRoute = False 1082 1102 1083 1103 def _backClicked(self, button): … … 1188 1208 gtk.PolicyType.AUTOMATIC if pygobject 1189 1209 else gtk.POLICY_AUTOMATIC) 1210 1211 self._uppercasingMETAR = False 1212 1190 1213 self._metar = gtk.TextView() 1191 1214 self._metar.set_accepts_tab(False) 1192 1215 self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD) 1193 1216 self._metar.get_buffer().connect("changed", self._metarChanged) 1217 self._metar.get_buffer().connect_after("insert-text", self._metarInserted) 1194 1218 scrolledWindow.add(self._metar) 1195 1219 alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0, … … 1284 1308 def _metarChanged(self, buffer): 1285 1309 """Called when the METAR has changed.""" 1286 self.metarEdited = True 1287 self._button.set_sensitive(buffer.get_text(buffer.get_start_iter(), 1288 buffer.get_end_iter(), 1289 True)!="") 1310 if not self._uppercasingMETAR: 1311 self.metarEdited = True 1312 self._button.set_sensitive(buffer.get_text(buffer.get_start_iter(), 1313 buffer.get_end_iter(), 1314 True)!="") 1315 1316 def _metarInserted(self, textBuffer, iter, text, length): 1317 """Called when new characters are inserted into the METAR. 1318 1319 It uppercases all characters.""" 1320 if not self._uppercasingMETAR: 1321 self._uppercasingMETAR = True 1322 1323 iter1 = iter.copy() 1324 iter1.backward_chars(length) 1325 textBuffer.delete(iter, iter1) 1326 1327 textBuffer.insert(iter, text.upper()) 1328 1329 self._uppercasingMETAR = False 1290 1330 1291 1331 #----------------------------------------------------------------------------- … … 1319 1359 self._runway.set_width_chars(10) 1320 1360 self._runway.set_tooltip_text(xstr("takeoff_runway_tooltip")) 1321 self._runway.connect("changed", self._ valueChanged)1361 self._runway.connect("changed", self._upperChanged) 1322 1362 table.attach(self._runway, 1, 3, 0, 1) 1323 1363 label.set_mnemonic_widget(self._runway) … … 1331 1371 self._sid.set_width_chars(10) 1332 1372 self._sid.set_tooltip_text(xstr("takeoff_sid_tooltip")) 1333 self._sid.connect("changed", self._ valueChanged)1373 self._sid.connect("changed", self._upperChanged) 1334 1374 table.attach(self._sid, 1, 3, 1, 2) 1335 1375 label.set_mnemonic_widget(self._sid) … … 1453 1493 self._updateForwardButton() 1454 1494 1495 def _upperChanged(self, entry, arg = None): 1496 """Called when the value of some entry widget has changed and the value 1497 should be converted to uppercase.""" 1498 entry.set_text(entry.get_text().upper()) 1499 self._valueChanged(entry, arg) 1500 1455 1501 def _backClicked(self, button): 1456 1502 """Called when the Back button is pressed.""" … … 1495 1541 self._star.set_width_chars(10) 1496 1542 self._star.set_tooltip_text(xstr("landing_star_tooltip")) 1497 self._star.connect("changed", self._up dateForwardButton)1543 self._star.connect("changed", self._upperChanged) 1498 1544 self._star.set_sensitive(False) 1499 1545 table.attach(self._star, 2, 4, 0, 1) … … 1512 1558 self._transition.set_width_chars(10) 1513 1559 self._transition.set_tooltip_text(xstr("landing_transition_tooltip")) 1514 self._transition.connect("changed", self._up dateForwardButton)1560 self._transition.connect("changed", self._upperChanged) 1515 1561 self._transition.set_sensitive(False) 1516 1562 table.attach(self._transition, 2, 4, 1, 2) … … 1525 1571 self._runway.set_width_chars(10) 1526 1572 self._runway.set_tooltip_text(xstr("landing_runway_tooltip")) 1527 self._runway.connect("changed", self._up dateForwardButton)1573 self._runway.connect("changed", self._upperChanged) 1528 1574 table.attach(self._runway, 2, 4, 2, 3) 1529 1575 label.set_mnemonic_widget(self._runway) … … 1537 1583 self._approachType.set_width_chars(10) 1538 1584 self._approachType.set_tooltip_text(xstr("landing_approach_tooltip")) 1539 self._approachType.connect("changed", self._up dateForwardButton)1585 self._approachType.connect("changed", self._upperChanged) 1540 1586 table.attach(self._approachType, 2, 4, 3, 4) 1541 1587 label.set_mnemonic_widget(self._approachType) … … 1650 1696 self._updateForwardButton() 1651 1697 1652 def _updateForwardButton(self , widget = None):1698 def _updateForwardButton(self): 1653 1699 """Update the sensitivity of the forward button.""" 1654 1700 sensitive = self._flightEnded and \ … … 1663 1709 self.vref is not None 1664 1710 self._button.set_sensitive(sensitive) 1711 1712 def _upperChanged(self, entry): 1713 """Called for entry widgets that must be converted to uppercase.""" 1714 entry.set_text(entry.get_text().upper()) 1715 self._updateForwardButton() 1665 1716 1666 1717 def _vrefChanged(self, widget, value):
Note:
See TracChangeset
for help on using the changeset viewer.