Changeset 184:0a000ef19c3a for src/mlx/gui
- Timestamp:
- 05/16/12 18:04:55 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- src/mlx/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/checklist.py
r175 r184 72 72 73 73 filter = gtk.FileFilter() 74 filter.set_name(xstr(" chklst_filter_all"))74 filter.set_name(xstr("file_filter_all")) 75 75 filter.add_pattern("*.*") 76 76 self._fileChooser.add_filter(filter) -
src/mlx/gui/flight.py
r170 r184 11 11 from mlx.i18n import xstr 12 12 from mlx.sound import startSound 13 import mlx.web as web 13 14 14 15 import datetime … … 215 216 xscale = 0.0, yscale = 0.0) 216 217 217 table = gtk.Table( 2, 3)218 table = gtk.Table(4, 2) 218 219 table.set_row_spacings(4) 219 220 table.set_col_spacings(32) … … 229 230 230 231 self._pilotID = gtk.Entry() 231 self._pilotID.connect("changed", self._set LoginButton)232 self._pilotID.connect("changed", self._setControls) 232 233 self._pilotID.set_tooltip_text(xstr("login_pilotID_tooltip")) 233 234 table.attach(self._pilotID, 1, 2, 0, 1) … … 243 244 self._password = gtk.Entry() 244 245 self._password.set_visibility(False) 245 self._password.connect("changed", self._set LoginButton)246 self._password.connect("changed", self._setControls) 246 247 self._password.set_tooltip_text(xstr("login_password_tooltip")) 247 248 table.attach(self._password, 1, 2, 1, 2) … … 253 254 table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8) 254 255 256 self._entranceExam = gtk.CheckButton(xstr("login_entranceExam")) 257 self._entranceExam.set_use_underline(True) 258 self._entranceExam.set_tooltip_text(xstr("login_entranceExam_tooltip")) 259 self._entranceExam.connect("toggled", self._setControls) 260 table.attach(self._entranceExam, 1, 2, 3, 4, ypadding = 12) 261 255 262 self._loginButton = self.addButton(xstr("button_login"), default = True) 256 self._loginButton.set_sensitive(False)257 263 self._loginButton.connect("clicked", self._loginClicked) 258 self._loginButton.set_tooltip_text(xstr("login_button_tooltip")) 264 self._loginButton.set_tooltip_text(xstr("login_button_tooltip")) 265 266 267 @property 268 def entranceExam(self): 269 """Get whether an entrance exam is being performed.""" 270 return self._entranceExam.get_active() and \ 271 self._pilotID.get_text()!="" 259 272 260 273 def activate(self): … … 264 277 self._password.set_text(config.password) 265 278 self._rememberButton.set_active(config.rememberPassword) 266 267 def _setLoginButton(self, entry): 268 """Set the login button's sensitivity. 269 270 The button is sensitive only if both the pilot ID and the password 271 fields contain values.""" 272 self._loginButton.set_sensitive(self._pilotID.get_text()!="" and 273 self._password.get_text()!="") 279 self._setControls(None) 280 281 def _setControls(self, entry = None): 282 """Set the sensitivity of the various controls. 283 284 The login button is sensitive only if both the pilot ID and the 285 password fields contain values. 286 287 The password field is sensitive only, if the entrance exam checkbox is 288 not selected. 289 290 The remember password checkbox is sensitive only, if the password field 291 contains text. 292 293 The entrance exam checkbox is senstive only, if the pilot ID is not 294 empty.""" 295 pilotID = self._pilotID.get_text() 296 password = self._password.get_text() 297 entranceExam = self._entranceExam.get_active() 298 self._password.set_sensitive(not entranceExam) 299 self._rememberButton.set_sensitive(password!="" and not entranceExam) 300 self._entranceExam.set_sensitive(pilotID!="") 301 self._loginButton.set_sensitive(pilotID!="" and 302 (password!="" or entranceExam)) 274 303 275 304 def _loginClicked(self, button): 276 305 """Called when the login button was clicked.""" 277 self._loginButton.set_sensitive(False)278 306 gui = self._wizard.gui 279 307 gui.beginBusy(xstr("login_busy")) 280 308 gui.webHandler.login(self._loginResultCallback, 281 self._pilotID.get_text(), 282 self._password.get_text()) 309 self._pilotID.get_text(), 310 self._password.get_text(), 311 entranceExam = self.entranceExam) 283 312 284 313 def _loginResultCallback(self, returned, result): … … 306 335 self._wizard.nextPage() 307 336 else: 337 message = xstr("login_entranceExam_invalid" 338 if self.entranceExam else 339 xstr("login_invalid")) 308 340 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, 309 341 type = MESSAGETYPE_ERROR, 310 message_format = xstr("login_invalid"))342 message_format = message) 311 343 dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK) 312 344 dialog.set_title(WINDOW_TITLE_BASE) 313 dialog.format_secondary_markup(xstr("login_invalid_sec")) 345 secondary = xstr("login_entranceExam_invalid_sec" 346 if self.entranceExam else 347 xstr("login_invalid_sec")) 348 dialog.format_secondary_markup(secondary) 314 349 dialog.run() 315 350 dialog.hide() … … 375 410 self.setMainWidget(alignment) 376 411 412 self._loadButton = self.addButton(xstr("flightsel_load"), 413 sensitive = True, 414 tooltip = xstr("flightsel_load_tooltip")) 415 self._loadButton.connect("clicked", self._loadButtonClicked) 416 self._loadDialog = None 417 377 418 self._button = self.addNextButton(sensitive = False, 378 419 clicked = self._forwardClicked) 420 421 self._flights = [] 379 422 380 423 def activate(self): 381 424 """Fill the flight list.""" 382 425 self._flightList.set_sensitive(True) 426 self._flights = [] 383 427 self._listStore.clear() 384 428 for flight in self._wizard.loginResult.flights: 385 self._listStore.append([str(flight.departureTime), 386 flight.callsign, 387 flight.departureICAO, 388 flight.arrivalICAO]) 389 429 self._addFlight(flight) 430 390 431 def finalize(self): 391 432 """Finalize the page.""" 392 433 self._flightList.set_sensitive(False) 393 434 435 def _addFlight(self, flight): 436 """Add the given file to the list of flights.""" 437 self._flights.append(flight) 438 self._listStore.append([str(flight.departureTime), 439 flight.callsign, 440 flight.departureICAO, 441 flight.arrivalICAO]) 442 394 443 def _selectionChanged(self, selection): 395 444 """Called when the selection is changed.""" 396 445 self._button.set_sensitive(selection.count_selected_rows()==1) 397 446 447 def _loadButtonClicked(self, loadButton): 448 """Called when the load a flight button is clicked.""" 449 dialog = self._getLoadDialog() 450 dialog.show_all() 451 response = dialog.run() 452 dialog.hide() 453 454 if response==RESPONSETYPE_OK: 455 fileName = dialog.get_filename() 456 print "Loading", fileName 457 bookedFlight = web.BookedFlight() 458 try: 459 with open(fileName, "rt") as f: 460 bookedFlight.readFromFile(f) 461 self._addFlight(bookedFlight) 462 except Exception, e: 463 print "Failed to load flight:", str(e) 464 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, 465 type = MESSAGETYPE_ERROR, 466 message_format = 467 xstr("flightsel_load_failed")) 468 dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK) 469 dialog.set_title(WINDOW_TITLE_BASE) 470 secondary = xstr("flightsel_load_failed_sec") 471 dialog.format_secondary_markup(secondary) 472 dialog.run() 473 dialog.hide() 474 398 475 def _forwardClicked(self, button): 399 476 """Called when the forward button was clicked.""" … … 406 483 [index] = path.get_indices() if pygobject else path 407 484 408 flight = self._ wizard.loginResult.flights[index]485 flight = self._flights[index] 409 486 self._wizard._bookedFlight = flight 410 487 self._wizard.gui.enableFlightInfo() … … 415 492 """Update the departure gate for the booked flight.""" 416 493 flight = self._wizard._bookedFlight 417 if self._wizard.gui.config.onlineGateSystem: 494 if self._wizard.gui.config.onlineGateSystem and \ 495 not self._wizard.entranceExam: 418 496 if flight.departureICAO=="LHBP": 419 497 self._wizard.getFleet(self._fleetRetrieved) … … 449 527 self._nextDistance = 2 450 528 self._wizard.jumpPage(2) 451 529 530 def _getLoadDialog(self): 531 """Get the dialog to load a flight file.""" 532 if self._loadDialog is not None: 533 return self._loadDialog 534 535 gui = self._wizard.gui 536 dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " + 537 xstr("flightsel_load_title"), 538 action = FILE_CHOOSER_ACTION_OPEN, 539 buttons = (gtk.STOCK_CANCEL, 540 RESPONSETYPE_CANCEL, 541 gtk.STOCK_OK, RESPONSETYPE_OK), 542 parent = gui.mainWindow) 543 dialog.set_modal(True) 544 545 filter = gtk.FileFilter() 546 filter.set_name(xstr("flightsel_filter_flights")) 547 filter.add_pattern("*.vaflight") 548 dialog.add_filter(filter) 549 550 filter = gtk.FileFilter() 551 filter.set_name(xstr("file_filter_all")) 552 filter.add_pattern("*.*") 553 dialog.add_filter(filter) 554 555 self._loadDialog = dialog 556 557 return dialog 558 452 559 #----------------------------------------------------------------------------- 453 560 … … 2036 2143 if self._wizard.gui.config.onlineGateSystem and \ 2037 2144 not self._completed and \ 2038 self._wizard.bookedFlight.arrivalICAO=="LHBP": 2145 self._wizard.bookedFlight.arrivalICAO=="LHBP" and \ 2146 not self._wizard.entranceExam: 2039 2147 self._wizard.getFleet(callback = self._fleetRetrieved, 2040 2148 force = True) … … 2238 2346 self._gatesModel.clear() 2239 2347 if self._wizard.gui.config.onlineGateSystem and \ 2240 self._wizard.bookedFlight.arrivalICAO=="LHBP": 2348 self._wizard.bookedFlight.arrivalICAO=="LHBP" and \ 2349 not self._wizard.entranceExam: 2241 2350 occupiedGates = self._wizard._fleet.getOccupiedGateNumbers() 2242 2351 for gateNumber in const.lhbpGateNumbers: … … 2261 2370 2262 2371 self._saveButton.set_sensitive(sensitive) 2263 self._sendButton.set_sensitive(sensitive) 2372 self._sendButton.set_sensitive(sensitive and 2373 self._wizard.bookedFlight.id is not None) 2264 2374 2265 2375 def _flightTypeChanged(self, comboBox): … … 2339 2449 2340 2450 filter = gtk.FileFilter() 2341 filter.set_name(xstr(" loadPIREP_filter_pireps"))2451 filter.set_name(xstr("file_filter_pireps")) 2342 2452 filter.add_pattern("*.pirep") 2343 2453 dialog.add_filter(filter) 2344 2454 2345 2455 filter = gtk.FileFilter() 2346 filter.set_name(xstr(" loadPIREP_filter_all"))2456 filter.set_name(xstr("file_filter_all")) 2347 2457 filter.add_pattern("*.*") 2348 2458 dialog.add_filter(filter) … … 2361 2471 def _handlePIREPSent(self, returned, result): 2362 2472 """Callback for the PIREP sending result.""" 2363 if self._wizard.gui.config.onlineGateSystem and returned and result.success: 2473 if self._wizard.gui.config.onlineGateSystem and \ 2474 not self._wizard.entranceExam and \ 2475 returned and result.success: 2364 2476 bookedFlight = self._wizard.bookedFlight 2365 2477 if bookedFlight.arrivalICAO=="LHBP": … … 2394 2506 self._pages = [] 2395 2507 self._currentPage = None 2396 2397 self._pages.append(LoginPage(self)) 2508 2509 self._loginPage = LoginPage(self) 2510 self._pages.append(self._loginPage) 2398 2511 self._pages.append(FlightSelectionPage(self)) 2399 2512 self._pages.append(GateSelectionPage(self)) … … 2432 2545 2433 2546 self._initialize() 2547 2548 @property 2549 def entranceExam(self): 2550 """Get whether an entrance exam is about to be taken.""" 2551 return self._loginPage.entranceExam 2434 2552 2435 2553 @property -
src/mlx/gui/gui.py
r182 r184 179 179 return self._flight 180 180 181 @property 182 def entranceExam(self): 183 """Get whether an entrance exam is about to be taken.""" 184 return self._wizard.entranceExam 185 181 186 @property 182 187 def loginResult(self): … … 977 982 978 983 filter = gtk.FileFilter() 979 filter.set_name(xstr(" loadPIREP_filter_pireps"))984 filter.set_name(xstr("file_filter_pireps")) 980 985 filter.add_pattern("*.pirep") 981 986 dialog.add_filter(filter) 982 987 983 988 filter = gtk.FileFilter() 984 filter.set_name(xstr(" loadPIREP_filter_all"))989 filter.set_name(xstr("file_filter_all")) 985 990 filter.add_pattern("*.*") 986 991 dialog.add_filter(filter)
Note:
See TracChangeset
for help on using the changeset viewer.