Changeset 853:28eb49544c0f for src
- Timestamp:
- 05/21/17 07:42:48 (8 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/gui.py
r845 r853 1266 1266 self._pirepEditor.setPIREP(pirep) 1267 1267 self._pirepEditor.show_all() 1268 self._pirepEditor.run() 1268 if self._pirepEditor.run()==RESPONSETYPE_OK: 1269 self.beginBusy(xstr("pirepEdit_save_busy")) 1270 self.webHandler.sendPIREP(self._pirepUpdatedCallback, pirep, 1271 update = True) 1272 else: 1273 self._pirepEditor.hide() 1274 1275 def _pirepUpdatedCallback(self, returned, result): 1276 """Callback for the PIREP updating result.""" 1277 gobject.idle_add(self._handlePIREPUpdated, returned, result) 1278 1279 def _handlePIREPUpdated(self, returned, result): 1280 """Callback for the PIREP updating result.""" 1281 self.endBusy() 1282 secondaryMarkup = None 1283 type = MESSAGETYPE_ERROR 1284 if returned: 1285 if result.success: 1286 type = None 1287 elif result.alreadyFlown: 1288 messageFormat = xstr("sendPIREP_already") 1289 secondaryMarkup = xstr("sendPIREP_already_sec") 1290 elif result.notAvailable: 1291 messageFormat = xstr("sendPIREP_notavail") 1292 else: 1293 messageFormat = xstr("sendPIREP_unknown") 1294 secondaryMarkup = xstr("sendPIREP_unknown_sec") 1295 else: 1296 print "PIREP sending failed", result 1297 messageFormat = xstr("sendPIREP_failed") 1298 secondaryMarkup = xstr("sendPIREP_failed_sec") 1299 1300 if type is not None: 1301 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, 1302 type = type, message_format = messageFormat) 1303 dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK) 1304 dialog.set_title(WINDOW_TITLE_BASE) 1305 if secondaryMarkup is not None: 1306 dialog.format_secondary_markup(secondaryMarkup) 1307 1308 dialog.run() 1309 dialog.hide() 1310 1269 1311 self._pirepEditor.hide() 1270 1312 -
src/mlx/gui/pirep.py
r849 r853 720 720 self.add_button(xstr("button_cancel"), RESPONSETYPE_CANCEL) 721 721 722 self._okButton = self.add_button(xstr("button_save"), RESPONSETYPE_OK) 722 self._okButton = self.add_button(xstr("button_save"), RESPONSETYPE_NONE) 723 self._okButton.connect("clicked", self._okClicked) 723 724 self._okButton.set_can_default(True) 724 725 self._modified = False 726 self._toSave = False 725 727 726 728 def setPIREP(self, pirep): … … 846 848 self._updateButtons() 847 849 self._modified = True 850 self._toSave = False 848 851 849 852 def delayCodesChanged(self): … … 1363 1366 self._approachType.get_text()!="") 1364 1367 1368 def _okClicked(self, button): 1369 """Called when the OK button has been clicked. 1370 1371 The PIREP is updated from the data in the window.""" 1372 if not askYesNo(xstr("pirepEdit_save_question"), parent = self): 1373 self.response(RESPONSETYPE_CANCEL) 1374 1375 pirep = self._pirep 1376 1377 pirep.filedCruiseAltitude = \ 1378 self._filedCruiseLevel.get_value_as_int() * 100 1379 pirep.cruiseAltitude = \ 1380 self._modifiedCruiseLevel.get_value_as_int() * 100 1381 1382 pirep.route = getTextViewText(self._userRoute) 1383 1384 pirep.departureMETAR = getTextViewText(self._departureMETAR) 1385 pirep.departureRunway = self._departureRunway.get_text() 1386 pirep.sid = self._sid.get_child().get_text() 1387 1388 pirep.arrivalMETAR = getTextViewText(self._arrivalMETAR) 1389 pirep.star = None if self._star.get_active()==0 \ 1390 else self._star.get_child().get_text() 1391 pirep.transition = None if self._transition.get_active()==0 \ 1392 else self._transition.get_child().get_text() 1393 pirep.approachType = self._approachType.get_text() 1394 pirep.arrivalRunway = self._arrivalRunway.get_text() 1395 1396 pirep.blockTimeStart = \ 1397 self._blockTimeStart.getTimestampFrom(pirep.blockTimeStart) 1398 pirep.blockTimeEnd = \ 1399 self._blockTimeEnd.getTimestampFrom(pirep.blockTimeEnd) 1400 pirep.flightTimeStart = \ 1401 self._flightTimeStart.getTimestampFrom(pirep.flightTimeStart) 1402 pirep.flightTimeEnd = \ 1403 self._flightTimeEnd.getTimestampFrom(pirep.flightTimeEnd) 1404 1405 pirep.fuelUsed = self._fuelUsed.get_value() 1406 1407 pirep.numCrew = self._flownNumCrew.get_value() 1408 pirep.numPassengers = self._flownNumPassengers.get_value() 1409 pirep.bagWeight = self._flownBagWeight.get_value() 1410 pirep.cargoWeight = self._flownCargoWeight.get_value() 1411 pirep.mailWeight = self._flownMailWeight.get_value() 1412 1413 pirep.flightType = flightTypes[self._flightType.get_active()] 1414 pirep.online = self._online.get_active() 1415 1416 pirep.delayCodes = self._flightInfo.delayCodes 1417 pirep.comments = self._flightInfo.comments 1418 pirep.flightDefects = self._flightInfo.faultsAndExplanations 1419 1420 self.response(RESPONSETYPE_OK) 1421 1422 1365 1423 #------------------------------------------------------------------------------ -
src/mlx/rpc.py
r829 r853 321 321 status, gateNumber)) 322 322 323 def addPIREP(self, flightID, pirep ):323 def addPIREP(self, flightID, pirep, update = False): 324 324 """Add the PIREP for the given flight.""" 325 325 (result, _value) = \ 326 326 self._performCall(lambda sessionID: 327 self._server.addPIREP(sessionID, flightID, pirep), 327 self._server.addPIREP(sessionID, flightID, pirep, 328 update), 328 329 acceptResults = [Client.RESULT_FLIGHT_ALREADY_REPORTED, 329 330 Client.RESULT_FLIGHT_NOT_EXISTS]) -
src/mlx/web.py
r829 r853 1144 1144 """A request to send a PIREP to the MAVA website via the RPC interface.""" 1145 1145 1146 def __init__(self, client, callback, pirep ):1146 def __init__(self, client, callback, pirep, update): 1147 1147 """Construct the sending of the PIREP.""" 1148 1148 super(SendPIREPRPC, self).__init__(client, callback) 1149 1149 self._pirep = pirep 1150 self._update = update 1150 1151 1151 1152 def run(self): 1152 1153 """Perform the sending of the PIREP.""" 1153 1154 pirep = self._pirep 1154 resultCode = self._client.addPIREP(pirep.bookedFlight.id, pirep) 1155 resultCode = self._client.addPIREP(pirep.bookedFlight.id, pirep, 1156 self._update) 1155 1157 1156 1158 result = Result() … … 1286 1288 print "pirepData:", pirepData 1287 1289 1288 bookedFlight = BookedFlight( )1290 bookedFlight = BookedFlight(self._flightID) 1289 1291 bookedFlight.setupFromPIREPData(pirepData) 1290 1292 … … 1382 1384 self._addRequest(GetMETARs(callback, airports)) 1383 1385 1384 def sendPIREP(self, callback, pirep ):1386 def sendPIREP(self, callback, pirep, update = False): 1385 1387 """Send the given PIREP.""" 1386 1388 request = \ 1387 SendPIREPRPC(self._rpcClient, callback, pirep ) if self._config.useRPC\1388 else SendPIREP(callback, pirep)1389 SendPIREPRPC(self._rpcClient, callback, pirep, update) \ 1390 if self._config.useRPC else SendPIREP(callback, pirep) 1389 1391 self._addRequest(request) 1390 1392
Note:
See TracChangeset
for help on using the changeset viewer.