[42] | 1 |
|
---|
| 2 | from mlx.gui.common import *
|
---|
[687] | 3 | import mlx.gui.cef as cef
|
---|
[819] | 4 | from mlx.gui.flightlist import ColumnDescriptor, FlightList, PendingFlightsWindow
|
---|
[42] | 5 |
|
---|
[51] | 6 | import mlx.const as const
|
---|
| 7 | import mlx.fs as fs
|
---|
[141] | 8 | import mlx.acft as acft
|
---|
[383] | 9 | from mlx.flight import Flight
|
---|
[60] | 10 | from mlx.checks import PayloadChecker
|
---|
[619] | 11 | from mlx.gates import lhbpGates
|
---|
[89] | 12 | import mlx.util as util
|
---|
[97] | 13 | from mlx.pirep import PIREP
|
---|
[759] | 14 | from mlx.i18n import xstr, getLanguage
|
---|
[170] | 15 | from mlx.sound import startSound
|
---|
[184] | 16 | import mlx.web as web
|
---|
[51] | 17 |
|
---|
[61] | 18 | import datetime
|
---|
| 19 | import time
|
---|
[393] | 20 | import os
|
---|
[687] | 21 | import tempfile
|
---|
[700] | 22 | import threading
|
---|
[753] | 23 | import re
|
---|
[764] | 24 | import webbrowser
|
---|
[61] | 25 |
|
---|
[42] | 26 | #-----------------------------------------------------------------------------
|
---|
| 27 |
|
---|
[300] | 28 | ## @package mlx.gui.flight
|
---|
| 29 | #
|
---|
| 30 | # The flight "wizard".
|
---|
| 31 | #
|
---|
| 32 | # This module implements the main tab of the application, the flight
|
---|
| 33 | # wizard. The wizard consists of \ref Page "pages", that come one after the
|
---|
| 34 | # other. As some pages might be skipped, the pages dynamically store the index
|
---|
| 35 | # of the previous page so that going back to it is simpler. The \ref
|
---|
| 36 | # Page.activate "activate" function is called before a page is first shown
|
---|
| 37 | # during a flight. This function should initialize the page's controls and fill
|
---|
| 38 | # it with initial data. When a page is left for the first time, its \ref
|
---|
| 39 | # Page.finalize "finalize" function is called. It should set those controls
|
---|
| 40 | # insensitive, that will not be available if the user comes back to this page.
|
---|
| 41 | #
|
---|
| 42 | # Each page has a title at the top displayed in inverted colors and a big
|
---|
| 43 | # font. There is a help text below it centered, that shortly describes what is
|
---|
| 44 | # expected on the page. There can be two help texts: one shown when the page is
|
---|
| 45 | # first displayed during a flight, another shown when the user goes back to the
|
---|
| 46 | # page. The main content area is below this, also centered. Finally, there are
|
---|
| 47 | # some buttons at the bottom on the right. As some buttons occur very
|
---|
| 48 | # frequently, there are functions to add them (\ref Page.addCancelFlightButton
|
---|
| 49 | # "addCancelFlightButton", \ref Page.addPreviousButton "addPreviousButton" and
|
---|
| 50 | # \ref Page.addNextButton "addNextButton".
|
---|
| 51 | #
|
---|
| 52 | # The \ref Wizard class is the main class to collect the pages. It also stores
|
---|
| 53 | # some data passed from one page to another and provides properties to access
|
---|
| 54 | # data items set via the wizard pages.
|
---|
| 55 |
|
---|
| 56 | #-----------------------------------------------------------------------------
|
---|
| 57 |
|
---|
[621] | 58 | comboModel = gtk.ListStore(gobject.TYPE_STRING)
|
---|
| 59 | comboModel.append(("N/A",))
|
---|
| 60 | comboModel.append(("VECTORS",))
|
---|
| 61 |
|
---|
| 62 | #-----------------------------------------------------------------------------
|
---|
| 63 |
|
---|
[44] | 64 | class Page(gtk.Alignment):
|
---|
[42] | 65 | """A page in the flight wizard."""
|
---|
[754] | 66 | def __init__(self, wizard, id, title, help, completedHelp = None):
|
---|
[42] | 67 | """Construct the page."""
|
---|
[44] | 68 | super(Page, self).__init__(xalign = 0.0, yalign = 0.0,
|
---|
| 69 | xscale = 1.0, yscale = 1.0)
|
---|
| 70 | self.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 71 | padding_left = 12, padding_right = 12)
|
---|
| 72 |
|
---|
| 73 | frame = gtk.Frame()
|
---|
| 74 | self.add(frame)
|
---|
| 75 |
|
---|
| 76 | self._vbox = gtk.VBox()
|
---|
[48] | 77 | self._vbox.set_homogeneous(False)
|
---|
[44] | 78 | frame.add(self._vbox)
|
---|
| 79 |
|
---|
| 80 | eventBox = gtk.EventBox()
|
---|
| 81 |
|
---|
| 82 | alignment = gtk.Alignment(xalign = 0.0, xscale = 0.0)
|
---|
[347] | 83 |
|
---|
[201] | 84 | titleLabel = gtk.Label(title)
|
---|
| 85 | titleLabel.modify_font(pango.FontDescription("bold 24"))
|
---|
[44] | 86 | alignment.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 87 | padding_left = 6, padding_right = 0)
|
---|
[347] | 88 |
|
---|
[201] | 89 | alignment.add(titleLabel)
|
---|
[44] | 90 | eventBox.add(alignment)
|
---|
[347] | 91 |
|
---|
[44] | 92 | self._vbox.pack_start(eventBox, False, False, 0)
|
---|
| 93 |
|
---|
[201] | 94 | self._titleEventBox = eventBox
|
---|
| 95 | self._titleLabel = titleLabel
|
---|
| 96 |
|
---|
[347] | 97 | mainBox = gtk.VBox()
|
---|
[48] | 98 |
|
---|
| 99 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[347] | 100 | xscale = 1.0, yscale = 1.0)
|
---|
[48] | 101 | alignment.set_padding(padding_top = 16, padding_bottom = 16,
|
---|
| 102 | padding_left = 16, padding_right = 16)
|
---|
[79] | 103 | alignment.add(mainBox)
|
---|
[48] | 104 | self._vbox.pack_start(alignment, True, True, 0)
|
---|
[347] | 105 |
|
---|
[48] | 106 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
[94] | 107 | xscale = 0.0, yscale = 0.0)
|
---|
[50] | 108 | alignment.set_padding(padding_top = 0, padding_bottom = 16,
|
---|
| 109 | padding_left = 0, padding_right = 0)
|
---|
[48] | 110 |
|
---|
[94] | 111 | self._help = help
|
---|
| 112 | self._completedHelp = completedHelp
|
---|
| 113 |
|
---|
| 114 | if self._completedHelp is None or \
|
---|
| 115 | len(help.splitlines())>=len(completedHelp.splitlines()):
|
---|
| 116 | longerHelp = help
|
---|
| 117 | else:
|
---|
| 118 | longerHelp = completedHelp
|
---|
[347] | 119 |
|
---|
[556] | 120 | self._helpLabel = gtk.Label(longerHelp)
|
---|
[94] | 121 | # FIXME: should be a constant in common
|
---|
| 122 | self._helpLabel.set_justify(gtk.Justification.CENTER if pygobject
|
---|
| 123 | else gtk.JUSTIFY_CENTER)
|
---|
| 124 | self._helpLabel.set_use_markup(True)
|
---|
| 125 | alignment.add(self._helpLabel)
|
---|
[79] | 126 | mainBox.pack_start(alignment, False, False, 0)
|
---|
[44] | 127 |
|
---|
| 128 | self._mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[48] | 129 | xscale = 1.0, yscale = 1.0)
|
---|
[79] | 130 | mainBox.pack_start(self._mainAlignment, True, True, 0)
|
---|
[347] | 131 |
|
---|
[48] | 132 | buttonAlignment = gtk.Alignment(xalign = 1.0, xscale=0.0, yscale = 0.0)
|
---|
[44] | 133 | buttonAlignment.set_padding(padding_top = 4, padding_bottom = 10,
|
---|
| 134 | padding_left = 16, padding_right = 16)
|
---|
| 135 |
|
---|
[70] | 136 | self._buttonBox = gtk.HBox()
|
---|
| 137 | self._buttonBox.set_homogeneous(False)
|
---|
[46] | 138 | self._defaultButton = None
|
---|
[44] | 139 | buttonAlignment.add(self._buttonBox)
|
---|
| 140 |
|
---|
| 141 | self._vbox.pack_start(buttonAlignment, False, False, 0)
|
---|
| 142 |
|
---|
[42] | 143 | self._wizard = wizard
|
---|
[754] | 144 | self._id = id
|
---|
| 145 | self._nextPageID = None
|
---|
[42] | 146 |
|
---|
[275] | 147 | self._cancelFlightButton = None
|
---|
| 148 |
|
---|
[94] | 149 | self._completed = False
|
---|
[70] | 150 | self._fromPage = None
|
---|
| 151 |
|
---|
[754] | 152 | @property
|
---|
| 153 | def id(self):
|
---|
| 154 | """Get the identifier of the page."""
|
---|
| 155 | return self._id
|
---|
| 156 |
|
---|
| 157 | @property
|
---|
| 158 | def nextPageID(self):
|
---|
| 159 | """Get the identifier of the next page, if set."""
|
---|
| 160 | return self._nextPageID
|
---|
| 161 |
|
---|
| 162 | @nextPageID.setter
|
---|
| 163 | def nextPageID(self, nextPageID):
|
---|
| 164 | """Set the identifier of the next page."""
|
---|
| 165 | self._nextPageID = nextPageID
|
---|
| 166 |
|
---|
[44] | 167 | def setMainWidget(self, widget):
|
---|
| 168 | """Set the given widget as the main one."""
|
---|
| 169 | self._mainAlignment.add(widget)
|
---|
| 170 |
|
---|
[107] | 171 | def addButton(self, label, default = False, sensitive = True,
|
---|
[769] | 172 | tooltip = None, clicked = None, padding = 4,
|
---|
| 173 | clickedArg = None):
|
---|
[44] | 174 | """Add a button with the given label.
|
---|
| 175 |
|
---|
| 176 | Return the button object created."""
|
---|
| 177 | button = gtk.Button(label)
|
---|
[208] | 178 | self._buttonBox.pack_start(button, False, False, padding)
|
---|
[48] | 179 | button.set_use_underline(True)
|
---|
[46] | 180 | if default:
|
---|
| 181 | button.set_can_default(True)
|
---|
| 182 | self._defaultButton = button
|
---|
[107] | 183 | button.set_sensitive(sensitive)
|
---|
| 184 | if tooltip is not None:
|
---|
| 185 | button.set_tooltip_text(tooltip)
|
---|
| 186 | if clicked is not None:
|
---|
[769] | 187 | if clickedArg is None:
|
---|
| 188 | button.connect("clicked", clicked)
|
---|
| 189 | else:
|
---|
| 190 | button.connect("clicked", clicked, clickedArg)
|
---|
[44] | 191 | return button
|
---|
| 192 |
|
---|
[208] | 193 | def addCancelFlightButton(self):
|
---|
| 194 | """Add the 'Cancel flight' button to the page."""
|
---|
[275] | 195 | self._cancelFlightButton = \
|
---|
| 196 | self.addButton(xstr("button_cancelFlight"),
|
---|
| 197 | sensitive = True,
|
---|
| 198 | tooltip = xstr("button_cancelFlight_tooltip"),
|
---|
| 199 | clicked = self._cancelFlight,
|
---|
| 200 | padding = 16)
|
---|
| 201 | return self._cancelFlightButton
|
---|
[208] | 202 |
|
---|
[107] | 203 | def addPreviousButton(self, sensitive = True, clicked = None):
|
---|
| 204 | """Add the 'Next' button to the page."""
|
---|
| 205 | return self.addButton(xstr("button_previous"),
|
---|
| 206 | sensitive = sensitive,
|
---|
| 207 | tooltip = xstr("button_previous_tooltip"),
|
---|
| 208 | clicked = clicked)
|
---|
| 209 |
|
---|
| 210 | def addNextButton(self, default = True, sensitive = True,
|
---|
| 211 | clicked = None):
|
---|
| 212 | """Add the 'Next' button to the page."""
|
---|
| 213 | return self.addButton(xstr("button_next"),
|
---|
| 214 | default = default,
|
---|
| 215 | sensitive = sensitive,
|
---|
| 216 | tooltip = xstr("button_next_tooltip"),
|
---|
| 217 | clicked = clicked)
|
---|
| 218 |
|
---|
[201] | 219 | def setStyle(self):
|
---|
| 220 | """Set the styles of some of the items on the page."""
|
---|
[413] | 221 | if pygobject:
|
---|
| 222 | context = self.get_style_context()
|
---|
| 223 | color = context.get_background_color(gtk.StateFlags.SELECTED)
|
---|
| 224 | self._titleEventBox.modify_bg(0, color.to_color())
|
---|
| 225 | color = context.get_color(gtk.StateFlags.SELECTED)
|
---|
| 226 | self._titleLabel.modify_fg(0, color.to_color())
|
---|
| 227 | else:
|
---|
| 228 | style = self.rc_get_style()
|
---|
| 229 | self._titleEventBox.modify_bg(0, style.bg[3])
|
---|
| 230 | self._titleLabel.modify_fg(0, style.fg[3])
|
---|
[347] | 231 |
|
---|
[94] | 232 | def initialize(self):
|
---|
| 233 | """Initialize the page.
|
---|
| 234 |
|
---|
| 235 | It sets up the primary help, and calls the activate() function."""
|
---|
| 236 | self._helpLabel.set_markup(self._help)
|
---|
| 237 | self._helpLabel.set_sensitive(True)
|
---|
| 238 | self.activate()
|
---|
| 239 |
|
---|
[48] | 240 | def activate(self):
|
---|
| 241 | """Called when this page becomes active.
|
---|
| 242 |
|
---|
| 243 | This default implementation does nothing."""
|
---|
| 244 | pass
|
---|
| 245 |
|
---|
[563] | 246 | def setHelp(self, help):
|
---|
| 247 | """Set the help string."""
|
---|
| 248 | self._help = help
|
---|
| 249 | if not self._completed:
|
---|
| 250 | self._helpLabel.set_markup(self._help)
|
---|
| 251 | self._helpLabel.set_sensitive(True)
|
---|
| 252 |
|
---|
[94] | 253 | def complete(self):
|
---|
| 254 | """Called when the page is completed.
|
---|
| 255 |
|
---|
| 256 | It greys out/changes the help text and then calls finalize()."""
|
---|
| 257 | self.finalize()
|
---|
| 258 | if self._completedHelp is None:
|
---|
| 259 | self._helpLabel.set_sensitive(False)
|
---|
| 260 | else:
|
---|
| 261 | self._helpLabel.set_markup(self._completedHelp)
|
---|
| 262 | self._completed = True
|
---|
| 263 |
|
---|
[70] | 264 | def finalize(self):
|
---|
| 265 | """Called when the page is finalized."""
|
---|
| 266 | pass
|
---|
| 267 |
|
---|
[46] | 268 | def grabDefault(self):
|
---|
| 269 | """If the page has a default button, make it the default one."""
|
---|
| 270 | if self._defaultButton is not None:
|
---|
| 271 | self._defaultButton.grab_default()
|
---|
[67] | 272 |
|
---|
| 273 | def reset(self):
|
---|
| 274 | """Reset the page if the wizard is reset."""
|
---|
[94] | 275 | self._completed = False
|
---|
[70] | 276 | self._fromPage = None
|
---|
[275] | 277 | if self._cancelFlightButton is not None:
|
---|
| 278 | self._cancelFlightButton.set_sensitive(True)
|
---|
[70] | 279 |
|
---|
| 280 | def goBack(self):
|
---|
| 281 | """Go to the page we were invoked from."""
|
---|
| 282 | assert self._fromPage is not None
|
---|
[347] | 283 |
|
---|
[70] | 284 | self._wizard.setCurrentPage(self._fromPage, finalize = False)
|
---|
[208] | 285 |
|
---|
[275] | 286 | def flightEnded(self):
|
---|
| 287 | """Called when the flight has ended.
|
---|
| 288 |
|
---|
| 289 | This default implementation disables the cancel flight button."""
|
---|
| 290 | if self._cancelFlightButton is not None:
|
---|
| 291 | self._cancelFlightButton.set_sensitive(False)
|
---|
| 292 |
|
---|
[208] | 293 | def _cancelFlight(self, button):
|
---|
| 294 | """Called when the Cancel flight button is clicked."""
|
---|
| 295 | self._wizard.gui.cancelFlight()
|
---|
[347] | 296 |
|
---|
[42] | 297 | #-----------------------------------------------------------------------------
|
---|
| 298 |
|
---|
| 299 | class LoginPage(Page):
|
---|
| 300 | """The login page."""
|
---|
| 301 | def __init__(self, wizard):
|
---|
| 302 | """Construct the login page."""
|
---|
[754] | 303 | super(LoginPage, self).__init__(wizard, "login",
|
---|
| 304 | xstr("login"), xstr("loginHelp"))
|
---|
[42] | 305 |
|
---|
[48] | 306 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 307 | xscale = 0.0, yscale = 0.0)
|
---|
[139] | 308 |
|
---|
[760] | 309 | table = gtk.Table(3, 2)
|
---|
[42] | 310 | table.set_row_spacings(4)
|
---|
| 311 | table.set_col_spacings(32)
|
---|
[48] | 312 | alignment.add(table)
|
---|
| 313 | self.setMainWidget(alignment)
|
---|
[42] | 314 |
|
---|
[107] | 315 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 316 | xscale = 0.0, yscale = 0.0)
|
---|
| 317 | label = gtk.Label(xstr("label_pilotID"))
|
---|
[45] | 318 | label.set_use_underline(True)
|
---|
| 319 | labelAlignment.add(label)
|
---|
[42] | 320 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 321 |
|
---|
| 322 | self._pilotID = gtk.Entry()
|
---|
[578] | 323 | self._pilotID.connect("changed", self._pilotIDChanged)
|
---|
[107] | 324 | self._pilotID.set_tooltip_text(xstr("login_pilotID_tooltip"))
|
---|
[42] | 325 | table.attach(self._pilotID, 1, 2, 0, 1)
|
---|
[45] | 326 | label.set_mnemonic_widget(self._pilotID)
|
---|
[42] | 327 |
|
---|
[107] | 328 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 329 | xscale = 0.0, yscale = 0.0)
|
---|
| 330 | label = gtk.Label(xstr("label_password"))
|
---|
[45] | 331 | label.set_use_underline(True)
|
---|
| 332 | labelAlignment.add(label)
|
---|
[42] | 333 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 334 |
|
---|
| 335 | self._password = gtk.Entry()
|
---|
| 336 | self._password.set_visibility(False)
|
---|
[184] | 337 | self._password.connect("changed", self._setControls)
|
---|
[107] | 338 | self._password.set_tooltip_text(xstr("login_password_tooltip"))
|
---|
[42] | 339 | table.attach(self._password, 1, 2, 1, 2)
|
---|
[45] | 340 | label.set_mnemonic_widget(self._password)
|
---|
[42] | 341 |
|
---|
[107] | 342 | self._rememberButton = gtk.CheckButton(xstr("remember_password"))
|
---|
[45] | 343 | self._rememberButton.set_use_underline(True)
|
---|
[107] | 344 | self._rememberButton.set_tooltip_text(xstr("login_remember_tooltip"))
|
---|
[45] | 345 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
| 346 |
|
---|
[753] | 347 | self.addButton(xstr("button_login_register"),
|
---|
| 348 | clicked = self._registerClicked,
|
---|
| 349 | tooltip = xstr("button_login_register_tooltip"))
|
---|
| 350 |
|
---|
[215] | 351 | self.addButton(xstr("button_offline"),
|
---|
| 352 | clicked = self._offlineClicked,
|
---|
| 353 | tooltip = xstr("button_offline_tooltip"))
|
---|
| 354 |
|
---|
[107] | 355 | self._loginButton = self.addButton(xstr("button_login"), default = True)
|
---|
[42] | 356 | self._loginButton.connect("clicked", self._loginClicked)
|
---|
[184] | 357 | self._loginButton.set_tooltip_text(xstr("login_button_tooltip"))
|
---|
| 358 |
|
---|
| 359 |
|
---|
| 360 | @property
|
---|
[215] | 361 | def pilotID(self):
|
---|
| 362 | """Get the pilot ID, if given."""
|
---|
| 363 | return self._pilotID.get_text()
|
---|
| 364 |
|
---|
[92] | 365 | def activate(self):
|
---|
| 366 | """Activate the page."""
|
---|
[42] | 367 | config = self._wizard.gui.config
|
---|
| 368 | self._pilotID.set_text(config.pilotID)
|
---|
| 369 | self._password.set_text(config.password)
|
---|
[45] | 370 | self._rememberButton.set_active(config.rememberPassword)
|
---|
[347] | 371 | self._setControls(None)
|
---|
[184] | 372 |
|
---|
[578] | 373 | def _pilotIDChanged(self, entry):
|
---|
| 374 | """Called when the pilot ID has changed.
|
---|
| 375 |
|
---|
| 376 | It sets the text to upper-case and calls _setControls to update other
|
---|
| 377 | stuff."""
|
---|
| 378 | entry.set_text(entry.get_text().upper())
|
---|
| 379 | self._setControls(entry)
|
---|
| 380 |
|
---|
[184] | 381 | def _setControls(self, entry = None):
|
---|
| 382 | """Set the sensitivity of the various controls.
|
---|
| 383 |
|
---|
| 384 | The login button is sensitive only if both the pilot ID and the
|
---|
| 385 | password fields contain values.
|
---|
| 386 |
|
---|
| 387 | The password field is sensitive only, if the entrance exam checkbox is
|
---|
| 388 | not selected.
|
---|
| 389 |
|
---|
| 390 | The remember password checkbox is sensitive only, if the password field
|
---|
| 391 | contains text.
|
---|
| 392 |
|
---|
[208] | 393 | The entrance exam checkbox is sensitive only, if the pilot ID is not
|
---|
[184] | 394 | empty."""
|
---|
| 395 | pilotID = self._pilotID.get_text()
|
---|
| 396 | password = self._password.get_text()
|
---|
[760] | 397 | self._rememberButton.set_sensitive(password!="")
|
---|
| 398 | self._loginButton.set_sensitive(pilotID!="" and password!="")
|
---|
[42] | 399 |
|
---|
[753] | 400 | def _registerClicked(self, button):
|
---|
| 401 | """Called when the Register button was clicked."""
|
---|
[754] | 402 | self._wizard.jumpPage("register")
|
---|
[753] | 403 |
|
---|
[215] | 404 | def _offlineClicked(self, button):
|
---|
| 405 | """Called when the offline button was clicked."""
|
---|
[402] | 406 | print "mlx.flight.LoginPage: offline flight selected"
|
---|
[215] | 407 | self._wizard.nextPage()
|
---|
| 408 |
|
---|
[42] | 409 | def _loginClicked(self, button):
|
---|
| 410 | """Called when the login button was clicked."""
|
---|
[435] | 411 | print "mlx.flight.LoginPage: logging in"
|
---|
[208] | 412 | self._wizard.login(self._handleLoginResult,
|
---|
| 413 | self._pilotID.get_text(),
|
---|
[760] | 414 | self._password.get_text())
|
---|
[42] | 415 |
|
---|
| 416 | def _handleLoginResult(self, returned, result):
|
---|
| 417 | """Handle the login result."""
|
---|
[70] | 418 | self._loginButton.set_sensitive(True)
|
---|
[208] | 419 | if returned and result.loggedIn:
|
---|
| 420 | config = self._wizard.gui.config
|
---|
| 421 |
|
---|
| 422 | config.pilotID = self._pilotID.get_text()
|
---|
| 423 |
|
---|
[347] | 424 | rememberPassword = self._rememberButton.get_active()
|
---|
[208] | 425 | config.password = result.password if rememberPassword else ""
|
---|
| 426 |
|
---|
| 427 | config.rememberPassword = rememberPassword
|
---|
| 428 |
|
---|
| 429 | config.save()
|
---|
[760] | 430 | if result.rank=="STU":
|
---|
| 431 | self._wizard.jumpPage("student")
|
---|
| 432 | else:
|
---|
| 433 | self._wizard.nextPage()
|
---|
[42] | 434 |
|
---|
| 435 | #-----------------------------------------------------------------------------
|
---|
| 436 |
|
---|
| 437 | class FlightSelectionPage(Page):
|
---|
| 438 | """The page to select the flight."""
|
---|
| 439 | def __init__(self, wizard):
|
---|
| 440 | """Construct the flight selection page."""
|
---|
[347] | 441 | help = xstr("flightsel_help")
|
---|
[107] | 442 | completedHelp = xstr("flightsel_chelp")
|
---|
[754] | 443 | super(FlightSelectionPage, self).__init__(wizard, "flightsel",
|
---|
| 444 | xstr("flightsel_title"),
|
---|
[94] | 445 | help, completedHelp = completedHelp)
|
---|
[48] | 446 |
|
---|
[860] | 447 | mainBox = gtk.HBox()
|
---|
| 448 | mainBox.set_homogeneous(False)
|
---|
| 449 |
|
---|
| 450 | leftVBox = gtk.VBox()
|
---|
| 451 |
|
---|
| 452 | alignment = gtk.Alignment(xscale = 1.0)
|
---|
| 453 | alignment.set_size_request(150, 0)
|
---|
| 454 |
|
---|
| 455 | leftVBox.pack_start(alignment, False, False, 0)
|
---|
| 456 |
|
---|
| 457 | mainBox.pack_start(leftVBox, True, True, 0)
|
---|
| 458 |
|
---|
[818] | 459 | self._flightList = FlightList(popupMenuProducer =
|
---|
[811] | 460 | self._createListPopupMenu,
|
---|
| 461 | widthRequest = 400)
|
---|
[277] | 462 | self._flightList.connect("row-activated", self._rowActivated)
|
---|
[811] | 463 | self._flightList.connect("selection-changed", self._selectionChanged)
|
---|
| 464 |
|
---|
[860] | 465 | mainBox.pack_start(self._flightList, False, False, 8)
|
---|
| 466 |
|
---|
| 467 | flightButtonBox = gtk.VBox()
|
---|
| 468 |
|
---|
| 469 | alignment = gtk.Alignment(xscale = 1.0)
|
---|
| 470 | alignment.set_size_request(150, 0)
|
---|
| 471 | flightButtonBox.pack_start(alignment, False, False, 0)
|
---|
| 472 |
|
---|
| 473 | saveButtonAlignment = gtk.Alignment(xscale=0.5, yscale=0.0,
|
---|
| 474 | xalign=0.0, yalign=0.0)
|
---|
| 475 | self._saveButton = gtk.Button(xstr("flightsel_save"))
|
---|
| 476 | self._saveButton.set_use_underline(True)
|
---|
| 477 | self._saveButton.set_sensitive(False)
|
---|
| 478 | self._saveButton.set_tooltip_text(xstr("flightsel_save_tooltip"))
|
---|
| 479 | self._saveButton.connect("clicked", self._saveClicked)
|
---|
| 480 |
|
---|
| 481 | saveButtonAlignment.add(self._saveButton)
|
---|
| 482 |
|
---|
| 483 | flightButtonBox.pack_start(saveButtonAlignment, False, False, 4)
|
---|
| 484 |
|
---|
| 485 | mainBox.pack_start(flightButtonBox, True, True, 0)
|
---|
| 486 |
|
---|
| 487 | self.setMainWidget(mainBox)
|
---|
[48] | 488 |
|
---|
[819] | 489 | self._pendingButton = self.addButton(xstr("flightsel_pending"),
|
---|
| 490 | sensitive = False,
|
---|
| 491 | clicked = self._pendingClicked,
|
---|
| 492 | tooltip = xstr("flightsel_pending_tooltip"))
|
---|
| 493 |
|
---|
[214] | 494 | self._saveDialog = None
|
---|
| 495 |
|
---|
[208] | 496 | self._refreshButton = self.addButton(xstr("flightsel_refresh"),
|
---|
| 497 | sensitive = True,
|
---|
| 498 | clicked = self._refreshClicked,
|
---|
| 499 | tooltip = xstr("flightsel_refresh_tooltip"))
|
---|
| 500 |
|
---|
[184] | 501 | self._loadButton = self.addButton(xstr("flightsel_load"),
|
---|
| 502 | sensitive = True,
|
---|
| 503 | tooltip = xstr("flightsel_load_tooltip"))
|
---|
| 504 | self._loadButton.connect("clicked", self._loadButtonClicked)
|
---|
| 505 | self._loadDialog = None
|
---|
[347] | 506 |
|
---|
[107] | 507 | self._button = self.addNextButton(sensitive = False,
|
---|
| 508 | clicked = self._forwardClicked)
|
---|
[48] | 509 |
|
---|
[184] | 510 | self._flights = []
|
---|
| 511 |
|
---|
[819] | 512 | self._pendingFlightsWindow = PendingFlightsWindow(self._wizard)
|
---|
| 513 | self._pendingFlightsWindowShown = False
|
---|
| 514 | self._pendingFlightsWindow.connect("delete-event",
|
---|
| 515 | self._deletePendingFlightsWindow)
|
---|
| 516 |
|
---|
[48] | 517 | def activate(self):
|
---|
| 518 | """Fill the flight list."""
|
---|
[810] | 519 | self._setupHelp()
|
---|
[70] | 520 | self._flightList.set_sensitive(True)
|
---|
[208] | 521 | self._loadButton.set_sensitive(True)
|
---|
[216] | 522 | self._refreshButton.set_sensitive(self._wizard.loggedIn)
|
---|
[208] | 523 | self._buildFlights()
|
---|
[347] | 524 |
|
---|
[208] | 525 | def finalize(self):
|
---|
| 526 | """Finalize the page."""
|
---|
| 527 | self._flightList.set_sensitive(False)
|
---|
| 528 | self._loadButton.set_sensitive(False)
|
---|
| 529 | self._refreshButton.set_sensitive(False)
|
---|
| 530 |
|
---|
[810] | 531 | def _setupHelp(self):
|
---|
| 532 | """Setup the help string"""
|
---|
| 533 | help = ""
|
---|
| 534 |
|
---|
| 535 | if self._wizard.loggedIn:
|
---|
| 536 | numReported = len(self._wizard.loginResult.reportedFlights)
|
---|
| 537 | numRejected = len(self._wizard.loginResult.rejectedFlights)
|
---|
| 538 | if numReported==0 and numRejected==0:
|
---|
| 539 | help = xstr("flightsel_prehelp_nopending")
|
---|
| 540 | elif numReported>0 and numRejected==0:
|
---|
| 541 | help = xstr("flightsel_prehelp_rep_0rej") % (numReported,)
|
---|
| 542 | elif numReported==0 and numRejected>0:
|
---|
| 543 | help = xstr("flightsel_prehelp_0rep_rej") % (numRejected,)
|
---|
| 544 | else:
|
---|
| 545 | help = xstr("flightsel_prehelp_rep_rej") % \
|
---|
| 546 | (numReported, numRejected)
|
---|
| 547 |
|
---|
| 548 | help += xstr("flightsel_help")
|
---|
| 549 |
|
---|
| 550 | self.setHelp(help)
|
---|
| 551 |
|
---|
[208] | 552 | def _buildFlights(self):
|
---|
| 553 | """Rebuild the flights from the login result."""
|
---|
[184] | 554 | self._flights = []
|
---|
[811] | 555 | self._flightList.clear()
|
---|
[819] | 556 | self._pendingFlightsWindow.clear()
|
---|
| 557 | loginResult = self._wizard.loginResult
|
---|
[215] | 558 | if self._wizard.loggedIn:
|
---|
[819] | 559 | for flight in loginResult.flights:
|
---|
[859] | 560 | self.addFlight(flight)
|
---|
[819] | 561 | for flight in loginResult.reportedFlights:
|
---|
| 562 | self._pendingFlightsWindow.addReportedFlight(flight)
|
---|
| 563 | for flight in loginResult.rejectedFlights:
|
---|
| 564 | self._pendingFlightsWindow.addRejectedFlight(flight)
|
---|
| 565 |
|
---|
| 566 | self._updatePendingButton()
|
---|
[48] | 567 |
|
---|
[859] | 568 | def addFlight(self, flight):
|
---|
[184] | 569 | """Add the given file to the list of flights."""
|
---|
| 570 | self._flights.append(flight)
|
---|
[811] | 571 | self._flightList.addFlight(flight)
|
---|
[184] | 572 |
|
---|
[821] | 573 | def _reflyFlight(self, flight):
|
---|
| 574 | """Refly the given flight."""
|
---|
[859] | 575 | self.addFlight(flight)
|
---|
[824] | 576 | self._updatePending()
|
---|
| 577 |
|
---|
| 578 | def _updatePending(self):
|
---|
| 579 | """Update the stuff depending on the set of pending flights."""
|
---|
[821] | 580 | self._setupHelp()
|
---|
| 581 | self._updatePendingButton()
|
---|
| 582 |
|
---|
[819] | 583 | def _pendingClicked(self, button):
|
---|
| 584 | """Called when the Pending flights button is clicked."""
|
---|
| 585 | self._pendingFlightsWindow.show_all()
|
---|
| 586 | self._pendingFlightsWindowShown = True
|
---|
| 587 | self._updateNextButton()
|
---|
| 588 |
|
---|
| 589 | def _deletePendingFlightsWindow(self, window, event):
|
---|
| 590 | """Called when the pending flights window is closed."""
|
---|
| 591 | self._pendingFlightsWindow.hide()
|
---|
| 592 | self._pendingFlightsWindowShown = False
|
---|
| 593 | self._updateNextButton()
|
---|
| 594 | return True
|
---|
| 595 |
|
---|
[214] | 596 | def _saveClicked(self, button):
|
---|
| 597 | """Called when the Save flight button is clicked."""
|
---|
[277] | 598 | self._saveSelected()
|
---|
| 599 |
|
---|
| 600 | def _saveSelected(self):
|
---|
| 601 | """Save the selected flight."""
|
---|
[214] | 602 | flight = self._getSelectedFlight()
|
---|
| 603 | date = flight.departureTime.date()
|
---|
| 604 | name = "%04d-%02d-%02d %s %s-%s.vaflight" % \
|
---|
| 605 | (date.year, date.month, date.day, flight.callsign,
|
---|
| 606 | flight.departureICAO, flight.arrivalICAO)
|
---|
| 607 |
|
---|
| 608 | dialog = self._getSaveDialog()
|
---|
| 609 | dialog.set_current_name(name)
|
---|
| 610 | dialog.show_all()
|
---|
| 611 | response = dialog.run()
|
---|
| 612 | dialog.hide()
|
---|
| 613 |
|
---|
| 614 | if response==RESPONSETYPE_OK:
|
---|
[233] | 615 | fileName = text2unicode(dialog.get_filename())
|
---|
[214] | 616 | print "Saving", fileName
|
---|
| 617 | try:
|
---|
| 618 | with open(fileName, "wt") as f:
|
---|
| 619 | flight.writeIntoFile(f)
|
---|
| 620 | except Exception, e:
|
---|
[401] | 621 | print "Failed to save flight:", util.utf2unicode(str(e))
|
---|
[214] | 622 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 623 | type = MESSAGETYPE_ERROR,
|
---|
| 624 | message_format =
|
---|
| 625 | xstr("flightsel_save_failed"))
|
---|
| 626 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 627 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 628 | secondary = xstr("flightsel_save_failed_sec")
|
---|
| 629 | dialog.format_secondary_markup(secondary)
|
---|
| 630 | dialog.run()
|
---|
| 631 | dialog.hide()
|
---|
[347] | 632 |
|
---|
[208] | 633 | def _refreshClicked(self, button):
|
---|
| 634 | """Called when the refresh button is clicked."""
|
---|
| 635 | self._wizard.reloadFlights(self._refreshCallback)
|
---|
| 636 |
|
---|
| 637 | def _refreshCallback(self, returned, result):
|
---|
| 638 | """Callback for the refresh."""
|
---|
[810] | 639 | if returned:
|
---|
| 640 | self._setupHelp()
|
---|
| 641 | if result.loggedIn:
|
---|
| 642 | self._buildFlights()
|
---|
[208] | 643 |
|
---|
[823] | 644 | def _selectionChanged(self, flightList, indexes):
|
---|
[48] | 645 | """Called when the selection is changed."""
|
---|
[823] | 646 | self._saveButton.set_sensitive(len(indexes)==1)
|
---|
[819] | 647 | self._updateNextButton()
|
---|
| 648 |
|
---|
| 649 | def _updatePendingButton(self):
|
---|
| 650 | """Update the senstivity of the Pending button."""
|
---|
| 651 | self._pendingButton.set_sensitive(self._pendingFlightsWindow.hasFlights)
|
---|
| 652 |
|
---|
| 653 | def _updateNextButton(self):
|
---|
| 654 | """Update the sensitivity of the Next button."""
|
---|
[823] | 655 | sensitive = len(self._flightList.selectedIndexes)==1 and \
|
---|
[819] | 656 | not self._pendingFlightsWindowShown
|
---|
| 657 | self._button.set_sensitive(sensitive)
|
---|
[42] | 658 |
|
---|
[184] | 659 | def _loadButtonClicked(self, loadButton):
|
---|
| 660 | """Called when the load a flight button is clicked."""
|
---|
| 661 | dialog = self._getLoadDialog()
|
---|
| 662 | dialog.show_all()
|
---|
| 663 | response = dialog.run()
|
---|
| 664 | dialog.hide()
|
---|
| 665 |
|
---|
| 666 | if response==RESPONSETYPE_OK:
|
---|
[233] | 667 | fileName = text2unicode(dialog.get_filename())
|
---|
[184] | 668 | print "Loading", fileName
|
---|
| 669 | bookedFlight = web.BookedFlight()
|
---|
| 670 | try:
|
---|
| 671 | with open(fileName, "rt") as f:
|
---|
| 672 | bookedFlight.readFromFile(f)
|
---|
[859] | 673 | self.addFlight(bookedFlight)
|
---|
[184] | 674 | except Exception, e:
|
---|
[401] | 675 | print "Failed to load flight:", util.utf2unicode(str(e))
|
---|
[184] | 676 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 677 | type = MESSAGETYPE_ERROR,
|
---|
| 678 | message_format =
|
---|
| 679 | xstr("flightsel_load_failed"))
|
---|
| 680 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 681 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 682 | secondary = xstr("flightsel_load_failed_sec")
|
---|
| 683 | dialog.format_secondary_markup(secondary)
|
---|
| 684 | dialog.run()
|
---|
[347] | 685 | dialog.hide()
|
---|
| 686 |
|
---|
[51] | 687 | def _forwardClicked(self, button):
|
---|
| 688 | """Called when the forward button was clicked."""
|
---|
[94] | 689 | if self._completed:
|
---|
[754] | 690 | self._wizard.jumpPage(self._nextID, finalize = False)
|
---|
[70] | 691 | else:
|
---|
[277] | 692 | self._flightSelected()
|
---|
| 693 |
|
---|
[811] | 694 | def _rowActivated(self, flightList, index):
|
---|
[277] | 695 | """Called when a row is activated."""
|
---|
| 696 | if not self._completed:
|
---|
| 697 | self._flightSelected()
|
---|
| 698 |
|
---|
| 699 | def _flightSelected(self):
|
---|
| 700 | """Called when a flight has been selected."""
|
---|
| 701 | flight = self._getSelectedFlight()
|
---|
| 702 | self._wizard._bookedFlight = flight
|
---|
[436] | 703 | self._wizard.gui.enableFlightInfo(flight.aircraftType)
|
---|
[347] | 704 |
|
---|
[277] | 705 | self._updateDepartureGate()
|
---|
[214] | 706 |
|
---|
| 707 | def _getSelectedFlight(self):
|
---|
| 708 | """Get the currently selected flight."""
|
---|
[823] | 709 | indexes = self._flightList.selectedIndexes
|
---|
| 710 | assert(len(indexes)==1)
|
---|
| 711 | return self._flights[indexes[0]]
|
---|
[277] | 712 |
|
---|
[51] | 713 | def _updateDepartureGate(self):
|
---|
| 714 | """Update the departure gate for the booked flight."""
|
---|
| 715 | flight = self._wizard._bookedFlight
|
---|
[184] | 716 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 717 | self._wizard.loggedIn and not self._wizard.entranceExam:
|
---|
[136] | 718 | if flight.departureICAO=="LHBP":
|
---|
| 719 | self._wizard.getFleet(self._fleetRetrieved)
|
---|
| 720 | else:
|
---|
| 721 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 722 | flight.tailNumber,
|
---|
| 723 | const.PLANE_AWAY)
|
---|
[51] | 724 | else:
|
---|
[754] | 725 | self._nextID = "connect"
|
---|
| 726 | self._wizard.jumpPage("connect")
|
---|
[347] | 727 |
|
---|
[51] | 728 | def _fleetRetrieved(self, fleet):
|
---|
| 729 | """Called when the fleet has been retrieved."""
|
---|
| 730 | if fleet is None:
|
---|
[754] | 731 | self._nextID = "connect"
|
---|
| 732 | self._wizard.jumpPage("connect")
|
---|
[51] | 733 | else:
|
---|
| 734 | plane = fleet[self._wizard._bookedFlight.tailNumber]
|
---|
| 735 | if plane is None:
|
---|
[754] | 736 | self._nextID = "connect"
|
---|
| 737 | self._wizard.jumpPage("connect")
|
---|
[70] | 738 | elif plane.gateNumber is not None and \
|
---|
| 739 | not fleet.isGateConflicting(plane):
|
---|
[51] | 740 | self._wizard._departureGate = plane.gateNumber
|
---|
[754] | 741 | self._nextID = "connect"
|
---|
| 742 | self._wizard.jumpPage("connect")
|
---|
[51] | 743 | else:
|
---|
[754] | 744 | self._nextID = "gatesel"
|
---|
| 745 | self._wizard.jumpPage("gatesel")
|
---|
[130] | 746 |
|
---|
| 747 | def _planeUpdated(self, success):
|
---|
| 748 | """Callback for the plane updating."""
|
---|
[754] | 749 | self._nextID = "connect"
|
---|
| 750 | self._wizard.jumpPage("connect")
|
---|
[184] | 751 |
|
---|
[214] | 752 | def _getSaveDialog(self):
|
---|
| 753 | """Get the dialog to load a flight file."""
|
---|
| 754 | if self._saveDialog is not None:
|
---|
| 755 | return self._saveDialog
|
---|
[347] | 756 |
|
---|
[214] | 757 | gui = self._wizard.gui
|
---|
| 758 | dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
| 759 | xstr("flightsel_save_title"),
|
---|
| 760 | action = FILE_CHOOSER_ACTION_SAVE,
|
---|
| 761 | buttons = (gtk.STOCK_CANCEL,
|
---|
| 762 | RESPONSETYPE_CANCEL,
|
---|
| 763 | gtk.STOCK_OK, RESPONSETYPE_OK),
|
---|
| 764 | parent = gui.mainWindow)
|
---|
[347] | 765 | dialog.set_modal(True)
|
---|
[214] | 766 | dialog.set_do_overwrite_confirmation(True)
|
---|
| 767 |
|
---|
| 768 | filter = gtk.FileFilter()
|
---|
| 769 | filter.set_name(xstr("flightsel_filter_flights"))
|
---|
| 770 | filter.add_pattern("*.vaflight")
|
---|
| 771 | dialog.add_filter(filter)
|
---|
[347] | 772 |
|
---|
[214] | 773 | filter = gtk.FileFilter()
|
---|
| 774 | filter.set_name(xstr("file_filter_all"))
|
---|
| 775 | filter.add_pattern("*.*")
|
---|
| 776 | dialog.add_filter(filter)
|
---|
| 777 |
|
---|
| 778 | self._saveDialog = dialog
|
---|
[347] | 779 |
|
---|
| 780 | return dialog
|
---|
| 781 |
|
---|
[184] | 782 | def _getLoadDialog(self):
|
---|
| 783 | """Get the dialog to load a flight file."""
|
---|
| 784 | if self._loadDialog is not None:
|
---|
| 785 | return self._loadDialog
|
---|
[347] | 786 |
|
---|
[184] | 787 | gui = self._wizard.gui
|
---|
| 788 | dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
| 789 | xstr("flightsel_load_title"),
|
---|
| 790 | action = FILE_CHOOSER_ACTION_OPEN,
|
---|
| 791 | buttons = (gtk.STOCK_CANCEL,
|
---|
| 792 | RESPONSETYPE_CANCEL,
|
---|
| 793 | gtk.STOCK_OK, RESPONSETYPE_OK),
|
---|
| 794 | parent = gui.mainWindow)
|
---|
[347] | 795 | dialog.set_modal(True)
|
---|
[184] | 796 |
|
---|
| 797 | filter = gtk.FileFilter()
|
---|
| 798 | filter.set_name(xstr("flightsel_filter_flights"))
|
---|
| 799 | filter.add_pattern("*.vaflight")
|
---|
| 800 | dialog.add_filter(filter)
|
---|
[347] | 801 |
|
---|
[184] | 802 | filter = gtk.FileFilter()
|
---|
| 803 | filter.set_name(xstr("file_filter_all"))
|
---|
| 804 | filter.add_pattern("*.*")
|
---|
| 805 | dialog.add_filter(filter)
|
---|
| 806 |
|
---|
| 807 | self._loadDialog = dialog
|
---|
[347] | 808 |
|
---|
| 809 | return dialog
|
---|
[277] | 810 |
|
---|
[811] | 811 | def _createListPopupMenu(self):
|
---|
[277] | 812 | """Get the flight list popup menu."""
|
---|
[811] | 813 | menu = gtk.Menu()
|
---|
| 814 |
|
---|
| 815 | menuItem = gtk.MenuItem()
|
---|
| 816 | menuItem.set_label(xstr("flightsel_popup_select"))
|
---|
| 817 | menuItem.set_use_underline(True)
|
---|
| 818 | menuItem.connect("activate", self._popupSelect)
|
---|
| 819 | menuItem.show()
|
---|
| 820 |
|
---|
| 821 | menu.append(menuItem)
|
---|
| 822 |
|
---|
| 823 | menuItem = gtk.MenuItem()
|
---|
| 824 | menuItem.set_label(xstr("flightsel_popup_save"))
|
---|
| 825 | menuItem.set_use_underline(True)
|
---|
| 826 | menuItem.connect("activate", self._popupSave)
|
---|
| 827 | menuItem.show()
|
---|
| 828 |
|
---|
| 829 | menu.append(menuItem)
|
---|
| 830 |
|
---|
| 831 | return menu
|
---|
[277] | 832 |
|
---|
| 833 | def _popupSelect(self, menuItem):
|
---|
| 834 | """Called when the Select menu item is activated in the popup menu."""
|
---|
| 835 | if not self._completed:
|
---|
| 836 | self._flightSelected()
|
---|
[347] | 837 |
|
---|
[277] | 838 | def _popupSave(self, menuItem):
|
---|
| 839 | """Called when the Save menu item is activated in the popup menu."""
|
---|
| 840 | if not self._completed:
|
---|
| 841 | self._saveSelected()
|
---|
[347] | 842 |
|
---|
[51] | 843 | #-----------------------------------------------------------------------------
|
---|
| 844 |
|
---|
| 845 | class GateSelectionPage(Page):
|
---|
| 846 | """Page to select a free gate at LHBP.
|
---|
| 847 | This page should be displayed only if we have fleet information!."""
|
---|
| 848 | def __init__(self, wizard):
|
---|
| 849 | """Construct the gate selection page."""
|
---|
[754] | 850 | super(GateSelectionPage, self).__init__(wizard, "gatesel",
|
---|
| 851 | xstr("gatesel_title"),
|
---|
[107] | 852 | xstr("gatesel_help"))
|
---|
[347] | 853 |
|
---|
[51] | 854 | self._listStore = gtk.ListStore(str)
|
---|
| 855 | self._gateList = gtk.TreeView(self._listStore)
|
---|
| 856 | column = gtk.TreeViewColumn(None, gtk.CellRendererText(),
|
---|
| 857 | text = 0)
|
---|
| 858 | column.set_expand(True)
|
---|
| 859 | self._gateList.append_column(column)
|
---|
| 860 | self._gateList.set_headers_visible(False)
|
---|
[278] | 861 | self._gateList.connect("row-activated", self._rowActivated)
|
---|
[51] | 862 |
|
---|
| 863 | gateSelection = self._gateList.get_selection()
|
---|
| 864 | gateSelection.connect("changed", self._selectionChanged)
|
---|
| 865 |
|
---|
| 866 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 867 | scrolledWindow.add(self._gateList)
|
---|
| 868 | scrolledWindow.set_size_request(50, -1)
|
---|
| 869 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 870 | else gtk.POLICY_AUTOMATIC,
|
---|
[69] | 871 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 872 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 873 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 874 | else gtk.SHADOW_IN)
|
---|
[51] | 875 |
|
---|
| 876 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
| 877 | alignment.add(scrolledWindow)
|
---|
| 878 |
|
---|
[347] | 879 | self.setMainWidget(alignment)
|
---|
[51] | 880 |
|
---|
[208] | 881 | self.addCancelFlightButton()
|
---|
| 882 |
|
---|
[107] | 883 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[347] | 884 |
|
---|
[107] | 885 | self._button = self.addNextButton(sensitive = False,
|
---|
| 886 | clicked = self._forwardClicked)
|
---|
[51] | 887 |
|
---|
| 888 | def activate(self):
|
---|
| 889 | """Fill the gate list."""
|
---|
| 890 | self._listStore.clear()
|
---|
[70] | 891 | self._gateList.set_sensitive(True)
|
---|
[51] | 892 | occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
[629] | 893 | for gate in lhbpGates.gates:
|
---|
[619] | 894 | if gate.isAvailable(lhbpGates, occupiedGateNumbers):
|
---|
| 895 | self._listStore.append([gate.number])
|
---|
[51] | 896 |
|
---|
[70] | 897 | def finalize(self):
|
---|
| 898 | """Finalize the page."""
|
---|
| 899 | self._gateList.set_sensitive(False)
|
---|
| 900 |
|
---|
[51] | 901 | def _selectionChanged(self, selection):
|
---|
| 902 | """Called when the selection is changed."""
|
---|
| 903 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
| 904 |
|
---|
[73] | 905 | def _backClicked(self, button):
|
---|
| 906 | """Called when the Back button is pressed."""
|
---|
| 907 | self.goBack()
|
---|
| 908 |
|
---|
[51] | 909 | def _forwardClicked(self, button):
|
---|
| 910 | """Called when the forward button is clicked."""
|
---|
[94] | 911 | if not self._completed:
|
---|
[278] | 912 | self._gateSelected()
|
---|
[130] | 913 | else:
|
---|
[754] | 914 | self._wizard.jumpPage("connect")
|
---|
[51] | 915 |
|
---|
[278] | 916 | def _rowActivated(self, flightList, path, column):
|
---|
| 917 | """Called when a row is activated."""
|
---|
| 918 | if not self._completed:
|
---|
| 919 | self._gateSelected()
|
---|
| 920 |
|
---|
| 921 | def _gateSelected(self):
|
---|
| 922 | """Called when a gate has been selected."""
|
---|
| 923 | selection = self._gateList.get_selection()
|
---|
| 924 | (listStore, iter) = selection.get_selected()
|
---|
| 925 | (gateNumber,) = listStore.get(iter, 0)
|
---|
| 926 |
|
---|
| 927 | self._wizard._departureGate = gateNumber
|
---|
| 928 |
|
---|
| 929 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 930 | self._wizard._bookedFlight.tailNumber,
|
---|
[347] | 931 | const.PLANE_HOME, gateNumber)
|
---|
[278] | 932 |
|
---|
[51] | 933 | def _planeUpdated(self, success):
|
---|
| 934 | """Callback for the plane updating call."""
|
---|
| 935 | if success is None or success:
|
---|
[754] | 936 | self._wizard.jumpPage("connect")
|
---|
[51] | 937 | else:
|
---|
[105] | 938 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 939 | type = MESSAGETYPE_ERROR,
|
---|
[107] | 940 | message_format = xstr("gatesel_conflict"))
|
---|
[124] | 941 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
[105] | 942 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
[107] | 943 | dialog.format_secondary_markup(xstr("gatesel_conflict_sec"))
|
---|
[51] | 944 | dialog.run()
|
---|
| 945 | dialog.hide()
|
---|
| 946 |
|
---|
[126] | 947 | self._wizard.getFleet(self._fleetRetrieved)
|
---|
[51] | 948 |
|
---|
| 949 | def _fleetRetrieved(self, fleet):
|
---|
| 950 | """Called when the fleet has been retrieved."""
|
---|
| 951 | if fleet is None:
|
---|
[754] | 952 | self._wizard.jumpPage("connect")
|
---|
[51] | 953 | else:
|
---|
| 954 | self.activate()
|
---|
[347] | 955 |
|
---|
[51] | 956 | #-----------------------------------------------------------------------------
|
---|
| 957 |
|
---|
[753] | 958 | class RegisterPage(Page):
|
---|
| 959 | """A page to enter the registration data."""
|
---|
| 960 |
|
---|
| 961 | # The minimal year of birth
|
---|
| 962 | _minYearOfBirth = 1900
|
---|
| 963 |
|
---|
| 964 | # The maximal year of birth
|
---|
| 965 | _maxYearOfBirth = datetime.date.today().year
|
---|
| 966 |
|
---|
| 967 | # The regular expression to check the e-mail address with
|
---|
| 968 | _emailAddressRE = re.compile("[^@]+@[^@]+\.[^@]+")
|
---|
| 969 |
|
---|
| 970 | def __init__(self, wizard):
|
---|
| 971 | """Construct the registration page."""
|
---|
[754] | 972 | super(RegisterPage, self).__init__(wizard, "register",
|
---|
| 973 | xstr("register_title"),
|
---|
[753] | 974 | xstr("register_help"))
|
---|
| 975 |
|
---|
| 976 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 977 | xscale = 0.0, yscale = 0.0)
|
---|
| 978 |
|
---|
[759] | 979 | table = gtk.Table(12, 3)
|
---|
[753] | 980 | table.set_row_spacings(4)
|
---|
| 981 | table.set_col_spacings(32)
|
---|
| 982 | alignment.add(table)
|
---|
| 983 | self.setMainWidget(alignment)
|
---|
| 984 |
|
---|
[759] | 985 | row = 0
|
---|
| 986 |
|
---|
[753] | 987 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 988 | xscale = 0.0, yscale = 0.0)
|
---|
[759] | 989 | label = gtk.Label(xstr("register_name1"))
|
---|
[753] | 990 | label.set_use_underline(True)
|
---|
| 991 | labelAlignment.add(label)
|
---|
[759] | 992 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
| 993 |
|
---|
| 994 | self._name1 = gtk.Entry()
|
---|
| 995 | self._name1.connect("changed", self._updateButtons)
|
---|
| 996 | self._name1.set_tooltip_text(xstr("register_name1_tooltip"))
|
---|
| 997 | self._name1.set_width_chars(15)
|
---|
| 998 | table.attach(self._name1, 1, 2, row, row+1)
|
---|
| 999 | label.set_mnemonic_widget(self._name1)
|
---|
| 1000 |
|
---|
| 1001 | row += 1
|
---|
| 1002 |
|
---|
| 1003 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1004 | xscale = 0.0, yscale = 0.0)
|
---|
| 1005 | label = gtk.Label(xstr("register_name2"))
|
---|
| 1006 | label.set_use_underline(True)
|
---|
| 1007 | labelAlignment.add(label)
|
---|
| 1008 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
| 1009 |
|
---|
| 1010 | self._name2 = gtk.Entry()
|
---|
| 1011 | self._name2.connect("changed", self._updateButtons)
|
---|
| 1012 | self._name2.set_tooltip_text(xstr("register_name2_tooltip"))
|
---|
| 1013 | self._name2.set_width_chars(15)
|
---|
| 1014 | table.attach(self._name2, 1, 2, row, row+1)
|
---|
| 1015 | label.set_mnemonic_widget(self._name2)
|
---|
| 1016 |
|
---|
| 1017 | row += 1
|
---|
[753] | 1018 |
|
---|
| 1019 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1020 | xscale = 0.0, yscale = 0.0)
|
---|
| 1021 | label = gtk.Label(xstr("register_year_of_birth"))
|
---|
| 1022 | label.set_use_underline(True)
|
---|
| 1023 | labelAlignment.add(label)
|
---|
[759] | 1024 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1025 |
|
---|
| 1026 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1027 | xscale = 0.0, yscale = 0.0)
|
---|
| 1028 |
|
---|
| 1029 | self._yearOfBirth = gtk.SpinButton()
|
---|
| 1030 | self._yearOfBirth.set_increments(step = 1, page = 10)
|
---|
| 1031 | self._yearOfBirth.set_range(min = RegisterPage._minYearOfBirth,
|
---|
| 1032 | max = RegisterPage._maxYearOfBirth)
|
---|
| 1033 | self._yearOfBirth.set_numeric(True)
|
---|
| 1034 | self._yearOfBirth.set_tooltip_text(xstr("register_year_of_birth_tooltip"))
|
---|
| 1035 | self._yearOfBirth.set_width_chars(5)
|
---|
| 1036 | self._yearOfBirth.connect("changed", self._updateButtons)
|
---|
| 1037 | self._yearOfBirth.connect("value-changed", self._updateButtons)
|
---|
| 1038 | alignment.add(self._yearOfBirth)
|
---|
[759] | 1039 | table.attach(alignment, 1, 2, row, row+1)
|
---|
[753] | 1040 | label.set_mnemonic_widget(self._yearOfBirth)
|
---|
| 1041 |
|
---|
[759] | 1042 | row += 1
|
---|
| 1043 |
|
---|
[753] | 1044 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1045 | xscale = 0.0, yscale = 0.0)
|
---|
| 1046 | label = gtk.Label(xstr("register_email"))
|
---|
| 1047 | label.set_use_underline(True)
|
---|
| 1048 | labelAlignment.add(label)
|
---|
[759] | 1049 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1050 |
|
---|
| 1051 | self._emailAddress = gtk.Entry()
|
---|
| 1052 | self._emailAddress.connect("changed", self._updateButtons)
|
---|
| 1053 | self._emailAddress.set_tooltip_text(xstr("register_email_tooltip"))
|
---|
[759] | 1054 | table.attach(self._emailAddress, 1, 2, row, row+1)
|
---|
[753] | 1055 | label.set_mnemonic_widget(self._emailAddress)
|
---|
| 1056 |
|
---|
| 1057 | self._emailAddressPublic = gtk.CheckButton(xstr("register_email_public"))
|
---|
| 1058 | self._emailAddressPublic.set_use_underline(True)
|
---|
| 1059 | self._emailAddressPublic.set_tooltip_text(xstr("register_email_public_tooltip"))
|
---|
[759] | 1060 | table.attach(self._emailAddressPublic, 2, 3, row, row+1)
|
---|
| 1061 |
|
---|
| 1062 | row += 1
|
---|
[753] | 1063 |
|
---|
| 1064 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1065 | xscale = 0.0, yscale = 0.0)
|
---|
| 1066 | label = gtk.Label(xstr("register_vatsim_id"))
|
---|
| 1067 | label.set_use_underline(True)
|
---|
| 1068 | labelAlignment.add(label)
|
---|
[759] | 1069 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1070 |
|
---|
| 1071 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1072 | xscale = 0.0, yscale = 0.0)
|
---|
| 1073 | self._vatsimID = IntegerEntry()
|
---|
| 1074 | self._vatsimID.connect("changed", self._updateButtons)
|
---|
| 1075 | self._vatsimID.set_tooltip_text(xstr("register_vatsim_id_tooltip"))
|
---|
| 1076 | self._vatsimID.set_width_chars(7)
|
---|
| 1077 | alignment.add(self._vatsimID)
|
---|
[759] | 1078 | table.attach(alignment, 1, 2, row, row+1)
|
---|
[753] | 1079 | label.set_mnemonic_widget(self._vatsimID)
|
---|
| 1080 |
|
---|
[759] | 1081 | row += 1
|
---|
| 1082 |
|
---|
[753] | 1083 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1084 | xscale = 0.0, yscale = 0.0)
|
---|
| 1085 | label = gtk.Label(xstr("register_ivao_id"))
|
---|
| 1086 | label.set_use_underline(True)
|
---|
| 1087 | labelAlignment.add(label)
|
---|
[759] | 1088 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1089 |
|
---|
| 1090 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1091 | xscale = 0.0, yscale = 0.0)
|
---|
| 1092 | self._ivaoID = IntegerEntry()
|
---|
| 1093 | self._ivaoID.connect("changed", self._updateButtons)
|
---|
| 1094 | self._ivaoID.set_tooltip_text(xstr("register_ivao_id_tooltip"))
|
---|
| 1095 | self._ivaoID.set_width_chars(7)
|
---|
| 1096 | alignment.add(self._ivaoID)
|
---|
[759] | 1097 | table.attach(alignment, 1, 2, row, row+1)
|
---|
[753] | 1098 | label.set_mnemonic_widget(self._ivaoID)
|
---|
| 1099 |
|
---|
[759] | 1100 | row += 1
|
---|
| 1101 |
|
---|
[753] | 1102 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1103 | xscale = 0.0, yscale = 0.0)
|
---|
| 1104 | label = gtk.Label(xstr("register_phone_num"))
|
---|
| 1105 | label.set_use_underline(True)
|
---|
| 1106 | label.set_use_markup(True)
|
---|
| 1107 | labelAlignment.add(label)
|
---|
[759] | 1108 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1109 |
|
---|
| 1110 | self._phoneNumber = gtk.Entry()
|
---|
| 1111 | self._phoneNumber.set_tooltip_text(xstr("register_phone_num_tooltip"))
|
---|
[759] | 1112 | table.attach(self._phoneNumber, 1, 2, row, row+1)
|
---|
[753] | 1113 | label.set_mnemonic_widget(self._phoneNumber)
|
---|
| 1114 |
|
---|
[759] | 1115 | row += 1
|
---|
| 1116 |
|
---|
[753] | 1117 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1118 | xscale = 0.0, yscale = 0.0)
|
---|
| 1119 | label = gtk.Label(xstr("register_nationality"))
|
---|
| 1120 | label.set_use_underline(True)
|
---|
| 1121 | label.set_use_markup(True)
|
---|
| 1122 | labelAlignment.add(label)
|
---|
[759] | 1123 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1124 |
|
---|
| 1125 |
|
---|
| 1126 | self._nationality = gtk.Entry()
|
---|
| 1127 | self._nationality.set_tooltip_text(xstr("register_nationality_tooltip"))
|
---|
[759] | 1128 | table.attach(self._nationality, 1, 2, row, row+1)
|
---|
[753] | 1129 | label.set_mnemonic_widget(self._nationality)
|
---|
| 1130 |
|
---|
| 1131 | placeholder = gtk.Label()
|
---|
| 1132 | placeholder.set_text(xstr("register_password_mismatch"))
|
---|
| 1133 | placeholder.set_use_markup(True)
|
---|
| 1134 | placeholder.set_child_visible(False)
|
---|
| 1135 | placeholder.hide()
|
---|
[759] | 1136 | table.attach(placeholder, 2, 3, row, row+1)
|
---|
| 1137 |
|
---|
| 1138 | row += 1
|
---|
[753] | 1139 |
|
---|
| 1140 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1141 | xscale = 0.0, yscale = 0.0)
|
---|
| 1142 | label = gtk.Label(xstr("register_password"))
|
---|
| 1143 | label.set_use_underline(True)
|
---|
| 1144 | labelAlignment.add(label)
|
---|
[759] | 1145 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1146 |
|
---|
| 1147 | self._password = gtk.Entry()
|
---|
| 1148 | self._password.set_visibility(False)
|
---|
| 1149 | self._password.connect("changed", self._updateButtons)
|
---|
| 1150 | self._password.set_tooltip_text(xstr("register_password_tooltip"))
|
---|
[759] | 1151 | table.attach(self._password, 1, 2, row, row+1)
|
---|
[753] | 1152 | label.set_mnemonic_widget(self._password)
|
---|
| 1153 |
|
---|
| 1154 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 1155 | xscale = 0.0, yscale = 0.0)
|
---|
| 1156 | self._passwordStatus = gtk.Label()
|
---|
| 1157 | alignment.add(self._passwordStatus)
|
---|
[759] | 1158 | table.attach(alignment, 2, 3, row, row+1)
|
---|
| 1159 |
|
---|
| 1160 | row += 1
|
---|
[753] | 1161 |
|
---|
| 1162 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 1163 | xscale = 0.0, yscale = 0.0)
|
---|
| 1164 | label = gtk.Label(xstr("register_password2"))
|
---|
| 1165 | label.set_use_underline(True)
|
---|
| 1166 | labelAlignment.add(label)
|
---|
[759] | 1167 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1168 |
|
---|
| 1169 | self._password2 = gtk.Entry()
|
---|
| 1170 | self._password2.set_visibility(False)
|
---|
| 1171 | self._password2.connect("changed", self._updateButtons)
|
---|
| 1172 | self._password2.set_tooltip_text(xstr("register_password2_tooltip"))
|
---|
[759] | 1173 | table.attach(self._password2, 1, 2, row, row+1)
|
---|
[753] | 1174 | label.set_mnemonic_widget(self._password2)
|
---|
| 1175 |
|
---|
| 1176 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 1177 | xscale = 0.0, yscale = 0.0)
|
---|
| 1178 | self._password2Status = gtk.Label()
|
---|
| 1179 | alignment.add(self._password2Status)
|
---|
[759] | 1180 | table.attach(alignment, 2, 3, row, row+1)
|
---|
| 1181 |
|
---|
| 1182 | row += 1
|
---|
[753] | 1183 |
|
---|
| 1184 | self._rememberButton = gtk.CheckButton(xstr("remember_password"))
|
---|
| 1185 | self._rememberButton.set_use_underline(True)
|
---|
| 1186 | self._rememberButton.set_tooltip_text(xstr("login_remember_tooltip"))
|
---|
[759] | 1187 | table.attach(self._rememberButton, 1, 2, row, row+1)
|
---|
[753] | 1188 |
|
---|
| 1189 | cancelButton = \
|
---|
| 1190 | self.addButton(xstr("button_cancel"))
|
---|
| 1191 | cancelButton.connect("clicked", self._cancelClicked)
|
---|
| 1192 |
|
---|
| 1193 | self._registerButton = \
|
---|
| 1194 | self.addButton(xstr("button_register"), default = True,
|
---|
| 1195 | tooltip = xstr("button_register_tooltip"))
|
---|
| 1196 | self._registerButton.connect("clicked", self._registerClicked)
|
---|
| 1197 |
|
---|
| 1198 | self._updateButtons()
|
---|
| 1199 |
|
---|
[756] | 1200 | @property
|
---|
[759] | 1201 | def name1(self):
|
---|
| 1202 | """Get the first name component entered."""
|
---|
| 1203 | return self._name1.get_text()
|
---|
| 1204 |
|
---|
| 1205 | @property
|
---|
| 1206 | def name2(self):
|
---|
| 1207 | """Get the second name component entered."""
|
---|
| 1208 | return self._name2.get_text()
|
---|
[756] | 1209 |
|
---|
| 1210 | @property
|
---|
| 1211 | def yearOfBirth(self):
|
---|
| 1212 | """Get the year of birth."""
|
---|
| 1213 | yearOfBirthText = self._yearOfBirth.get_text()
|
---|
| 1214 | return int(yearOfBirthText) if yearOfBirthText else 0
|
---|
| 1215 |
|
---|
| 1216 | @property
|
---|
| 1217 | def emailAddress(self):
|
---|
| 1218 | """Get the e-mail address."""
|
---|
| 1219 | return self._emailAddress.get_text()
|
---|
| 1220 |
|
---|
| 1221 | @property
|
---|
| 1222 | def emailAddressPublic(self):
|
---|
| 1223 | """Get the whether the e-mail address is public."""
|
---|
| 1224 | return self._emailAddressPublic.get_active()
|
---|
| 1225 |
|
---|
| 1226 | @property
|
---|
| 1227 | def vatsimID(self):
|
---|
| 1228 | """Get the VATSIM ID."""
|
---|
| 1229 | return self._vatsimID.get_int()
|
---|
| 1230 |
|
---|
| 1231 | @property
|
---|
| 1232 | def ivaoID(self):
|
---|
| 1233 | """Get the IVAO ID."""
|
---|
| 1234 | return self._ivaoID.get_int()
|
---|
| 1235 |
|
---|
| 1236 | @property
|
---|
| 1237 | def phoneNumber(self):
|
---|
| 1238 | """Get the phone number."""
|
---|
| 1239 | return self._phoneNumber.get_text()
|
---|
| 1240 |
|
---|
| 1241 | @property
|
---|
| 1242 | def nationality(self):
|
---|
| 1243 | """Get the nationality."""
|
---|
| 1244 | return self._nationality.get_text()
|
---|
| 1245 |
|
---|
| 1246 | @property
|
---|
| 1247 | def password(self):
|
---|
| 1248 | """Get the password."""
|
---|
| 1249 | return self._password.get_text()
|
---|
| 1250 |
|
---|
| 1251 | @property
|
---|
| 1252 | def rememberPassword(self):
|
---|
| 1253 | """Get whether the password should be remembered."""
|
---|
| 1254 | return self._rememberButton.get_active()
|
---|
| 1255 |
|
---|
[753] | 1256 | def activate(self):
|
---|
| 1257 | """Setup the route from the booked flight."""
|
---|
| 1258 | self._yearOfBirth.set_value(0)
|
---|
| 1259 | self._yearOfBirth.set_text("")
|
---|
| 1260 | self._updateButtons()
|
---|
| 1261 |
|
---|
| 1262 | def _updateButtons(self, widget = None):
|
---|
| 1263 | """Update the sensitive state of the buttons"""
|
---|
[756] | 1264 | yearOfBirth = self.yearOfBirth
|
---|
| 1265 |
|
---|
| 1266 | emailAddress = self.emailAddress
|
---|
| 1267 | emailAddressMatch = RegisterPage._emailAddressRE.match(emailAddress)
|
---|
| 1268 |
|
---|
| 1269 | vatsimID = self.vatsimID
|
---|
| 1270 | ivaoID = self.ivaoID
|
---|
| 1271 |
|
---|
| 1272 | password = self.password
|
---|
[753] | 1273 | password2 = self._password2.get_text()
|
---|
| 1274 | if not password:
|
---|
| 1275 | self._passwordStatus.set_text("")
|
---|
| 1276 | elif len(password)<5:
|
---|
| 1277 | self._passwordStatus.set_text(xstr("register_password_too_short"))
|
---|
| 1278 | else:
|
---|
| 1279 | self._passwordStatus.set_text(xstr("register_password_ok"))
|
---|
| 1280 | self._passwordStatus.set_use_markup(True)
|
---|
| 1281 |
|
---|
| 1282 | if len(password)<5 or not password2:
|
---|
| 1283 | self._password2Status.set_text("")
|
---|
| 1284 | elif password!=password2:
|
---|
| 1285 | self._password2Status.set_text(xstr("register_password_mismatch"))
|
---|
| 1286 | else:
|
---|
| 1287 | self._password2Status.set_text(xstr("register_password_ok"))
|
---|
| 1288 | self._password2Status.set_use_markup(True)
|
---|
| 1289 |
|
---|
| 1290 | sensitive = \
|
---|
[759] | 1291 | len(self.name1)>0 and len(self.name2)>0 and \
|
---|
[753] | 1292 | yearOfBirth>=RegisterPage._minYearOfBirth and \
|
---|
| 1293 | yearOfBirth<=RegisterPage._maxYearOfBirth and \
|
---|
| 1294 | emailAddressMatch is not None and \
|
---|
| 1295 | (vatsimID>=800000 or ivaoID>=100000) and \
|
---|
| 1296 | len(password)>=5 and password==password2
|
---|
| 1297 |
|
---|
| 1298 | self._registerButton.set_sensitive(sensitive)
|
---|
| 1299 |
|
---|
| 1300 | def _cancelClicked(self, button):
|
---|
| 1301 | """Called when the Cancel button is clicked."""
|
---|
| 1302 | self.goBack()
|
---|
| 1303 |
|
---|
| 1304 | def _registerClicked(self, button):
|
---|
| 1305 | """Called when the Register button is clicked."""
|
---|
[759] | 1306 | nameOrder = xstr("register_nameorder")
|
---|
| 1307 |
|
---|
| 1308 | if nameOrder=="eastern":
|
---|
| 1309 | surName = self.name1
|
---|
| 1310 | firstName = self.name2
|
---|
| 1311 | else:
|
---|
| 1312 | surName = self.name2
|
---|
| 1313 | firstName = self.name1
|
---|
| 1314 |
|
---|
| 1315 | nationality = self.nationality.lower()
|
---|
| 1316 |
|
---|
| 1317 | if getLanguage().lower()=="hu" or nationality.find("hung")!=-1 or \
|
---|
| 1318 | nationality.find("magyar")!=-1:
|
---|
| 1319 | requestedNameOrder = "eastern"
|
---|
| 1320 | else:
|
---|
| 1321 | requestedNameOrder = "western"
|
---|
| 1322 |
|
---|
| 1323 | registrationData = web.Registration(surName, firstName,
|
---|
| 1324 | requestedNameOrder,
|
---|
| 1325 | self.yearOfBirth,
|
---|
[756] | 1326 | self.emailAddress,
|
---|
| 1327 | self.emailAddressPublic,
|
---|
| 1328 | self.vatsimID, self.ivaoID,
|
---|
| 1329 | self.phoneNumber, self.nationality,
|
---|
| 1330 | self.password)
|
---|
| 1331 | print "Registering with data:"
|
---|
[759] | 1332 | print " name:", self.name1, self.name2, registrationData.firstName, registrationData.surName, requestedNameOrder
|
---|
[756] | 1333 | print " yearOfBirth:", self.yearOfBirth, registrationData.yearOfBirth
|
---|
| 1334 | print " emailAddress:", self.emailAddress, registrationData.emailAddress
|
---|
| 1335 | print " emailAddressPublic:", self.emailAddressPublic, registrationData.emailAddressPublic
|
---|
| 1336 | print " vatsimID:", self.vatsimID, registrationData.vatsimID
|
---|
| 1337 | print " ivaoID:", self.ivaoID, registrationData.ivaoID
|
---|
| 1338 | print " phoneNumber:", self.phoneNumber, registrationData.phoneNumber
|
---|
| 1339 | print " nationality:", self.nationality, registrationData.nationality
|
---|
| 1340 |
|
---|
| 1341 | gui = self._wizard.gui
|
---|
| 1342 | gui.beginBusy(xstr("register_busy"))
|
---|
| 1343 | gui.webHandler.register(self._registerResultCallback, registrationData)
|
---|
| 1344 |
|
---|
| 1345 | def _registerResultCallback(self, returned, result):
|
---|
| 1346 | """Called when the registration result is available."""
|
---|
| 1347 | gobject.idle_add(self._handleRegisterResult, returned, result)
|
---|
| 1348 |
|
---|
| 1349 | def _handleRegisterResult(self, returned, result):
|
---|
| 1350 | """Handle the registration result."""
|
---|
| 1351 | gui = self._wizard.gui
|
---|
| 1352 |
|
---|
| 1353 | gui.endBusy()
|
---|
| 1354 |
|
---|
| 1355 | print "Registration result:"
|
---|
| 1356 | print " returned:", returned
|
---|
| 1357 | if returned:
|
---|
| 1358 | print " registered:", result.registered
|
---|
| 1359 | if result.registered:
|
---|
| 1360 | print " pilotID", result.pilotID
|
---|
| 1361 | print " loggedIn", result.loggedIn
|
---|
| 1362 | print " emailAlreadyRegistered:", result.emailAlreadyRegistered
|
---|
| 1363 | print " invalidData:", result.invalidData
|
---|
| 1364 |
|
---|
| 1365 | registrationOK = returned and result.registered
|
---|
| 1366 |
|
---|
| 1367 | message = xstr("register_ok") if registrationOK \
|
---|
| 1368 | else xstr("register_failed")
|
---|
| 1369 | secondaryMessage = None
|
---|
| 1370 | if registrationOK:
|
---|
| 1371 | if result.loggedIn:
|
---|
| 1372 | secondaryMessage = xstr("register_info") % (result.pilotID,)
|
---|
| 1373 | else:
|
---|
| 1374 | secondaryMessage = xstr("register_nologin") % (result.pilotID,)
|
---|
| 1375 | messageType = MESSAGETYPE_INFO
|
---|
| 1376 |
|
---|
| 1377 | config = gui.config
|
---|
| 1378 | config.pilotID = result.pilotID
|
---|
| 1379 | config.rememberPassword = self.rememberPassword
|
---|
| 1380 | if config.rememberPassword:
|
---|
| 1381 | config.password = self.password
|
---|
| 1382 | else:
|
---|
| 1383 | config.password = ""
|
---|
| 1384 |
|
---|
| 1385 | config.save()
|
---|
| 1386 | elif returned and result.emailAlreadyRegistered:
|
---|
| 1387 | secondaryMessage = xstr("register_email_already")
|
---|
| 1388 | messageType = MESSAGETYPE_ERROR
|
---|
| 1389 | elif returned and result.invalidData:
|
---|
| 1390 | secondaryMessage = xstr("register_invalid_data")
|
---|
| 1391 | messageType = MESSAGETYPE_ERROR
|
---|
| 1392 | else:
|
---|
| 1393 | secondaryMessage = xstr("register_error")
|
---|
| 1394 | messageType = MESSAGETYPE_ERROR
|
---|
| 1395 |
|
---|
| 1396 | dialog = gtk.MessageDialog(parent = gui.mainWindow,
|
---|
| 1397 | type = messageType,
|
---|
| 1398 | message_format = message)
|
---|
| 1399 | dialog.set_title(WINDOW_TITLE_BASE + " - " +
|
---|
| 1400 | xstr("register_result_title"))
|
---|
| 1401 | dialog.format_secondary_markup(secondaryMessage)
|
---|
| 1402 |
|
---|
| 1403 | dialog.add_button(xstr("button_ok"), 0)
|
---|
| 1404 |
|
---|
| 1405 | dialog.run()
|
---|
| 1406 | dialog.hide()
|
---|
| 1407 |
|
---|
| 1408 | if registrationOK:
|
---|
| 1409 | if result.loggedIn:
|
---|
[771] | 1410 | self._wizard._loginResult = result
|
---|
[756] | 1411 | self._wizard.nextPage()
|
---|
| 1412 | else:
|
---|
| 1413 | self._wizard.jumpPage("login")
|
---|
[753] | 1414 |
|
---|
| 1415 | #-----------------------------------------------------------------------------
|
---|
| 1416 |
|
---|
| 1417 | class StudentPage(Page):
|
---|
| 1418 | """A page displayed to students after logging in."""
|
---|
[762] | 1419 | _entryExamStatusQueryInterval = 60*1000
|
---|
| 1420 |
|
---|
[753] | 1421 | def __init__(self, wizard):
|
---|
| 1422 | """Construct the student page."""
|
---|
[754] | 1423 | super(StudentPage, self).__init__(wizard, "student",
|
---|
| 1424 | xstr("student_title"),
|
---|
[753] | 1425 | xstr("student_help"))
|
---|
| 1426 |
|
---|
[769] | 1427 |
|
---|
| 1428 | self._getEntryExamStatusCancelled = False
|
---|
| 1429 |
|
---|
[762] | 1430 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1431 | xscale = 0.5, yscale = 0.0)
|
---|
| 1432 |
|
---|
[769] | 1433 | table = gtk.Table(6, 4)
|
---|
[762] | 1434 | table.set_row_spacings(4)
|
---|
[769] | 1435 | table.set_col_spacings(0)
|
---|
[764] | 1436 | table.set_homogeneous(False)
|
---|
[762] | 1437 | alignment.add(table)
|
---|
| 1438 | self.setMainWidget(alignment)
|
---|
| 1439 |
|
---|
| 1440 | row = 0
|
---|
| 1441 |
|
---|
[764] | 1442 | labelAlignment = gtk.Alignment(xalign=0.0, yalign = 0.5,
|
---|
| 1443 | xscale=0.0, yscale = 0.0)
|
---|
| 1444 | label = gtk.Label(xstr("student_entry_exam_status"))
|
---|
[769] | 1445 | label.set_alignment(0.0, 0.5)
|
---|
[764] | 1446 | labelAlignment.add(label)
|
---|
[769] | 1447 | labelAlignment.resize_children()
|
---|
| 1448 | table.attach(labelAlignment, 0, 1, row, row + 1, xoptions = FILL)
|
---|
[764] | 1449 |
|
---|
| 1450 | alignment = gtk.Alignment(xalign=0.0, yalign = 0.5,
|
---|
| 1451 | xscale=1.0, yscale = 0.0)
|
---|
| 1452 | self._entryExamStatus = gtk.Label()
|
---|
| 1453 | self._entryExamStatus.set_use_markup(True)
|
---|
| 1454 | self._entryExamStatus.set_alignment(0.0, 0.5)
|
---|
| 1455 | alignment.add(self._entryExamStatus)
|
---|
[769] | 1456 | alignment.resize_children()
|
---|
| 1457 | table.attach(alignment, 1, 4, row, row + 1)
|
---|
[764] | 1458 |
|
---|
| 1459 | row += 1
|
---|
| 1460 |
|
---|
[762] | 1461 | buttonAlignment = gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 1462 | button = self._entryExamButton = gtk.Button(xstr("student_entry_exam"))
|
---|
| 1463 | button.set_use_underline(True)
|
---|
| 1464 | button.connect("clicked", self._entryExamClicked)
|
---|
| 1465 | button.set_tooltip_text(xstr("student_entry_exam_tooltip"))
|
---|
| 1466 |
|
---|
| 1467 | buttonAlignment.add(button)
|
---|
[769] | 1468 | table.attach(buttonAlignment, 0, 4, row, row + 1, xoptions = FILL,
|
---|
[764] | 1469 | ypadding = 4)
|
---|
[762] | 1470 |
|
---|
[769] | 1471 | row += 3
|
---|
| 1472 |
|
---|
| 1473 | labelAlignment = gtk.Alignment(xalign=0.0, yalign = 0.5,
|
---|
| 1474 | xscale=0.0, yscale = 0.0)
|
---|
| 1475 | label = gtk.Label(xstr("student_check_flight_status"))
|
---|
| 1476 | labelAlignment.add(label)
|
---|
| 1477 | table.attach(labelAlignment, 0, 1, row, row + 1, xoptions = FILL)
|
---|
| 1478 |
|
---|
| 1479 | alignment = gtk.Alignment(xalign=0.0, yalign = 0.5,
|
---|
| 1480 | xscale=1.0, yscale = 0.0)
|
---|
| 1481 | self._checkFlightStatus = gtk.Label()
|
---|
| 1482 | self._checkFlightStatus.set_use_markup(True)
|
---|
| 1483 | self._checkFlightStatus.set_alignment(0.0, 0.5)
|
---|
| 1484 | alignment.add(self._checkFlightStatus)
|
---|
| 1485 | table.attach(alignment, 1, 4, row, row + 1)
|
---|
| 1486 |
|
---|
| 1487 | row += 1
|
---|
| 1488 |
|
---|
| 1489 | alignment = gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 1490 |
|
---|
| 1491 | hbox = gtk.HBox()
|
---|
| 1492 | hbox.set_homogeneous(False)
|
---|
| 1493 | hbox.set_spacing(0)
|
---|
| 1494 |
|
---|
| 1495 | aircraftTypesModel = gtk.ListStore(str, int)
|
---|
| 1496 | for aircraftType in web.BookedFlight.checkFlightTypes:
|
---|
| 1497 | aircraftTypesModel.append([aircraftNames[aircraftType],
|
---|
| 1498 | aircraftType])
|
---|
| 1499 |
|
---|
| 1500 | aircraftTypeAlignment = gtk.Alignment(xalign = 0.0, xscale = 1.0)
|
---|
| 1501 |
|
---|
| 1502 | self._aircraftType = gtk.ComboBox(model = aircraftTypesModel)
|
---|
| 1503 | renderer = gtk.CellRendererText()
|
---|
| 1504 | self._aircraftType.pack_start(renderer, True)
|
---|
| 1505 | self._aircraftType.add_attribute(renderer, "text", 0)
|
---|
| 1506 | self._aircraftType.set_tooltip_text(xstr("student_check_flight_type_tooltip"))
|
---|
| 1507 | self._aircraftType.set_active(0)
|
---|
| 1508 |
|
---|
| 1509 | aircraftTypeAlignment.add(self._aircraftType)
|
---|
| 1510 |
|
---|
| 1511 | hbox.pack_start(aircraftTypeAlignment, False, False, 0)
|
---|
| 1512 |
|
---|
| 1513 | buttonAlignment = gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 1514 | button = self._checkFlightButton = gtk.Button(xstr("student_check_flight"))
|
---|
| 1515 | button.set_use_underline(True)
|
---|
| 1516 | button.connect("clicked", self._checkFlightClicked)
|
---|
| 1517 | button.set_tooltip_text(xstr("student_check_flight_tooltip"))
|
---|
| 1518 |
|
---|
| 1519 | hbox.pack_start(button, True, True, 0)
|
---|
| 1520 |
|
---|
| 1521 | alignment.add(hbox)
|
---|
| 1522 | table.attach(alignment, 0, 4, row, row + 1, xoptions = FILL)
|
---|
| 1523 |
|
---|
| 1524 | @property
|
---|
| 1525 | def aircraftType(self):
|
---|
| 1526 | """Get the type of the aircraft used to perform the check flight."""
|
---|
| 1527 | index = self._aircraftType.get_active()
|
---|
| 1528 | return self._aircraftType.get_model()[index][1]
|
---|
| 1529 |
|
---|
[762] | 1530 | def activate(self):
|
---|
| 1531 | """Activate the student page."""
|
---|
[769] | 1532 | print "StudentPage.activate"
|
---|
| 1533 | self._getEntryExamStatusCancelled = False
|
---|
| 1534 |
|
---|
[762] | 1535 | loginResult = self._wizard.loginResult
|
---|
[764] | 1536 | self._entryExamLink = loginResult.entryExamLink
|
---|
| 1537 |
|
---|
| 1538 | self._updateEntryExamStatus(loginResult.entryExamPassed)
|
---|
[762] | 1539 | self._getEntryExamStatus()
|
---|
| 1540 |
|
---|
[769] | 1541 | # FIXME: call with real value
|
---|
| 1542 | self._updateCheckFlightStatus(self._wizard.loginResult.checkFlightStatus)
|
---|
| 1543 |
|
---|
| 1544 | def finalize(self):
|
---|
| 1545 | """Finalize the page."""
|
---|
| 1546 | print "StudentPage.finalize"
|
---|
| 1547 | self._getEntryExamStatusCancelled = True
|
---|
| 1548 |
|
---|
[762] | 1549 | def _entryExamClicked(self, button):
|
---|
| 1550 | """Called when the entry exam button is clicked."""
|
---|
[764] | 1551 | webbrowser.open(self._entryExamLink)
|
---|
[762] | 1552 |
|
---|
| 1553 | def _getEntryExamStatus(self):
|
---|
| 1554 | """Initiate the query of the entry exam status after the interval."""
|
---|
[769] | 1555 | if not self._getEntryExamStatusCancelled:
|
---|
| 1556 | gobject.timeout_add(StudentPage._entryExamStatusQueryInterval,
|
---|
| 1557 | lambda: self._wizard.gui.webHandler. \
|
---|
| 1558 | getEntryExamStatus(self._entryExamStatusCallback))
|
---|
[762] | 1559 |
|
---|
| 1560 | def _entryExamStatusCallback(self, returned, result):
|
---|
| 1561 | """Called when the entry exam status is available."""
|
---|
| 1562 | gobject.idle_add(self._handleEntryExamStatus, returned, result)
|
---|
| 1563 |
|
---|
| 1564 | def _handleEntryExamStatus(self, returned, result):
|
---|
| 1565 | """Called when the entry exam status is availabe."""
|
---|
| 1566 | print "_handleEntryExamStatus", returned, result
|
---|
[769] | 1567 | if returned and not self._getEntryExamStatusCancelled:
|
---|
[764] | 1568 | self._entryExamLink = result.entryExamLink
|
---|
| 1569 | self._updateEntryExamStatus(result.entryExamPassed)
|
---|
[769] | 1570 | if result.madeFO:
|
---|
| 1571 | self._madeFO()
|
---|
| 1572 | else:
|
---|
| 1573 | self._getEntryExamStatus()
|
---|
[762] | 1574 |
|
---|
[764] | 1575 | def _updateEntryExamStatus(self, passed):
|
---|
| 1576 | """Update the entry exam status display and button."""
|
---|
| 1577 | self._entryExamStatus.set_text(xstr("student_entry_exam_passed")
|
---|
| 1578 | if passed else
|
---|
| 1579 | xstr("student_entry_exam_not_passed"))
|
---|
| 1580 | self._entryExamStatus.set_use_markup(True)
|
---|
| 1581 | self._entryExamButton.set_sensitive(not passed)
|
---|
[772] | 1582 | self._wizard._loginResult.entryExamPassed = passed
|
---|
[764] | 1583 |
|
---|
[769] | 1584 | def _checkFlightClicked(self, button):
|
---|
| 1585 | """Called when the check flight button is clicked."""
|
---|
| 1586 | aircraftType = self.aircraftType
|
---|
| 1587 | self._wizard._bookedFlight = \
|
---|
| 1588 | web.BookedFlight.forCheckFlight(aircraftType)
|
---|
| 1589 | self._wizard.gui.enableFlightInfo(aircraftType)
|
---|
| 1590 | self._wizard.jumpPage("connect")
|
---|
| 1591 |
|
---|
| 1592 | def _updateCheckFlightStatus(self, passed):
|
---|
| 1593 | """Update the status of the check flight."""
|
---|
| 1594 | self._aircraftType.set_sensitive(not passed)
|
---|
| 1595 | self._checkFlightStatus.set_text(xstr("student_check_flight_passed")
|
---|
| 1596 | if passed else
|
---|
| 1597 | xstr("student_check_flight_not_passed"))
|
---|
| 1598 | self._checkFlightStatus.set_use_markup(True)
|
---|
| 1599 | self._checkFlightButton.set_sensitive(not passed)
|
---|
| 1600 |
|
---|
| 1601 | def _madeFO(self):
|
---|
| 1602 | """Handle the event when the pilot has become a first officer."""
|
---|
| 1603 | wizard = self._wizard
|
---|
| 1604 | loginResult = wizard.loginResult
|
---|
| 1605 | loginResult.rank = "FO"
|
---|
| 1606 |
|
---|
| 1607 | gui = wizard.gui
|
---|
| 1608 |
|
---|
| 1609 | dialog = gtk.MessageDialog(parent = gui.mainWindow,
|
---|
| 1610 | type = MESSAGETYPE_INFO,
|
---|
| 1611 | message_format = xstr("student_fo"))
|
---|
| 1612 |
|
---|
| 1613 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 1614 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 1615 | secondary = xstr("student_fo_secondary")
|
---|
| 1616 | dialog.format_secondary_markup(secondary)
|
---|
| 1617 | dialog.run()
|
---|
| 1618 | dialog.hide()
|
---|
| 1619 |
|
---|
| 1620 | gui.reset()
|
---|
| 1621 |
|
---|
[753] | 1622 | #-----------------------------------------------------------------------------
|
---|
| 1623 |
|
---|
[51] | 1624 | class ConnectPage(Page):
|
---|
| 1625 | """Page which displays the departure airport and gate (if at LHBP)."""
|
---|
| 1626 | def __init__(self, wizard):
|
---|
| 1627 | """Construct the connect page."""
|
---|
[78] | 1628 | help = "Load the aircraft below into the simulator and park it\n" \
|
---|
| 1629 | "at the given airport, at the gate below, if present.\n\n" \
|
---|
[51] | 1630 | "Then press the Connect button to connect to the simulator."
|
---|
[94] | 1631 | completedHelp = "The basic data of your flight can be read below."
|
---|
[754] | 1632 | super(ConnectPage, self).__init__(wizard, "connect",
|
---|
| 1633 | xstr("connect_title"),
|
---|
[107] | 1634 | xstr("connect_help"),
|
---|
| 1635 | completedHelp = xstr("connect_chelp"))
|
---|
[347] | 1636 |
|
---|
[501] | 1637 | self._selectSimulator = os.name=="nt" or "FORCE_SELECT_SIM" in os.environ
|
---|
| 1638 |
|
---|
[51] | 1639 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1640 | xscale = 0.0, yscale = 0.0)
|
---|
| 1641 |
|
---|
[501] | 1642 | table = gtk.Table(7 if self._selectSimulator else 5, 2)
|
---|
[51] | 1643 | table.set_row_spacings(4)
|
---|
| 1644 | table.set_col_spacings(16)
|
---|
| 1645 | table.set_homogeneous(True)
|
---|
| 1646 | alignment.add(table)
|
---|
| 1647 | self.setMainWidget(alignment)
|
---|
| 1648 |
|
---|
| 1649 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 1650 | label = gtk.Label(xstr("connect_flightno"))
|
---|
[51] | 1651 | labelAlignment.add(label)
|
---|
| 1652 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 1653 |
|
---|
| 1654 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[78] | 1655 | self._flightNumber = gtk.Label()
|
---|
[191] | 1656 | self._flightNumber.set_width_chars(9)
|
---|
[78] | 1657 | self._flightNumber.set_alignment(0.0, 0.5)
|
---|
| 1658 | labelAlignment.add(self._flightNumber)
|
---|
| 1659 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
| 1660 |
|
---|
| 1661 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 1662 | label = gtk.Label(xstr("connect_acft"))
|
---|
[78] | 1663 | labelAlignment.add(label)
|
---|
| 1664 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 1665 |
|
---|
| 1666 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1667 | self._aircraft = gtk.Label()
|
---|
| 1668 | self._aircraft.set_width_chars(25)
|
---|
| 1669 | self._aircraft.set_alignment(0.0, 0.5)
|
---|
| 1670 | labelAlignment.add(self._aircraft)
|
---|
| 1671 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
| 1672 |
|
---|
| 1673 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 1674 | label = gtk.Label(xstr("connect_tailno"))
|
---|
[78] | 1675 | labelAlignment.add(label)
|
---|
| 1676 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
| 1677 |
|
---|
| 1678 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1679 | self._tailNumber = gtk.Label()
|
---|
[80] | 1680 | self._tailNumber.set_width_chars(10)
|
---|
[78] | 1681 | self._tailNumber.set_alignment(0.0, 0.5)
|
---|
| 1682 | labelAlignment.add(self._tailNumber)
|
---|
| 1683 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
| 1684 |
|
---|
| 1685 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 1686 | label = gtk.Label(xstr("connect_airport"))
|
---|
[78] | 1687 | labelAlignment.add(label)
|
---|
| 1688 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
| 1689 |
|
---|
| 1690 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[51] | 1691 | self._departureICAO = gtk.Label()
|
---|
[80] | 1692 | self._departureICAO.set_width_chars(6)
|
---|
[51] | 1693 | self._departureICAO.set_alignment(0.0, 0.5)
|
---|
| 1694 | labelAlignment.add(self._departureICAO)
|
---|
[78] | 1695 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
[51] | 1696 |
|
---|
| 1697 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 1698 | label = gtk.Label(xstr("connect_gate"))
|
---|
[51] | 1699 | labelAlignment.add(label)
|
---|
[78] | 1700 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
[51] | 1701 |
|
---|
| 1702 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 1703 | self._departureGate = gtk.Label()
|
---|
| 1704 | self._departureGate.set_width_chars(5)
|
---|
| 1705 | self._departureGate.set_alignment(0.0, 0.5)
|
---|
| 1706 | labelAlignment.add(self._departureGate)
|
---|
[78] | 1707 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
[51] | 1708 |
|
---|
[501] | 1709 | if self._selectSimulator:
|
---|
| 1710 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0, yalign=0.5)
|
---|
| 1711 | label = gtk.Label(xstr("connect_sim"))
|
---|
| 1712 | labelAlignment.add(label)
|
---|
| 1713 | table.attach(labelAlignment, 0, 1, 5, 7)
|
---|
| 1714 |
|
---|
| 1715 | selectAlignment = gtk.Alignment(xalign=0.0, xscale=0.0, yalign=0.5)
|
---|
| 1716 |
|
---|
| 1717 | selectBox = gtk.HBox()
|
---|
| 1718 | if pygobject:
|
---|
| 1719 | self._selectMSFS = \
|
---|
| 1720 | gtk.RadioButton.new_with_mnemonic_from_widget(None,
|
---|
| 1721 | xstr("connect_sim_msfs"))
|
---|
| 1722 | else:
|
---|
| 1723 | self._selectMSFS = gtk.RadioButton(None,
|
---|
| 1724 | xstr("connect_sim_msfs"))
|
---|
| 1725 |
|
---|
| 1726 | selectBox.pack_start(self._selectMSFS, False, False, 0);
|
---|
| 1727 |
|
---|
| 1728 | if pygobject:
|
---|
| 1729 | self._selectXPlane = \
|
---|
| 1730 | gtk.RadioButton.new_with_mnemonic_from_widget(self._selectMSFS,
|
---|
| 1731 | xstr("connect_sim_xplane"))
|
---|
| 1732 | else:
|
---|
| 1733 | self._selectXPlane = gtk.RadioButton(self._selectMSFS,
|
---|
| 1734 | xstr("connect_sim_xplane"))
|
---|
| 1735 |
|
---|
| 1736 | selectBox.pack_start(self._selectXPlane, False, False, 8);
|
---|
| 1737 |
|
---|
| 1738 | selectAlignment.add(selectBox)
|
---|
| 1739 | table.attach(selectAlignment, 1, 2, 5, 7)
|
---|
| 1740 |
|
---|
| 1741 |
|
---|
[208] | 1742 | self.addCancelFlightButton()
|
---|
| 1743 |
|
---|
[769] | 1744 | self._previousButton = \
|
---|
| 1745 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[70] | 1746 |
|
---|
[107] | 1747 | self._button = self.addButton(xstr("button_connect"), default = True,
|
---|
| 1748 | tooltip = xstr("button_connect_tooltip"))
|
---|
[70] | 1749 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[51] | 1750 |
|
---|
| 1751 | def activate(self):
|
---|
[60] | 1752 | """Setup the departure information."""
|
---|
[107] | 1753 | self._button.set_label(xstr("button_connect"))
|
---|
[70] | 1754 | self._button.set_use_underline(True)
|
---|
[107] | 1755 | self._button.set_tooltip_text(xstr("button_connect_tooltip"))
|
---|
[70] | 1756 | self._button.disconnect(self._clickedID)
|
---|
| 1757 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[78] | 1758 |
|
---|
| 1759 | bookedFlight = self._wizard._bookedFlight
|
---|
| 1760 |
|
---|
| 1761 | self._flightNumber.set_markup("<b>" + bookedFlight.callsign + "</b>")
|
---|
| 1762 |
|
---|
[191] | 1763 | aircraftType = aircraftNames[bookedFlight.aircraftType]
|
---|
[78] | 1764 | self._aircraft.set_markup("<b>" + aircraftType + "</b>")
|
---|
[347] | 1765 |
|
---|
[78] | 1766 | self._tailNumber.set_markup("<b>" + bookedFlight.tailNumber + "</b>")
|
---|
| 1767 |
|
---|
| 1768 | icao = bookedFlight.departureICAO
|
---|
[51] | 1769 | self._departureICAO.set_markup("<b>" + icao + "</b>")
|
---|
| 1770 | gate = self._wizard._departureGate
|
---|
| 1771 | if gate!="-":
|
---|
| 1772 | gate = "<b>" + gate + "</b>"
|
---|
| 1773 | self._departureGate.set_markup(gate)
|
---|
| 1774 |
|
---|
[501] | 1775 | if self._selectSimulator:
|
---|
[503] | 1776 | config = self._wizard.gui.config
|
---|
| 1777 | self._selectMSFS.set_active(config.defaultMSFS)
|
---|
| 1778 | self._selectXPlane.set_active(not config.defaultMSFS)
|
---|
[501] | 1779 |
|
---|
[769] | 1780 | self._previousButton.set_sensitive(not self._wizard.entranceExam)
|
---|
| 1781 |
|
---|
[70] | 1782 | def finalize(self):
|
---|
| 1783 | """Finalize the page."""
|
---|
[107] | 1784 | self._button.set_label(xstr("button_next"))
|
---|
| 1785 | self._button.set_use_underline(True)
|
---|
| 1786 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
[70] | 1787 | self._button.disconnect(self._clickedID)
|
---|
| 1788 | self._clickedID = self._button.connect("clicked", self._forwardClicked)
|
---|
| 1789 |
|
---|
| 1790 | def _backClicked(self, button):
|
---|
| 1791 | """Called when the Back button is pressed."""
|
---|
| 1792 | self.goBack()
|
---|
| 1793 |
|
---|
[51] | 1794 | def _connectClicked(self, button):
|
---|
| 1795 | """Called when the Connect button is pressed."""
|
---|
[501] | 1796 | if self._selectSimulator:
|
---|
| 1797 | simulatorType = const.SIM_MSFS9 if self._selectMSFS.get_active() \
|
---|
| 1798 | else const.SIM_XPLANE10
|
---|
| 1799 | else:
|
---|
| 1800 | simulatorType = const.SIM_MSFS9 if os.name=="nt" \
|
---|
[503] | 1801 | else const.SIM_XPLANE10
|
---|
| 1802 |
|
---|
| 1803 | config = self._wizard.gui.config
|
---|
| 1804 | config.defaultMSFS = simulatorType == const.SIM_MSFS9
|
---|
| 1805 | config.save()
|
---|
| 1806 |
|
---|
[501] | 1807 | self._wizard._connectSimulator(simulatorType)
|
---|
[51] | 1808 |
|
---|
[70] | 1809 | def _forwardClicked(self, button):
|
---|
| 1810 | """Called when the Forward button is pressed."""
|
---|
| 1811 | self._wizard.nextPage()
|
---|
| 1812 |
|
---|
[42] | 1813 | #-----------------------------------------------------------------------------
|
---|
| 1814 |
|
---|
[59] | 1815 | class PayloadPage(Page):
|
---|
| 1816 | """Page to allow setting up the payload."""
|
---|
| 1817 | def __init__(self, wizard):
|
---|
| 1818 | """Construct the page."""
|
---|
[754] | 1819 | super(PayloadPage, self).__init__(wizard, "payload",
|
---|
| 1820 | xstr("payload_title"),
|
---|
[107] | 1821 | xstr("payload_help"),
|
---|
| 1822 | completedHelp = xstr("payload_chelp"))
|
---|
[59] | 1823 |
|
---|
[60] | 1824 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1825 | xscale = 0.0, yscale = 0.0)
|
---|
| 1826 |
|
---|
| 1827 | table = gtk.Table(7, 3)
|
---|
| 1828 | table.set_row_spacings(4)
|
---|
| 1829 | table.set_col_spacings(16)
|
---|
| 1830 | table.set_homogeneous(False)
|
---|
| 1831 | alignment.add(table)
|
---|
| 1832 | self.setMainWidget(alignment)
|
---|
| 1833 |
|
---|
[107] | 1834 | label = gtk.Label(xstr("payload_crew"))
|
---|
[309] | 1835 | label.set_use_underline(True)
|
---|
[60] | 1836 | label.set_alignment(0.0, 0.5)
|
---|
| 1837 | table.attach(label, 0, 1, 0, 1)
|
---|
| 1838 |
|
---|
[303] | 1839 | self._numCrew = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1840 | self._numCrew.set_width_chars(6)
|
---|
[303] | 1841 | self._numCrew.connect("integer-changed", self._weightChanged)
|
---|
| 1842 | self._numCrew.set_tooltip_text(xstr("payload_crew_tooltip"))
|
---|
[60] | 1843 | table.attach(self._numCrew, 1, 2, 0, 1)
|
---|
[303] | 1844 | label.set_mnemonic_widget(self._numCrew)
|
---|
[347] | 1845 |
|
---|
[107] | 1846 | label = gtk.Label(xstr("payload_pax"))
|
---|
[309] | 1847 | label.set_use_underline(True)
|
---|
[60] | 1848 | label.set_alignment(0.0, 0.5)
|
---|
| 1849 | table.attach(label, 0, 1, 1, 2)
|
---|
| 1850 |
|
---|
[347] | 1851 | self._numPassengers = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1852 | self._numPassengers.set_width_chars(6)
|
---|
[303] | 1853 | self._numPassengers.connect("integer-changed", self._weightChanged)
|
---|
| 1854 | self._numPassengers.set_tooltip_text(xstr("payload_pax_tooltip"))
|
---|
[60] | 1855 | table.attach(self._numPassengers, 1, 2, 1, 2)
|
---|
[303] | 1856 | label.set_mnemonic_widget(self._numPassengers)
|
---|
[347] | 1857 |
|
---|
[107] | 1858 | label = gtk.Label(xstr("payload_bag"))
|
---|
[309] | 1859 | label.set_use_underline(True)
|
---|
[60] | 1860 | label.set_alignment(0.0, 0.5)
|
---|
| 1861 | table.attach(label, 0, 1, 2, 3)
|
---|
| 1862 |
|
---|
[303] | 1863 | self._bagWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1864 | self._bagWeight.set_width_chars(6)
|
---|
[303] | 1865 | self._bagWeight.connect("integer-changed", self._weightChanged)
|
---|
| 1866 | self._bagWeight.set_tooltip_text(xstr("payload_bag_tooltip"))
|
---|
[60] | 1867 | table.attach(self._bagWeight, 1, 2, 2, 3)
|
---|
[303] | 1868 | label.set_mnemonic_widget(self._bagWeight)
|
---|
[60] | 1869 |
|
---|
| 1870 | table.attach(gtk.Label("kg"), 2, 3, 2, 3)
|
---|
[347] | 1871 |
|
---|
[107] | 1872 | label = gtk.Label(xstr("payload_cargo"))
|
---|
[60] | 1873 | label.set_use_underline(True)
|
---|
| 1874 | label.set_alignment(0.0, 0.5)
|
---|
| 1875 | table.attach(label, 0, 1, 3, 4)
|
---|
| 1876 |
|
---|
[84] | 1877 | self._cargoWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1878 | self._cargoWeight.set_width_chars(6)
|
---|
[303] | 1879 | self._cargoWeight.connect("integer-changed", self._weightChanged)
|
---|
[107] | 1880 | self._cargoWeight.set_tooltip_text(xstr("payload_cargo_tooltip"))
|
---|
[60] | 1881 | table.attach(self._cargoWeight, 1, 2, 3, 4)
|
---|
| 1882 | label.set_mnemonic_widget(self._cargoWeight)
|
---|
| 1883 |
|
---|
| 1884 | table.attach(gtk.Label("kg"), 2, 3, 3, 4)
|
---|
[347] | 1885 |
|
---|
[107] | 1886 | label = gtk.Label(xstr("payload_mail"))
|
---|
[309] | 1887 | label.set_use_underline(True)
|
---|
[60] | 1888 | label.set_alignment(0.0, 0.5)
|
---|
| 1889 | table.attach(label, 0, 1, 4, 5)
|
---|
| 1890 |
|
---|
[303] | 1891 | self._mailWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1892 | self._mailWeight.set_width_chars(6)
|
---|
[303] | 1893 | self._mailWeight.connect("integer-changed", self._weightChanged)
|
---|
| 1894 | self._mailWeight.set_tooltip_text(xstr("payload_mail_tooltip"))
|
---|
[60] | 1895 | table.attach(self._mailWeight, 1, 2, 4, 5)
|
---|
[303] | 1896 | label.set_mnemonic_widget(self._mailWeight)
|
---|
[60] | 1897 |
|
---|
| 1898 | table.attach(gtk.Label("kg"), 2, 3, 4, 5)
|
---|
[347] | 1899 |
|
---|
[107] | 1900 | label = gtk.Label("<b>" + xstr("payload_zfw") + "</b>")
|
---|
[60] | 1901 | label.set_alignment(0.0, 0.5)
|
---|
| 1902 | label.set_use_markup(True)
|
---|
| 1903 | table.attach(label, 0, 1, 5, 6)
|
---|
| 1904 |
|
---|
| 1905 | self._calculatedZFW = gtk.Label()
|
---|
| 1906 | self._calculatedZFW.set_width_chars(6)
|
---|
| 1907 | self._calculatedZFW.set_alignment(1.0, 0.5)
|
---|
| 1908 | table.attach(self._calculatedZFW, 1, 2, 5, 6)
|
---|
| 1909 |
|
---|
| 1910 | table.attach(gtk.Label("kg"), 2, 3, 5, 6)
|
---|
| 1911 |
|
---|
[107] | 1912 | self._zfwButton = gtk.Button(xstr("payload_fszfw"))
|
---|
[70] | 1913 | self._zfwButton.set_use_underline(True)
|
---|
| 1914 | self._zfwButton.connect("clicked", self._zfwRequested)
|
---|
[107] | 1915 | self._zfwButton.set_tooltip_text(xstr("payload_fszfw_tooltip"))
|
---|
[70] | 1916 | table.attach(self._zfwButton, 0, 1, 6, 7)
|
---|
[60] | 1917 |
|
---|
| 1918 | self._simulatorZFW = gtk.Label("-")
|
---|
| 1919 | self._simulatorZFW.set_width_chars(6)
|
---|
| 1920 | self._simulatorZFW.set_alignment(1.0, 0.5)
|
---|
| 1921 | table.attach(self._simulatorZFW, 1, 2, 6, 7)
|
---|
| 1922 | self._simulatorZFWValue = None
|
---|
| 1923 |
|
---|
| 1924 | table.attach(gtk.Label("kg"), 2, 3, 6, 7)
|
---|
| 1925 |
|
---|
[208] | 1926 | self.addCancelFlightButton()
|
---|
[107] | 1927 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1928 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[60] | 1929 |
|
---|
[97] | 1930 | @property
|
---|
[303] | 1931 | def numCrew(self):
|
---|
| 1932 | """The number of the crew members on the flight."""
|
---|
| 1933 | return self._numCrew.get_int()
|
---|
[347] | 1934 |
|
---|
[303] | 1935 | @property
|
---|
| 1936 | def numPassengers(self):
|
---|
| 1937 | """The number of the passengers on the flight."""
|
---|
| 1938 | return self._numPassengers.get_int()
|
---|
[347] | 1939 |
|
---|
[303] | 1940 | @property
|
---|
| 1941 | def bagWeight(self):
|
---|
| 1942 | """Get the bag weight entered."""
|
---|
| 1943 | return self._bagWeight.get_int()
|
---|
| 1944 |
|
---|
| 1945 | @property
|
---|
[97] | 1946 | def cargoWeight(self):
|
---|
| 1947 | """Get the cargo weight entered."""
|
---|
| 1948 | return self._cargoWeight.get_int()
|
---|
| 1949 |
|
---|
[303] | 1950 | @property
|
---|
| 1951 | def mailWeight(self):
|
---|
| 1952 | """Get the bag weight entered."""
|
---|
| 1953 | return self._mailWeight.get_int()
|
---|
| 1954 |
|
---|
[60] | 1955 | def activate(self):
|
---|
| 1956 | """Setup the information."""
|
---|
| 1957 | bookedFlight = self._wizard._bookedFlight
|
---|
[303] | 1958 |
|
---|
| 1959 | self._numCrew.set_int(bookedFlight.numCrew)
|
---|
| 1960 | self._numCrew.set_sensitive(True)
|
---|
| 1961 | self._numPassengers.set_int(bookedFlight.numPassengers)
|
---|
| 1962 | self._numPassengers.set_sensitive(True)
|
---|
| 1963 |
|
---|
| 1964 | self._bagWeight.set_int(bookedFlight.bagWeight)
|
---|
| 1965 | self._bagWeight.set_sensitive(True)
|
---|
[84] | 1966 | self._cargoWeight.set_int(bookedFlight.cargoWeight)
|
---|
[70] | 1967 | self._cargoWeight.set_sensitive(True)
|
---|
[303] | 1968 | self._mailWeight.set_int(bookedFlight.mailWeight)
|
---|
| 1969 | self._mailWeight.set_sensitive(True)
|
---|
[347] | 1970 |
|
---|
[92] | 1971 | self._simulatorZFW.set_text("-")
|
---|
| 1972 | self._simulatorZFWValue = None
|
---|
[70] | 1973 | self._zfwButton.set_sensitive(True)
|
---|
[60] | 1974 | self._updateCalculatedZFW()
|
---|
[59] | 1975 |
|
---|
[70] | 1976 | def finalize(self):
|
---|
| 1977 | """Finalize the payload page."""
|
---|
[303] | 1978 | self._numCrew.set_sensitive(False)
|
---|
| 1979 | self._numPassengers.set_sensitive(False)
|
---|
| 1980 | self._bagWeight.set_sensitive(False)
|
---|
[70] | 1981 | self._cargoWeight.set_sensitive(False)
|
---|
[303] | 1982 | self._mailWeight.set_sensitive(False)
|
---|
[117] | 1983 | self._wizard.gui.initializeWeightHelp()
|
---|
[70] | 1984 |
|
---|
[84] | 1985 | def calculateZFW(self):
|
---|
[60] | 1986 | """Calculate the ZFW value."""
|
---|
| 1987 | zfw = self._wizard.gui._flight.aircraft.dow
|
---|
[303] | 1988 | zfw += (self._numCrew.get_int() + self._numPassengers.get_int()) * 82
|
---|
| 1989 | zfw += self._bagWeight.get_int()
|
---|
[84] | 1990 | zfw += self._cargoWeight.get_int()
|
---|
[303] | 1991 | zfw += self._mailWeight.get_int()
|
---|
[60] | 1992 | return zfw
|
---|
[347] | 1993 |
|
---|
[60] | 1994 | def _updateCalculatedZFW(self):
|
---|
| 1995 | """Update the calculated ZFW"""
|
---|
[84] | 1996 | zfw = self.calculateZFW()
|
---|
[60] | 1997 |
|
---|
| 1998 | markupBegin = "<b>"
|
---|
| 1999 | markupEnd = "</b>"
|
---|
| 2000 | if self._simulatorZFWValue is not None and \
|
---|
| 2001 | PayloadChecker.isZFWFaulty(self._simulatorZFWValue, zfw):
|
---|
| 2002 | markupBegin += '<span foreground="red">'
|
---|
| 2003 | markupEnd = "</span>" + markupEnd
|
---|
| 2004 | self._calculatedZFW.set_markup(markupBegin + str(zfw) + markupEnd)
|
---|
| 2005 |
|
---|
[303] | 2006 | def _weightChanged(self, entry, weight):
|
---|
| 2007 | """Called when one of the weight values or humanm counts has changed."""
|
---|
[60] | 2008 | self._updateCalculatedZFW()
|
---|
[347] | 2009 |
|
---|
[59] | 2010 | def _zfwRequested(self, button):
|
---|
| 2011 | """Called when the ZFW is requested from the simulator."""
|
---|
[70] | 2012 | self._zfwButton.set_sensitive(False)
|
---|
| 2013 | self._backButton.set_sensitive(False)
|
---|
| 2014 | self._button.set_sensitive(False)
|
---|
| 2015 | gui = self._wizard.gui
|
---|
[107] | 2016 | gui.beginBusy(xstr("payload_zfw_busy"))
|
---|
[70] | 2017 | gui.simulator.requestZFW(self._handleZFW)
|
---|
[59] | 2018 |
|
---|
| 2019 | def _handleZFW(self, zfw):
|
---|
| 2020 | """Called when the ZFW value is retrieved."""
|
---|
[60] | 2021 | gobject.idle_add(self._processZFW, zfw)
|
---|
[59] | 2022 |
|
---|
[60] | 2023 | def _processZFW(self, zfw):
|
---|
| 2024 | """Process the given ZFW value received from the simulator."""
|
---|
[61] | 2025 | self._wizard.gui.endBusy()
|
---|
[70] | 2026 | self._zfwButton.set_sensitive(True)
|
---|
| 2027 | self._backButton.set_sensitive(True)
|
---|
| 2028 | self._button.set_sensitive(True)
|
---|
[60] | 2029 | self._simulatorZFWValue = zfw
|
---|
| 2030 | self._simulatorZFW.set_text("%.0f" % (zfw,))
|
---|
| 2031 | self._updateCalculatedZFW()
|
---|
| 2032 |
|
---|
| 2033 | def _forwardClicked(self, button):
|
---|
| 2034 | """Called when the forward button is clicked."""
|
---|
| 2035 | self._wizard.nextPage()
|
---|
[70] | 2036 |
|
---|
| 2037 | def _backClicked(self, button):
|
---|
| 2038 | """Called when the Back button is pressed."""
|
---|
| 2039 | self.goBack()
|
---|
[347] | 2040 |
|
---|
[59] | 2041 | #-----------------------------------------------------------------------------
|
---|
| 2042 |
|
---|
[61] | 2043 | class TimePage(Page):
|
---|
| 2044 | """Page displaying the departure and arrival times and allows querying the
|
---|
| 2045 | current time from the flight simulator."""
|
---|
| 2046 | def __init__(self, wizard):
|
---|
[754] | 2047 | super(TimePage, self).__init__(wizard, "time",
|
---|
| 2048 | xstr("time_title"),
|
---|
[107] | 2049 | xstr("time_help"),
|
---|
| 2050 | completedHelp = xstr("time_chelp"))
|
---|
[61] | 2051 |
|
---|
| 2052 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2053 | xscale = 0.0, yscale = 0.0)
|
---|
| 2054 |
|
---|
| 2055 | table = gtk.Table(3, 2)
|
---|
| 2056 | table.set_row_spacings(4)
|
---|
| 2057 | table.set_col_spacings(16)
|
---|
| 2058 | table.set_homogeneous(False)
|
---|
| 2059 | alignment.add(table)
|
---|
| 2060 | self.setMainWidget(alignment)
|
---|
| 2061 |
|
---|
[107] | 2062 | label = gtk.Label(xstr("time_departure"))
|
---|
[61] | 2063 | label.set_alignment(0.0, 0.5)
|
---|
| 2064 | table.attach(label, 0, 1, 0, 1)
|
---|
| 2065 |
|
---|
| 2066 | self._departure = gtk.Label()
|
---|
| 2067 | self._departure.set_alignment(0.0, 0.5)
|
---|
| 2068 | table.attach(self._departure, 1, 2, 0, 1)
|
---|
[347] | 2069 |
|
---|
[107] | 2070 | label = gtk.Label(xstr("time_arrival"))
|
---|
[61] | 2071 | label.set_alignment(0.0, 0.5)
|
---|
| 2072 | table.attach(label, 0, 1, 1, 2)
|
---|
| 2073 |
|
---|
| 2074 | self._arrival = gtk.Label()
|
---|
| 2075 | self._arrival.set_alignment(0.0, 0.5)
|
---|
| 2076 | table.attach(self._arrival, 1, 2, 1, 2)
|
---|
| 2077 |
|
---|
[107] | 2078 | self._timeButton = gtk.Button(xstr("time_fs"))
|
---|
[70] | 2079 | self._timeButton.set_use_underline(True)
|
---|
[107] | 2080 | self._timeButton.set_tooltip_text(xstr("time_fs_tooltip"))
|
---|
[70] | 2081 | self._timeButton.connect("clicked", self._timeRequested)
|
---|
| 2082 | table.attach(self._timeButton, 0, 1, 2, 3)
|
---|
[61] | 2083 |
|
---|
| 2084 | self._simulatorTime = gtk.Label("-")
|
---|
| 2085 | self._simulatorTime.set_alignment(0.0, 0.5)
|
---|
| 2086 | table.attach(self._simulatorTime, 1, 2, 2, 3)
|
---|
| 2087 |
|
---|
[208] | 2088 | self.addCancelFlightButton()
|
---|
| 2089 |
|
---|
[107] | 2090 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2091 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[61] | 2092 |
|
---|
| 2093 | def activate(self):
|
---|
| 2094 | """Activate the page."""
|
---|
[70] | 2095 | self._timeButton.set_sensitive(True)
|
---|
[61] | 2096 | bookedFlight = self._wizard._bookedFlight
|
---|
| 2097 | self._departure.set_text(str(bookedFlight.departureTime.time()))
|
---|
| 2098 | self._arrival.set_text(str(bookedFlight.arrivalTime.time()))
|
---|
[92] | 2099 | self._simulatorTime.set_text("-")
|
---|
[61] | 2100 |
|
---|
| 2101 | def _timeRequested(self, button):
|
---|
| 2102 | """Request the time from the simulator."""
|
---|
[70] | 2103 | self._timeButton.set_sensitive(False)
|
---|
| 2104 | self._backButton.set_sensitive(False)
|
---|
| 2105 | self._button.set_sensitive(False)
|
---|
[107] | 2106 | self._wizard.gui.beginBusy(xstr("time_busy"))
|
---|
[61] | 2107 | self._wizard.gui.simulator.requestTime(self._handleTime)
|
---|
| 2108 |
|
---|
| 2109 | def _handleTime(self, timestamp):
|
---|
| 2110 | """Handle the result of a time retrieval."""
|
---|
| 2111 | gobject.idle_add(self._processTime, timestamp)
|
---|
| 2112 |
|
---|
| 2113 | def _processTime(self, timestamp):
|
---|
| 2114 | """Process the given time."""
|
---|
| 2115 | self._wizard.gui.endBusy()
|
---|
[70] | 2116 | self._timeButton.set_sensitive(True)
|
---|
| 2117 | self._backButton.set_sensitive(True)
|
---|
| 2118 | self._button.set_sensitive(True)
|
---|
[61] | 2119 | tm = time.gmtime(timestamp)
|
---|
| 2120 | t = datetime.time(tm.tm_hour, tm.tm_min, tm.tm_sec)
|
---|
| 2121 | self._simulatorTime.set_text(str(t))
|
---|
| 2122 |
|
---|
| 2123 | ts = tm.tm_hour * 3600 + tm.tm_min * 60 + tm.tm_sec
|
---|
| 2124 | dt = self._wizard._bookedFlight.departureTime.time()
|
---|
| 2125 | dts = dt.hour * 3600 + dt.minute * 60 + dt.second
|
---|
| 2126 | diff = dts-ts
|
---|
| 2127 |
|
---|
| 2128 | markupBegin = ""
|
---|
| 2129 | markupEnd = ""
|
---|
| 2130 | if diff < 0:
|
---|
| 2131 | markupBegin = '<b><span foreground="red">'
|
---|
| 2132 | markupEnd = '</span></b>'
|
---|
| 2133 | elif diff < 3*60 or diff > 30*60:
|
---|
| 2134 | markupBegin = '<b><span foreground="orange">'
|
---|
| 2135 | markupEnd = '</span></b>'
|
---|
| 2136 |
|
---|
| 2137 | self._departure.set_markup(markupBegin + str(dt) + markupEnd)
|
---|
| 2138 |
|
---|
[70] | 2139 | def _backClicked(self, button):
|
---|
| 2140 | """Called when the Back button is pressed."""
|
---|
| 2141 | self.goBack()
|
---|
[347] | 2142 |
|
---|
[61] | 2143 | def _forwardClicked(self, button):
|
---|
| 2144 | """Called when the forward button is clicked."""
|
---|
[141] | 2145 | if not self._completed:
|
---|
| 2146 | gui = self._wizard.gui
|
---|
| 2147 | gui.beginBusy(xstr("fuel_get_busy"))
|
---|
[347] | 2148 |
|
---|
[274] | 2149 | gui.simulator.getFuel(self._handleFuel)
|
---|
[141] | 2150 | else:
|
---|
| 2151 | self._wizard.nextPage()
|
---|
| 2152 |
|
---|
| 2153 | def _handleFuel(self, fuelData):
|
---|
| 2154 | """Callback for the fuel query operation."""
|
---|
| 2155 | gobject.idle_add(self._processFuel, fuelData)
|
---|
| 2156 |
|
---|
| 2157 | def _processFuel(self, fuelData):
|
---|
| 2158 | """Process the given fuel data."""
|
---|
| 2159 | self._wizard.gui.endBusy()
|
---|
| 2160 | self._wizard._fuelData = fuelData
|
---|
[61] | 2161 | self._wizard.nextPage()
|
---|
[347] | 2162 |
|
---|
[61] | 2163 | #-----------------------------------------------------------------------------
|
---|
| 2164 |
|
---|
[687] | 2165 | class RoutePage(Page):
|
---|
| 2166 | """The page containing the route and the flight level."""
|
---|
| 2167 | def __init__(self, wizard):
|
---|
| 2168 | """Construct the page."""
|
---|
[754] | 2169 | super(RoutePage, self).__init__(wizard, "route",
|
---|
| 2170 | xstr("route_title"),
|
---|
[687] | 2171 | xstr("route_help"),
|
---|
| 2172 | completedHelp = xstr("route_chelp"))
|
---|
| 2173 |
|
---|
| 2174 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2175 | xscale = 0.0, yscale = 0.0)
|
---|
| 2176 |
|
---|
| 2177 | mainBox = gtk.VBox()
|
---|
| 2178 | alignment.add(mainBox)
|
---|
| 2179 | self.setMainWidget(alignment)
|
---|
| 2180 |
|
---|
| 2181 | levelBox = gtk.HBox()
|
---|
| 2182 |
|
---|
| 2183 | label = gtk.Label(xstr("route_level"))
|
---|
| 2184 | label.set_use_underline(True)
|
---|
| 2185 | levelBox.pack_start(label, True, True, 0)
|
---|
| 2186 |
|
---|
| 2187 | self._cruiseLevel = gtk.SpinButton()
|
---|
| 2188 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
| 2189 | self._cruiseLevel.set_range(min = 0, max = 500)
|
---|
| 2190 | self._cruiseLevel.set_tooltip_text(xstr("route_level_tooltip"))
|
---|
| 2191 | self._cruiseLevel.set_numeric(True)
|
---|
| 2192 | self._cruiseLevel.connect("changed", self._cruiseLevelChanged)
|
---|
| 2193 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
| 2194 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
| 2195 |
|
---|
| 2196 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
| 2197 |
|
---|
| 2198 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 2199 | xscale = 0.0, yscale = 0.0)
|
---|
| 2200 | alignment.add(levelBox)
|
---|
| 2201 |
|
---|
| 2202 | mainBox.pack_start(alignment, False, False, 0)
|
---|
| 2203 |
|
---|
| 2204 |
|
---|
| 2205 | routeBox = gtk.VBox()
|
---|
| 2206 |
|
---|
| 2207 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 2208 | xscale = 0.0, yscale = 0.0)
|
---|
| 2209 | label = gtk.Label(xstr("route_route"))
|
---|
| 2210 | label.set_use_underline(True)
|
---|
| 2211 | alignment.add(label)
|
---|
| 2212 | routeBox.pack_start(alignment, True, True, 0)
|
---|
| 2213 |
|
---|
| 2214 | routeWindow = gtk.ScrolledWindow()
|
---|
| 2215 | routeWindow.set_size_request(400, 80)
|
---|
| 2216 | routeWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 2217 | else gtk.SHADOW_IN)
|
---|
| 2218 | routeWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 2219 | else gtk.POLICY_AUTOMATIC,
|
---|
| 2220 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 2221 | else gtk.POLICY_AUTOMATIC)
|
---|
| 2222 |
|
---|
| 2223 | self._uppercasingRoute = False
|
---|
| 2224 |
|
---|
| 2225 | self._route = gtk.TextView()
|
---|
| 2226 | self._route.set_tooltip_text(xstr("route_route_tooltip"))
|
---|
| 2227 | self._route.set_wrap_mode(WRAP_WORD)
|
---|
| 2228 | self._route.get_buffer().connect("changed", self._routeChanged)
|
---|
| 2229 | self._route.get_buffer().connect_after("insert-text", self._routeInserted)
|
---|
| 2230 | routeWindow.add(self._route)
|
---|
| 2231 |
|
---|
| 2232 | label.set_mnemonic_widget(self._route)
|
---|
| 2233 | routeBox.pack_start(routeWindow, True, True, 0)
|
---|
| 2234 |
|
---|
| 2235 | mainBox.pack_start(routeBox, True, True, 8)
|
---|
| 2236 |
|
---|
| 2237 | alternateBox = gtk.HBox()
|
---|
| 2238 |
|
---|
| 2239 | label = gtk.Label(xstr("route_altn"))
|
---|
| 2240 | label.set_use_underline(True)
|
---|
| 2241 | alternateBox.pack_start(label, True, True, 0)
|
---|
| 2242 |
|
---|
| 2243 | self._alternate = gtk.Entry()
|
---|
| 2244 | self._alternate.set_width_chars(6)
|
---|
| 2245 | self._alternate.connect("changed", self._alternateChanged)
|
---|
| 2246 | self._alternate.set_tooltip_text(xstr("route_altn_tooltip"))
|
---|
| 2247 | label.set_mnemonic_widget(self._alternate)
|
---|
| 2248 |
|
---|
| 2249 | alternateBox.pack_start(self._alternate, False, False, 8)
|
---|
| 2250 |
|
---|
| 2251 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 2252 | xscale = 0.0, yscale = 0.0)
|
---|
| 2253 | alignment.add(alternateBox)
|
---|
| 2254 |
|
---|
| 2255 | mainBox.pack_start(alignment, False, False, 0)
|
---|
| 2256 |
|
---|
| 2257 | self.addCancelFlightButton()
|
---|
| 2258 |
|
---|
| 2259 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2260 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 2261 |
|
---|
| 2262 | @property
|
---|
| 2263 | def filedCruiseLevel(self):
|
---|
| 2264 | """Get the filed cruise level."""
|
---|
| 2265 | return self._cruiseLevel.get_value_as_int()
|
---|
| 2266 |
|
---|
| 2267 | @property
|
---|
| 2268 | def route(self):
|
---|
| 2269 | """Get the route."""
|
---|
| 2270 | return self._getRoute()
|
---|
| 2271 |
|
---|
| 2272 | @property
|
---|
| 2273 | def alternate(self):
|
---|
| 2274 | """Get the ICAO code of the alternate airport."""
|
---|
| 2275 | return self._alternate.get_text()
|
---|
| 2276 |
|
---|
| 2277 | def activate(self):
|
---|
| 2278 | """Setup the route from the booked flight."""
|
---|
| 2279 | self._cruiseLevel.set_value(0)
|
---|
| 2280 | self._cruiseLevel.set_text("")
|
---|
| 2281 | self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
|
---|
[692] | 2282 | self._alternate.set_text("")
|
---|
[687] | 2283 | self._updateForwardButton()
|
---|
| 2284 |
|
---|
| 2285 | def _getRoute(self):
|
---|
| 2286 | """Get the text of the route."""
|
---|
| 2287 | buffer = self._route.get_buffer()
|
---|
| 2288 | return buffer.get_text(buffer.get_start_iter(),
|
---|
| 2289 | buffer.get_end_iter(), True)
|
---|
| 2290 |
|
---|
| 2291 | def _updateForwardButton(self):
|
---|
| 2292 | """Update the sensitivity of the forward button."""
|
---|
| 2293 | cruiseLevelText = self._cruiseLevel.get_text()
|
---|
| 2294 | cruiseLevel = int(cruiseLevelText) if cruiseLevelText else 0
|
---|
| 2295 | alternate = self._alternate.get_text()
|
---|
| 2296 | self._button.set_sensitive(cruiseLevel>=50 and self._getRoute()!="" and
|
---|
[769] | 2297 | (len(alternate)==4 or self._wizard.entranceExam))
|
---|
[687] | 2298 |
|
---|
| 2299 | def _cruiseLevelChanged(self, *arg):
|
---|
| 2300 | """Called when the cruise level has changed."""
|
---|
| 2301 | self._updateForwardButton()
|
---|
| 2302 |
|
---|
| 2303 | def _routeChanged(self, textBuffer):
|
---|
| 2304 | """Called when the route has changed."""
|
---|
| 2305 | if not self._uppercasingRoute:
|
---|
| 2306 | self._updateForwardButton()
|
---|
| 2307 |
|
---|
| 2308 | def _routeInserted(self, textBuffer, iter, text, length):
|
---|
| 2309 | """Called when new characters are inserted into the route.
|
---|
| 2310 |
|
---|
| 2311 | It uppercases all characters."""
|
---|
| 2312 | if not self._uppercasingRoute:
|
---|
| 2313 | self._uppercasingRoute = True
|
---|
| 2314 |
|
---|
| 2315 | iter1 = iter.copy()
|
---|
| 2316 | iter1.backward_chars(length)
|
---|
| 2317 | textBuffer.delete(iter, iter1)
|
---|
| 2318 |
|
---|
| 2319 | textBuffer.insert(iter, text.upper())
|
---|
| 2320 |
|
---|
| 2321 | self._uppercasingRoute = False
|
---|
| 2322 |
|
---|
| 2323 | def _alternateChanged(self, entry):
|
---|
| 2324 | """Called when the alternate airport has changed."""
|
---|
| 2325 | entry.set_text(entry.get_text().upper())
|
---|
| 2326 | self._updateForwardButton()
|
---|
| 2327 |
|
---|
| 2328 | def _backClicked(self, button):
|
---|
| 2329 | """Called when the Back button is pressed."""
|
---|
| 2330 | self.goBack()
|
---|
| 2331 |
|
---|
| 2332 | def _forwardClicked(self, button):
|
---|
| 2333 | """Called when the Forward button is clicked."""
|
---|
[710] | 2334 | if self._wizard.gui.flight.aircraft.simBriefData is None:
|
---|
| 2335 | self._wizard.usingSimBrief = False
|
---|
[692] | 2336 | if self._wizard.gui.config.useSimBrief and \
|
---|
| 2337 | self._wizard.usingSimBrief is not False:
|
---|
[754] | 2338 | self._wizard.jumpPage("simbrief_setup")
|
---|
[687] | 2339 | else:
|
---|
[719] | 2340 | self._wizard.usingSimBrief = False
|
---|
[754] | 2341 | self._wizard.jumpPage("fuel")
|
---|
[687] | 2342 |
|
---|
| 2343 | #-----------------------------------------------------------------------------
|
---|
| 2344 |
|
---|
[700] | 2345 | class SimBriefCredentialsDialog(gtk.Dialog):
|
---|
| 2346 | """A dialog window to ask for SimBrief credentials."""
|
---|
| 2347 | def __init__(self, gui, userName, password, rememberPassword):
|
---|
| 2348 | """Construct the dialog."""
|
---|
| 2349 | super(SimBriefCredentialsDialog, self).__init__(WINDOW_TITLE_BASE + " - " +
|
---|
| 2350 | xstr("simbrief_credentials_title"),
|
---|
| 2351 | gui.mainWindow,
|
---|
| 2352 | DIALOG_MODAL)
|
---|
| 2353 | self.add_button(xstr("button_cancel"), RESPONSETYPE_CANCEL)
|
---|
| 2354 | self.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 2355 |
|
---|
| 2356 | contentArea = self.get_content_area()
|
---|
| 2357 |
|
---|
| 2358 | contentAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2359 | xscale = 0.0, yscale = 0.0)
|
---|
| 2360 | contentAlignment.set_padding(padding_top = 4, padding_bottom = 16,
|
---|
| 2361 | padding_left = 8, padding_right = 8)
|
---|
| 2362 |
|
---|
| 2363 | contentArea.pack_start(contentAlignment, False, False, 0)
|
---|
| 2364 |
|
---|
| 2365 | contentVBox = gtk.VBox()
|
---|
| 2366 | contentAlignment.add(contentVBox)
|
---|
| 2367 |
|
---|
| 2368 | label = gtk.Label(xstr("simbrief_login_failed"))
|
---|
| 2369 | label.set_alignment(0.0, 0.0)
|
---|
| 2370 |
|
---|
| 2371 | contentVBox.pack_start(label, False, False, 0)
|
---|
| 2372 |
|
---|
| 2373 | tableAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2374 | xscale = 0.0, yscale = 0.0)
|
---|
| 2375 | tableAlignment.set_padding(padding_top = 24, padding_bottom = 0,
|
---|
| 2376 | padding_left = 0, padding_right = 0)
|
---|
| 2377 |
|
---|
| 2378 | table = gtk.Table(3, 2)
|
---|
| 2379 | table.set_row_spacings(4)
|
---|
| 2380 | table.set_col_spacings(16)
|
---|
| 2381 | table.set_homogeneous(False)
|
---|
| 2382 |
|
---|
| 2383 | tableAlignment.add(table)
|
---|
| 2384 | contentVBox.pack_start(tableAlignment, True, True, 0)
|
---|
| 2385 |
|
---|
| 2386 | label = gtk.Label(xstr("simbrief_username"))
|
---|
| 2387 | label.set_use_underline(True)
|
---|
| 2388 | label.set_alignment(0.0, 0.5)
|
---|
| 2389 | table.attach(label, 0, 1, 0, 1)
|
---|
| 2390 |
|
---|
| 2391 | self._userName = gtk.Entry()
|
---|
| 2392 | self._userName.set_width_chars(16)
|
---|
| 2393 | #self._userName.connect("changed",
|
---|
| 2394 | # lambda button: self._updateForwardButton())
|
---|
| 2395 | self._userName.set_tooltip_text(xstr("simbrief_username_tooltip"))
|
---|
| 2396 | self._userName.set_text(userName)
|
---|
| 2397 | table.attach(self._userName, 1, 2, 0, 1)
|
---|
| 2398 | label.set_mnemonic_widget(self._userName)
|
---|
| 2399 |
|
---|
| 2400 | label = gtk.Label(xstr("simbrief_password"))
|
---|
| 2401 | label.set_use_underline(True)
|
---|
| 2402 | label.set_alignment(0.0, 0.5)
|
---|
| 2403 | table.attach(label, 0, 1, 1, 2)
|
---|
| 2404 |
|
---|
| 2405 | self._password = gtk.Entry()
|
---|
| 2406 | self._password.set_visibility(False)
|
---|
| 2407 | #self._password.connect("changed",
|
---|
| 2408 | # lambda button: self._updateForwardButton())
|
---|
| 2409 | self._password.set_tooltip_text(xstr("simbrief_password_tooltip"))
|
---|
| 2410 | self._password.set_text(password)
|
---|
| 2411 | table.attach(self._password, 1, 2, 1, 2)
|
---|
| 2412 | label.set_mnemonic_widget(self._password)
|
---|
| 2413 |
|
---|
| 2414 | self._rememberButton = gtk.CheckButton(xstr("simbrief_remember_password"))
|
---|
| 2415 | self._rememberButton.set_use_underline(True)
|
---|
| 2416 | self._rememberButton.set_tooltip_text(xstr("simbrief_remember_tooltip"))
|
---|
| 2417 | self._rememberButton.set_active(rememberPassword)
|
---|
| 2418 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
| 2419 |
|
---|
| 2420 | @property
|
---|
| 2421 | def userName(self):
|
---|
| 2422 | """Get the user name entered."""
|
---|
| 2423 | return self._userName.get_text()
|
---|
| 2424 |
|
---|
| 2425 | @property
|
---|
| 2426 | def password(self):
|
---|
| 2427 | """Get the password entered."""
|
---|
| 2428 | return self._password.get_text()
|
---|
| 2429 |
|
---|
| 2430 | @property
|
---|
| 2431 | def rememberPassword(self):
|
---|
| 2432 | """Get whether the password is to be remembered."""
|
---|
| 2433 | return self._rememberButton.get_active()
|
---|
| 2434 |
|
---|
| 2435 | def run(self):
|
---|
| 2436 | """Run the dialog."""
|
---|
| 2437 | self.show_all()
|
---|
| 2438 |
|
---|
| 2439 | response = super(SimBriefCredentialsDialog, self).run()
|
---|
| 2440 |
|
---|
| 2441 | self.hide()
|
---|
| 2442 |
|
---|
| 2443 | return response
|
---|
| 2444 |
|
---|
| 2445 | #-----------------------------------------------------------------------------
|
---|
| 2446 |
|
---|
[687] | 2447 | class SimBriefSetupPage(Page):
|
---|
| 2448 | """Page for setting up some parameters for SimBrief."""
|
---|
| 2449 | monthNum2Name = [
|
---|
| 2450 | "JAN",
|
---|
| 2451 | "FEB",
|
---|
| 2452 | "MAR",
|
---|
| 2453 | "APR",
|
---|
| 2454 | "MAY",
|
---|
| 2455 | "JUN",
|
---|
| 2456 | "JUL",
|
---|
| 2457 | "AUG",
|
---|
| 2458 | "SEP",
|
---|
| 2459 | "OCT",
|
---|
| 2460 | "NOV",
|
---|
| 2461 | "DEC"
|
---|
| 2462 | ]
|
---|
| 2463 |
|
---|
[692] | 2464 | progress2Message = {
|
---|
| 2465 | cef.SIMBRIEF_PROGRESS_SEARCHING_BROWSER: "simbrief_progress_searching_browser",
|
---|
| 2466 | cef.SIMBRIEF_PROGRESS_LOADING_FORM: "simbrief_progress_loading_form",
|
---|
| 2467 | cef.SIMBRIEF_PROGRESS_FILLING_FORM: "simbrief_progress_filling_form",
|
---|
| 2468 | cef.SIMBRIEF_PROGRESS_WAITING_LOGIN: "simbrief_progress_waiting_login",
|
---|
| 2469 | cef.SIMBRIEF_PROGRESS_LOGGING_IN: "simbrief_progress_logging_in",
|
---|
| 2470 | cef.SIMBRIEF_PROGRESS_WAITING_RESULT: "simbrief_progress_waiting_result",
|
---|
| 2471 | cef.SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING: "simbrief_progress_retrieving_briefing"
|
---|
| 2472 | }
|
---|
| 2473 |
|
---|
| 2474 | result2Message = {
|
---|
| 2475 | cef.SIMBRIEF_RESULT_ERROR_OTHER: "simbrief_result_error_other",
|
---|
| 2476 | cef.SIMBRIEF_RESULT_ERROR_NO_FORM: "simbrief_result_error_no_form",
|
---|
| 2477 | cef.SIMBRIEF_RESULT_ERROR_NO_POPUP: "simbrief_result_error_no_popup",
|
---|
| 2478 | cef.SIMBRIEF_RESULT_ERROR_LOGIN_FAILED: "simbrief_result_error_login_failed"
|
---|
| 2479 | }
|
---|
| 2480 |
|
---|
[687] | 2481 | @staticmethod
|
---|
| 2482 | def getHTMLFilePath():
|
---|
| 2483 | """Get the path of the HTML file to contain the generated flight
|
---|
| 2484 | plan."""
|
---|
| 2485 | if os.name=="nt":
|
---|
| 2486 | return os.path.join(tempfile.gettempdir(),
|
---|
| 2487 | "mlx_simbrief" +
|
---|
| 2488 | (".secondary" if secondaryInstallation else "") +
|
---|
| 2489 | ".html")
|
---|
| 2490 | else:
|
---|
| 2491 | import pwd
|
---|
| 2492 | return os.path.join(tempfile.gettempdir(),
|
---|
| 2493 | "mlx_simbrief." + pwd.getpwuid(os.getuid())[0] + "" +
|
---|
| 2494 | (".secondary" if secondaryInstallation else "") +
|
---|
| 2495 | ".html")
|
---|
| 2496 |
|
---|
| 2497 | def __init__(self, wizard):
|
---|
| 2498 | """Construct the setup page."""
|
---|
| 2499 |
|
---|
[754] | 2500 | super(SimBriefSetupPage, self).__init__(wizard, "simbrief_setup",
|
---|
[691] | 2501 | xstr("simbrief_setup_title"),
|
---|
| 2502 | xstr("simbrief_setup_help"),
|
---|
| 2503 | xstr("simbrief_setup_chelp"))
|
---|
[687] | 2504 |
|
---|
| 2505 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2506 | xscale = 0.0, yscale = 0.0)
|
---|
| 2507 |
|
---|
[711] | 2508 | table = gtk.Table(9, 3)
|
---|
[687] | 2509 | table.set_row_spacings(4)
|
---|
| 2510 | table.set_col_spacings(16)
|
---|
| 2511 | table.set_homogeneous(False)
|
---|
| 2512 | alignment.add(table)
|
---|
| 2513 | self.setMainWidget(alignment)
|
---|
| 2514 |
|
---|
[691] | 2515 | label = gtk.Label(xstr("simbrief_username"))
|
---|
[687] | 2516 | label.set_use_underline(True)
|
---|
| 2517 | label.set_alignment(0.0, 0.5)
|
---|
| 2518 | table.attach(label, 0, 1, 0, 1)
|
---|
| 2519 |
|
---|
| 2520 | self._userName = gtk.Entry()
|
---|
| 2521 | self._userName.set_width_chars(16)
|
---|
| 2522 | self._userName.connect("changed",
|
---|
| 2523 | lambda button: self._updateForwardButton())
|
---|
[691] | 2524 | self._userName.set_tooltip_text(xstr("simbrief_username_tooltip"))
|
---|
[687] | 2525 | table.attach(self._userName, 1, 2, 0, 1)
|
---|
| 2526 | label.set_mnemonic_widget(self._userName)
|
---|
| 2527 |
|
---|
[691] | 2528 | label = gtk.Label(xstr("simbrief_password"))
|
---|
[687] | 2529 | label.set_use_underline(True)
|
---|
| 2530 | label.set_alignment(0.0, 0.5)
|
---|
| 2531 | table.attach(label, 0, 1, 1, 2)
|
---|
| 2532 |
|
---|
| 2533 | self._password = gtk.Entry()
|
---|
| 2534 | self._password.set_visibility(False)
|
---|
| 2535 | self._password.connect("changed",
|
---|
| 2536 | lambda button: self._updateForwardButton())
|
---|
[691] | 2537 | self._password.set_tooltip_text(xstr("simbrief_password_tooltip"))
|
---|
[687] | 2538 | table.attach(self._password, 1, 2, 1, 2)
|
---|
| 2539 | label.set_mnemonic_widget(self._password)
|
---|
| 2540 |
|
---|
[690] | 2541 | self._rememberButton = gtk.CheckButton(xstr("simbrief_remember_password"))
|
---|
| 2542 | self._rememberButton.set_use_underline(True)
|
---|
| 2543 | self._rememberButton.set_tooltip_text(xstr("simbrief_remember_tooltip"))
|
---|
| 2544 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
| 2545 |
|
---|
[707] | 2546 | label = gtk.Label(xstr("simbrief_extra_fuel"))
|
---|
| 2547 | label.set_use_underline(True)
|
---|
| 2548 | label.set_alignment(0.0, 0.5)
|
---|
| 2549 | table.attach(label, 0, 1, 3, 4)
|
---|
| 2550 |
|
---|
| 2551 | self._extraFuel = IntegerEntry(defaultValue = 0)
|
---|
| 2552 | self._extraFuel.set_width_chars(6)
|
---|
| 2553 | self._extraFuel.set_tooltip_text(xstr("simbrief_extra_fuel_tooltip"))
|
---|
| 2554 | table.attach(self._extraFuel, 1, 2, 3, 4)
|
---|
| 2555 | label.set_mnemonic_widget(self._extraFuel)
|
---|
| 2556 |
|
---|
| 2557 | table.attach(gtk.Label("kg"), 2, 3, 3, 4)
|
---|
| 2558 |
|
---|
[708] | 2559 | label = gtk.Label(xstr("simbrief_takeoff_runway"))
|
---|
| 2560 | label.set_use_underline(True)
|
---|
| 2561 | label.set_alignment(0.0, 0.5)
|
---|
| 2562 | table.attach(label, 0, 1, 4, 5)
|
---|
| 2563 |
|
---|
| 2564 | self._takeoffRunway = gtk.Entry()
|
---|
| 2565 | self._takeoffRunway.set_width_chars(10)
|
---|
| 2566 | self._takeoffRunway.set_tooltip_text(xstr("simbrief_takeoff_runway_tooltip"))
|
---|
| 2567 | self._takeoffRunway.connect("changed", self._upperChanged)
|
---|
| 2568 | table.attach(self._takeoffRunway, 1, 2, 4, 5)
|
---|
| 2569 | label.set_mnemonic_widget(self._takeoffRunway)
|
---|
| 2570 |
|
---|
| 2571 | label = gtk.Label(xstr("simbrief_landing_runway"))
|
---|
| 2572 | label.set_use_underline(True)
|
---|
| 2573 | label.set_alignment(0.0, 0.5)
|
---|
| 2574 | table.attach(label, 0, 1, 5, 6)
|
---|
| 2575 |
|
---|
| 2576 | self._landingRunway = gtk.Entry()
|
---|
| 2577 | self._landingRunway.set_width_chars(10)
|
---|
| 2578 | self._landingRunway.set_tooltip_text(xstr("simbrief_takeoff_runway_tooltip"))
|
---|
| 2579 | self._landingRunway.connect("changed", self._upperChanged)
|
---|
| 2580 | table.attach(self._landingRunway, 1, 2, 5, 6)
|
---|
| 2581 | label.set_mnemonic_widget(self._landingRunway)
|
---|
| 2582 |
|
---|
[711] | 2583 | label = gtk.Label(xstr("simbrief_climb_profile"))
|
---|
| 2584 | label.set_use_underline(True)
|
---|
| 2585 | label.set_alignment(0.0, 0.5)
|
---|
| 2586 | table.attach(label, 0, 1, 6, 7)
|
---|
| 2587 |
|
---|
| 2588 | self._climbProfile = gtk.ComboBox()
|
---|
| 2589 | renderer = gtk.CellRendererText()
|
---|
| 2590 | self._climbProfile.pack_start(renderer, True)
|
---|
| 2591 | self._climbProfile.add_attribute(renderer, "text", 0)
|
---|
| 2592 | self._climbProfile.set_tooltip_text(xstr("simbrief_climb_profile_tooltip"))
|
---|
| 2593 | table.attach(self._climbProfile, 1, 2, 6, 7)
|
---|
| 2594 | label.set_mnemonic_widget(self._climbProfile)
|
---|
| 2595 |
|
---|
| 2596 | label = gtk.Label(xstr("simbrief_cruise_profile"))
|
---|
| 2597 | label.set_use_underline(True)
|
---|
| 2598 | label.set_alignment(0.0, 0.5)
|
---|
| 2599 | table.attach(label, 0, 1, 7, 8)
|
---|
| 2600 |
|
---|
| 2601 | self._cruiseProfile = gtk.ComboBox()
|
---|
| 2602 | renderer = gtk.CellRendererText()
|
---|
| 2603 | self._cruiseProfile.pack_start(renderer, True)
|
---|
| 2604 | self._cruiseProfile.add_attribute(renderer, "text", 0)
|
---|
| 2605 | self._cruiseProfile.set_tooltip_text(xstr("simbrief_cruise_profile_tooltip"))
|
---|
| 2606 | table.attach(self._cruiseProfile, 1, 2, 7, 8)
|
---|
| 2607 | label.set_mnemonic_widget(self._cruiseProfile)
|
---|
| 2608 |
|
---|
| 2609 | label = gtk.Label(xstr("simbrief_descent_profile"))
|
---|
| 2610 | label.set_use_underline(True)
|
---|
| 2611 | label.set_alignment(0.0, 0.5)
|
---|
| 2612 | table.attach(label, 0, 1, 8, 9)
|
---|
| 2613 |
|
---|
| 2614 | self._descentProfile = gtk.ComboBox()
|
---|
| 2615 | renderer = gtk.CellRendererText()
|
---|
| 2616 | self._descentProfile.pack_start(renderer, True)
|
---|
| 2617 | self._descentProfile.add_attribute(renderer, "text", 0)
|
---|
| 2618 | self._descentProfile.set_tooltip_text(xstr("simbrief_descent_profile_tooltip"))
|
---|
| 2619 | table.attach(self._descentProfile, 1, 2, 8, 9)
|
---|
| 2620 | label.set_mnemonic_widget(self._descentProfile)
|
---|
| 2621 |
|
---|
[687] | 2622 | self.addCancelFlightButton()
|
---|
| 2623 |
|
---|
| 2624 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2625 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 2626 |
|
---|
| 2627 | def activate(self):
|
---|
| 2628 | """Activate the SimBrief setup page"""
|
---|
[690] | 2629 | config = self._wizard.gui.config
|
---|
| 2630 |
|
---|
| 2631 | self._userName.set_text(config.simBriefUserName)
|
---|
[704] | 2632 | self._userName.set_sensitive(True)
|
---|
| 2633 |
|
---|
[690] | 2634 | self._password.set_text(config.simBriefPassword)
|
---|
[704] | 2635 | self._password.set_sensitive(True)
|
---|
| 2636 |
|
---|
[690] | 2637 | self._rememberButton.set_active(config.rememberSimBriefPassword)
|
---|
[704] | 2638 | self._rememberButton.set_sensitive(True)
|
---|
[690] | 2639 |
|
---|
[707] | 2640 | self._extraFuel.set_int(0)
|
---|
| 2641 | self._extraFuel.set_sensitive(True)
|
---|
| 2642 |
|
---|
[708] | 2643 | self._takeoffRunway.set_text("")
|
---|
| 2644 | self._takeoffRunway.set_sensitive(True)
|
---|
| 2645 |
|
---|
| 2646 | self._landingRunway.set_text("")
|
---|
| 2647 | self._landingRunway.set_sensitive(True)
|
---|
| 2648 |
|
---|
[711] | 2649 | simBriefData = self._wizard.gui.flight.aircraft.simBriefData
|
---|
| 2650 | for (control, profiles) in [(self._climbProfile,
|
---|
| 2651 | simBriefData.climbProfiles),
|
---|
| 2652 | (self._cruiseProfile,
|
---|
| 2653 | simBriefData.cruiseProfiles),
|
---|
| 2654 | (self._descentProfile,
|
---|
| 2655 | simBriefData.descentProfiles)]:
|
---|
| 2656 | model = gtk.ListStore(str)
|
---|
| 2657 | for profile in profiles:
|
---|
| 2658 | model.append([profile])
|
---|
| 2659 | control.set_model(model)
|
---|
| 2660 | control.set_sensitive(True)
|
---|
| 2661 |
|
---|
| 2662 | self._climbProfile.set_active(0)
|
---|
| 2663 | self._cruiseProfile.set_active(0)
|
---|
| 2664 | self._descentProfile.set_active(0)
|
---|
| 2665 |
|
---|
[687] | 2666 | self._updateForwardButton()
|
---|
| 2667 |
|
---|
| 2668 | def _updateForwardButton(self):
|
---|
| 2669 | """Update the sensitivity of the forward button."""
|
---|
| 2670 | self._button.set_sensitive(len(self._userName.get_text())>0 and
|
---|
| 2671 | len(self._password.get_text())>0)
|
---|
| 2672 |
|
---|
| 2673 | def _backClicked(self, button):
|
---|
| 2674 | """Called when the Back button is pressed."""
|
---|
| 2675 | self.goBack()
|
---|
| 2676 |
|
---|
| 2677 | def _forwardClicked(self, button):
|
---|
| 2678 | if self._completed:
|
---|
| 2679 | self._wizard.nextPage()
|
---|
| 2680 | else:
|
---|
[690] | 2681 | config = self._wizard.gui.config
|
---|
| 2682 |
|
---|
| 2683 | config.simBriefUserName = self._userName.get_text()
|
---|
| 2684 |
|
---|
| 2685 | rememberPassword = self._rememberButton.get_active()
|
---|
| 2686 | config.simBriefPassword = \
|
---|
| 2687 | self._password.get_text() if rememberPassword else ""
|
---|
| 2688 | config.rememberSimBriefPassword = rememberPassword
|
---|
| 2689 |
|
---|
| 2690 | config.save()
|
---|
| 2691 |
|
---|
[687] | 2692 | plan = self._getPlan()
|
---|
| 2693 | print "plan:", plan
|
---|
| 2694 |
|
---|
[717] | 2695 | takeoffRunway = self._takeoffRunway.get_text()
|
---|
| 2696 | if takeoffRunway:
|
---|
| 2697 | self._wizard.takeoffRunway = takeoffRunway
|
---|
| 2698 |
|
---|
| 2699 | landingRunway = self._landingRunway.get_text()
|
---|
| 2700 | if landingRunway:
|
---|
| 2701 | self._wizard.landingRunway = landingRunway
|
---|
| 2702 |
|
---|
[704] | 2703 | self._userName.set_sensitive(False)
|
---|
| 2704 | self._password.set_sensitive(False)
|
---|
| 2705 | self._rememberButton.set_sensitive(False)
|
---|
[707] | 2706 | self._extraFuel.set_sensitive(False)
|
---|
[708] | 2707 | self._takeoffRunway.set_sensitive(False)
|
---|
| 2708 | self._landingRunway.set_sensitive(False)
|
---|
[704] | 2709 |
|
---|
[711] | 2710 | self._climbProfile.set_sensitive(False)
|
---|
| 2711 | self._cruiseProfile.set_sensitive(False)
|
---|
| 2712 | self._descentProfile.set_sensitive(False)
|
---|
| 2713 |
|
---|
[714] | 2714 | self._wizard.gui.beginBusy(xstr("simbrief_calling"))
|
---|
[687] | 2715 |
|
---|
| 2716 | cef.callSimBrief(plan,
|
---|
[805] | 2717 | self._getCredentials,
|
---|
| 2718 | self._simBriefProgress,
|
---|
[687] | 2719 | SimBriefSetupPage.getHTMLFilePath())
|
---|
| 2720 |
|
---|
| 2721 | startSound(const.SOUND_NOTAM)
|
---|
| 2722 |
|
---|
[700] | 2723 | def _getCredentials(self, count):
|
---|
| 2724 | """Get the credentials.
|
---|
| 2725 |
|
---|
| 2726 | If count is 0, the user name and password entered into the setup page
|
---|
| 2727 | are returned. Otherwise a dialog box is displayed informing the user of
|
---|
| 2728 | invalid credentials and requesting another set of them."""
|
---|
[805] | 2729 | print "_getCredentials", count
|
---|
| 2730 | if count==0:
|
---|
| 2731 | return (self._userName.get_text(), self._password.get_text())
|
---|
| 2732 | else:
|
---|
| 2733 | gui = self._wizard.gui
|
---|
| 2734 | config = gui.config
|
---|
| 2735 |
|
---|
| 2736 | dialog = SimBriefCredentialsDialog(gui,
|
---|
| 2737 | config.simBriefUserName,
|
---|
| 2738 | config.simBriefPassword,
|
---|
| 2739 | config.rememberSimBriefPassword)
|
---|
| 2740 | response = dialog.run()
|
---|
| 2741 |
|
---|
| 2742 | if response==RESPONSETYPE_OK:
|
---|
| 2743 | userName = dialog.userName
|
---|
| 2744 | self._userName.set_text(userName)
|
---|
| 2745 | password = dialog.password
|
---|
| 2746 | self._password.set_text(password)
|
---|
| 2747 | rememberPassword = dialog.rememberPassword
|
---|
| 2748 |
|
---|
| 2749 | config.simBriefUserName = userName
|
---|
| 2750 |
|
---|
| 2751 | config.simBriefPassword = \
|
---|
| 2752 | password if rememberPassword else ""
|
---|
| 2753 | config.rememberSimBriefPassword = rememberPassword
|
---|
| 2754 |
|
---|
| 2755 | config.save()
|
---|
| 2756 |
|
---|
| 2757 | return (userName, password)
|
---|
[700] | 2758 | else:
|
---|
[805] | 2759 | return (None, None)
|
---|
[692] | 2760 |
|
---|
| 2761 | def _simBriefProgress(self, progress, result, flightInfo):
|
---|
[687] | 2762 | """The real SimBrief progress handler."""
|
---|
[692] | 2763 | print "_simBriefProgress", progress, result, flightInfo
|
---|
| 2764 | if result==cef.SIMBRIEF_RESULT_NONE:
|
---|
| 2765 | message = SimBriefSetupPage.progress2Message.get(progress,
|
---|
| 2766 | "simbrief_progress_unknown")
|
---|
| 2767 | self._wizard.gui.updateBusyState(xstr(message))
|
---|
| 2768 | else:
|
---|
[687] | 2769 | self._wizard.gui.endBusy()
|
---|
[692] | 2770 |
|
---|
| 2771 | if result==cef.SIMBRIEF_RESULT_OK:
|
---|
[718] | 2772 | self._wizard.departureMETARChanged(flightInfo["orig_metar"],
|
---|
| 2773 | self)
|
---|
| 2774 | self._wizard.arrivalMETARChanged(flightInfo["dest_metar"], self)
|
---|
[692] | 2775 | self._wizard.nextPage()
|
---|
| 2776 | else:
|
---|
| 2777 | message = SimBriefSetupPage.result2Message.get(result,
|
---|
| 2778 | "simbrief_result_unknown")
|
---|
| 2779 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 2780 | type = MESSAGETYPE_ERROR,
|
---|
| 2781 | message_format =
|
---|
| 2782 | xstr(message) + "\n"+
|
---|
| 2783 | xstr("simbrief_cancelled"))
|
---|
| 2784 |
|
---|
| 2785 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 2786 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 2787 | secondary = xstr("flightsel_save_failed_sec")
|
---|
| 2788 | dialog.format_secondary_markup(secondary)
|
---|
| 2789 | dialog.run()
|
---|
| 2790 | dialog.hide()
|
---|
| 2791 |
|
---|
| 2792 | self._wizard.usingSimBrief = False
|
---|
[754] | 2793 | self._wizard.jumpPage("fuel", fromPageShift = 1)
|
---|
[687] | 2794 |
|
---|
| 2795 | def _getPlan(self):
|
---|
| 2796 | """Get the flight plan data for SimBrief."""
|
---|
| 2797 | plan = {
|
---|
| 2798 | "airline": "MAH",
|
---|
| 2799 | "selcal": "XXXX",
|
---|
| 2800 | "fuelfactor": "P000",
|
---|
| 2801 | "contpct": "0.05",
|
---|
| 2802 | "resvrule": "45",
|
---|
| 2803 | "taxiout": "10",
|
---|
| 2804 | "taxiin": "10",
|
---|
| 2805 | "civalue": "AUTO"
|
---|
| 2806 | }
|
---|
| 2807 |
|
---|
| 2808 | wizard = self._wizard
|
---|
| 2809 | gui = wizard.gui
|
---|
| 2810 |
|
---|
| 2811 | loginResult = wizard.loginResult
|
---|
| 2812 | plan["cpt"] = loginResult.pilotName
|
---|
| 2813 | plan["pid"] = loginResult.pilotID
|
---|
| 2814 |
|
---|
| 2815 | bookedFlight = wizard.bookedFlight
|
---|
| 2816 | plan["fltnum"] = wizard.bookedFlight.callsign[2:]
|
---|
| 2817 | plan["type"] = const.icaoCodes[bookedFlight.aircraftType]
|
---|
| 2818 | plan["orig"] = bookedFlight.departureICAO
|
---|
| 2819 | plan["dest"] = bookedFlight.arrivalICAO
|
---|
| 2820 | plan["reg"] = bookedFlight.tailNumber
|
---|
| 2821 | plan["fin"] = bookedFlight.tailNumber[3:]
|
---|
| 2822 | plan["pax"] = str(bookedFlight.numPassengers)
|
---|
| 2823 |
|
---|
| 2824 | departureTime = bookedFlight.departureTime
|
---|
| 2825 | plan["date"] = "%d%s%d" % (departureTime.day,
|
---|
| 2826 | SimBriefSetupPage.monthNum2Name[departureTime.month-1],
|
---|
| 2827 | departureTime.year%100)
|
---|
| 2828 | plan["deph"] = str(departureTime.hour)
|
---|
| 2829 | plan["depm"] = str(departureTime.minute)
|
---|
| 2830 |
|
---|
| 2831 | arrivalTime = bookedFlight.arrivalTime
|
---|
| 2832 | plan["steh"] = str(arrivalTime.hour)
|
---|
| 2833 | plan["stem"] = str(arrivalTime.minute)
|
---|
| 2834 |
|
---|
[705] | 2835 | plan["manualzfw"] = str(wizard.zfw / 1000.0)
|
---|
| 2836 | plan["cargo"] = str((wizard.bagWeight + wizard.cargoWeight + wizard.mailWeight)/1000.0)
|
---|
[687] | 2837 |
|
---|
| 2838 | plan["route"] = wizard.route
|
---|
| 2839 | plan["fl"] = str(wizard.filedCruiseAltitude)
|
---|
| 2840 | plan["altn"] = wizard.alternate
|
---|
| 2841 |
|
---|
[707] | 2842 | plan["addedfuel"] = str(self._extraFuel.get_int() / 1000.0)
|
---|
[708] | 2843 | plan["origrwy"] = self._takeoffRunway.get_text()
|
---|
| 2844 | plan["destrwy"] = self._landingRunway.get_text()
|
---|
[711] | 2845 |
|
---|
| 2846 | for (key, control) in [("climb", self._climbProfile),
|
---|
| 2847 | ("cruise", self._cruiseProfile),
|
---|
| 2848 | ("descent", self._descentProfile)]:
|
---|
| 2849 | model = control.get_model()
|
---|
| 2850 | active = control.get_active_iter()
|
---|
| 2851 | value = model.get_value(active, 0)
|
---|
| 2852 | plan[key] = value
|
---|
[687] | 2853 |
|
---|
| 2854 | return plan
|
---|
| 2855 |
|
---|
[708] | 2856 | def _upperChanged(self, entry, arg = None):
|
---|
| 2857 | """Called when the value of some entry widget has changed and the value
|
---|
| 2858 | should be converted to uppercase."""
|
---|
| 2859 | entry.set_text(entry.get_text().upper())
|
---|
| 2860 |
|
---|
[687] | 2861 | #-----------------------------------------------------------------------------
|
---|
| 2862 |
|
---|
| 2863 | class SimBriefingPage(Page):
|
---|
| 2864 | """Page to display the SimBrief HTML briefing."""
|
---|
[712] | 2865 | class BrowserLifeSpanHandler(object):
|
---|
| 2866 | """The life-span handler of a browser."""
|
---|
| 2867 | def __init__(self, simBriefingPage):
|
---|
| 2868 | """Construct the life-span handler for the given page."""
|
---|
| 2869 | self._simBriefingPage = simBriefingPage
|
---|
| 2870 |
|
---|
| 2871 | def OnBeforeClose(self, browser):
|
---|
| 2872 | """Called before closing the browser."""
|
---|
| 2873 | self._simBriefingPage._invalidateBrowser()
|
---|
| 2874 |
|
---|
[687] | 2875 | def __init__(self, wizard):
|
---|
| 2876 | """Construct the setup page."""
|
---|
| 2877 |
|
---|
[754] | 2878 | super(SimBriefingPage, self).__init__(wizard, "simbrief_result",
|
---|
[727] | 2879 | xstr("simbrief_result_title"), "")
|
---|
[687] | 2880 |
|
---|
| 2881 | self._alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2882 | xscale = 1.0, yscale = 1.0)
|
---|
| 2883 |
|
---|
[698] | 2884 | self._container = cef.getContainer()
|
---|
| 2885 | self._alignment.add(self._container)
|
---|
| 2886 |
|
---|
[687] | 2887 | self.setMainWidget(self._alignment)
|
---|
| 2888 |
|
---|
[698] | 2889 | self._browser = None
|
---|
| 2890 |
|
---|
[687] | 2891 | self.addCancelFlightButton()
|
---|
| 2892 |
|
---|
| 2893 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2894 |
|
---|
| 2895 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 2896 | self._button.set_label(xstr("briefing_button"))
|
---|
| 2897 | self._button.set_has_tooltip(False)
|
---|
| 2898 | self._button.set_use_stock(False)
|
---|
| 2899 |
|
---|
| 2900 | def activate(self):
|
---|
| 2901 | """Activate the SimBrief flight plan page"""
|
---|
[698] | 2902 | if self._browser is None:
|
---|
[712] | 2903 | self._startBrowser()
|
---|
[698] | 2904 | else:
|
---|
| 2905 | self._browser.Reload()
|
---|
[687] | 2906 |
|
---|
[712] | 2907 | def grabDefault(self):
|
---|
| 2908 | """If the page has a default button, make it the default one."""
|
---|
| 2909 | super(SimBriefingPage, self).grabDefault()
|
---|
| 2910 |
|
---|
| 2911 | if self._browser is None:
|
---|
| 2912 | self._startBrowser()
|
---|
| 2913 |
|
---|
[687] | 2914 | def _backClicked(self, button):
|
---|
| 2915 | """Called when the Back button has been pressed."""
|
---|
| 2916 | self.goBack()
|
---|
| 2917 |
|
---|
| 2918 | def _forwardClicked(self, button):
|
---|
| 2919 | """Called when the Forward button has been pressed."""
|
---|
| 2920 | if not self._completed:
|
---|
| 2921 | self._button.set_label(xstr("button_next"))
|
---|
| 2922 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
| 2923 | self._wizard.usingSimBrief = True
|
---|
| 2924 | self.complete()
|
---|
| 2925 |
|
---|
| 2926 | self._wizard.nextPage()
|
---|
| 2927 |
|
---|
[712] | 2928 | def _startBrowser(self):
|
---|
| 2929 | """Start the browser.
|
---|
| 2930 |
|
---|
| 2931 | If a container is needed, create one."""
|
---|
| 2932 | if self._container is None:
|
---|
| 2933 | self._container = cef.getContainer()
|
---|
| 2934 | self._alignment.add(self._container)
|
---|
| 2935 |
|
---|
| 2936 | url = "file://" + SimBriefSetupPage.getHTMLFilePath()
|
---|
| 2937 | self._browser = cef.startInContainer(self._container, url)
|
---|
| 2938 |
|
---|
| 2939 | lifeSpanHandler = SimBriefingPage.BrowserLifeSpanHandler(self)
|
---|
| 2940 | self._browser.SetClientHandler(lifeSpanHandler)
|
---|
| 2941 |
|
---|
| 2942 | def _invalidateBrowser(self):
|
---|
| 2943 | """Invalidate the browser (and associated stuff)."""
|
---|
| 2944 | self._alignment.remove(self._container)
|
---|
| 2945 | self._container = None
|
---|
| 2946 | self._browser = None
|
---|
| 2947 |
|
---|
[687] | 2948 | #-----------------------------------------------------------------------------
|
---|
| 2949 |
|
---|
[141] | 2950 | class FuelTank(gtk.VBox):
|
---|
| 2951 | """Widget for the fuel tank."""
|
---|
| 2952 | def __init__(self, fuelTank, name, capacity, currentWeight):
|
---|
| 2953 | """Construct the widget for the tank with the given name."""
|
---|
| 2954 | super(FuelTank, self).__init__()
|
---|
| 2955 |
|
---|
[146] | 2956 | self._enabled = True
|
---|
[141] | 2957 | self.fuelTank = fuelTank
|
---|
| 2958 | self.capacity = capacity
|
---|
| 2959 | self.currentWeight = currentWeight
|
---|
| 2960 | self.expectedWeight = currentWeight
|
---|
| 2961 |
|
---|
| 2962 | label = gtk.Label("<b>" + name + "</b>")
|
---|
| 2963 | label.set_use_markup(True)
|
---|
[145] | 2964 | label.set_use_underline(True)
|
---|
[141] | 2965 | label.set_justify(JUSTIFY_CENTER)
|
---|
| 2966 | label.set_alignment(0.5, 1.0)
|
---|
| 2967 | self.pack_start(label, False, False, 4)
|
---|
| 2968 |
|
---|
[142] | 2969 | self._tankFigure = gtk.EventBox()
|
---|
[141] | 2970 | self._tankFigure.set_size_request(38, -1)
|
---|
[142] | 2971 | self._tankFigure.set_visible_window(False)
|
---|
[144] | 2972 | self._tankFigure.set_tooltip_markup(xstr("fuel_tank_tooltip"))
|
---|
[141] | 2973 |
|
---|
| 2974 | if pygobject:
|
---|
| 2975 | self._tankFigure.connect("draw", self._drawTankFigure)
|
---|
| 2976 | else:
|
---|
| 2977 | self._tankFigure.connect("expose_event", self._drawTankFigure)
|
---|
[144] | 2978 | self._tankFigure.connect("button_press_event", self._buttonPressed)
|
---|
| 2979 | self._tankFigure.connect("motion_notify_event", self._motionNotify)
|
---|
| 2980 | self._tankFigure.connect("scroll-event", self._scrolled)
|
---|
[347] | 2981 |
|
---|
[141] | 2982 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2983 | xscale = 0.0, yscale = 1.0)
|
---|
[142] | 2984 | alignment.add(self._tankFigure)
|
---|
[141] | 2985 |
|
---|
| 2986 | self.pack_start(alignment, True, True, 4)
|
---|
| 2987 |
|
---|
| 2988 | self._expectedButton = gtk.SpinButton()
|
---|
| 2989 | self._expectedButton.set_numeric(True)
|
---|
| 2990 | self._expectedButton.set_range(0, self.capacity)
|
---|
| 2991 | self._expectedButton.set_increments(10, 100)
|
---|
| 2992 | self._expectedButton.set_value(currentWeight)
|
---|
| 2993 | self._expectedButton.set_alignment(1.0)
|
---|
| 2994 | self._expectedButton.set_width_chars(5)
|
---|
| 2995 | self._expectedButton.connect("value-changed", self._expectedChanged)
|
---|
| 2996 |
|
---|
[145] | 2997 | label.set_mnemonic_widget(self._expectedButton)
|
---|
| 2998 |
|
---|
[141] | 2999 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 3000 | xscale = 0.0, yscale = 1.0)
|
---|
[347] | 3001 | alignment.add(self._expectedButton)
|
---|
[141] | 3002 | self.pack_start(alignment, False, False, 4)
|
---|
| 3003 |
|
---|
| 3004 | def setCurrent(self, currentWeight):
|
---|
| 3005 | """Set the current weight."""
|
---|
| 3006 | self.currentWeight = currentWeight
|
---|
| 3007 | self._redraw()
|
---|
| 3008 |
|
---|
| 3009 | def isCorrect(self):
|
---|
| 3010 | """Determine if the contents of the fuel tank are as expected"""
|
---|
| 3011 | return abs(self.expectedWeight - self.currentWeight)<=1
|
---|
| 3012 |
|
---|
| 3013 | def disable(self):
|
---|
| 3014 | """Disable the fuel tank."""
|
---|
| 3015 | self._expectedButton.set_sensitive(False)
|
---|
[146] | 3016 | self._enabled = False
|
---|
[141] | 3017 |
|
---|
| 3018 | def _redraw(self):
|
---|
| 3019 | """Redraw the tank figure."""
|
---|
| 3020 | self._tankFigure.queue_draw()
|
---|
| 3021 |
|
---|
[142] | 3022 | def _drawTankFigure(self, tankFigure, eventOrContext):
|
---|
[141] | 3023 | """Draw the tank figure."""
|
---|
| 3024 | triangleSize = 5
|
---|
[142] | 3025 |
|
---|
| 3026 | context = eventOrContext if pygobject else tankFigure.window.cairo_create()
|
---|
| 3027 | (xOffset, yOffset) = (0, 0) if pygobject \
|
---|
| 3028 | else (tankFigure.allocation.x, tankFigure.allocation.y)
|
---|
[347] | 3029 |
|
---|
[142] | 3030 | width = tankFigure.get_allocated_width() if pygobject \
|
---|
| 3031 | else tankFigure.allocation.width
|
---|
| 3032 | height = tankFigure.get_allocated_height() if pygobject \
|
---|
| 3033 | else tankFigure.allocation.height
|
---|
[141] | 3034 |
|
---|
| 3035 | rectangleX0 = triangleSize
|
---|
| 3036 | rectangleY0 = triangleSize
|
---|
| 3037 | rectangleX1 = width - 1 - triangleSize
|
---|
| 3038 | rectangleY1 = height - 1 - triangleSize
|
---|
| 3039 | rectangleLineWidth = 2.0
|
---|
| 3040 |
|
---|
| 3041 | context.set_source_rgb(0.0, 0.0, 0.0)
|
---|
| 3042 | context.set_line_width(rectangleLineWidth)
|
---|
[142] | 3043 | context.rectangle(xOffset + rectangleX0 + rectangleLineWidth/2,
|
---|
| 3044 | yOffset + rectangleY0 + rectangleLineWidth/2,
|
---|
[141] | 3045 | rectangleX1 - rectangleX0 - rectangleLineWidth,
|
---|
| 3046 | rectangleY1 - rectangleY0 - rectangleLineWidth)
|
---|
| 3047 | context.stroke()
|
---|
| 3048 |
|
---|
| 3049 | rectangleInnerLeft = rectangleX0 + rectangleLineWidth
|
---|
| 3050 | rectangleInnerRight = rectangleX1 - rectangleLineWidth
|
---|
[144] | 3051 | self._rectangleInnerTop = rectangleInnerTop = rectangleY0 + rectangleLineWidth
|
---|
| 3052 | self._rectangleInnerBottom = rectangleInnerBottom = rectangleY1 - rectangleLineWidth
|
---|
[141] | 3053 |
|
---|
| 3054 | rectangleInnerWidth = rectangleInnerRight - rectangleInnerLeft
|
---|
| 3055 | rectangleInnerHeight = rectangleInnerBottom - rectangleInnerTop
|
---|
| 3056 |
|
---|
| 3057 | context.set_source_rgb(1.0, 0.9, 0.6)
|
---|
| 3058 | currentHeight = self.currentWeight * rectangleInnerHeight / self.capacity
|
---|
| 3059 | currentX = rectangleInnerTop + rectangleInnerHeight - currentHeight
|
---|
[142] | 3060 | context.rectangle(xOffset + rectangleInnerLeft,
|
---|
| 3061 | yOffset + rectangleInnerTop +
|
---|
| 3062 | rectangleInnerHeight - currentHeight,
|
---|
[141] | 3063 | rectangleInnerWidth, currentHeight)
|
---|
| 3064 | context.fill()
|
---|
| 3065 |
|
---|
| 3066 | expectedHeight = self.expectedWeight * rectangleInnerHeight / self.capacity
|
---|
| 3067 | expectedY = rectangleInnerTop + rectangleInnerHeight - expectedHeight
|
---|
| 3068 |
|
---|
| 3069 | context.set_line_width(1.5)
|
---|
| 3070 | context.set_source_rgb(0.0, 0.85, 0.85)
|
---|
[142] | 3071 | context.move_to(xOffset + rectangleX0, yOffset + expectedY)
|
---|
| 3072 | context.line_to(xOffset + rectangleX1, yOffset + expectedY)
|
---|
[141] | 3073 | context.stroke()
|
---|
| 3074 |
|
---|
| 3075 | context.set_line_width(0.0)
|
---|
[142] | 3076 | context.move_to(xOffset + 0, yOffset + expectedY - triangleSize)
|
---|
| 3077 | context.line_to(xOffset + 0, yOffset + expectedY + triangleSize)
|
---|
| 3078 | context.line_to(xOffset + rectangleX0 + 1, yOffset + expectedY)
|
---|
| 3079 | context.line_to(xOffset + 0, yOffset + expectedY - triangleSize)
|
---|
[141] | 3080 | context.fill()
|
---|
| 3081 |
|
---|
| 3082 | context.set_line_width(0.0)
|
---|
[142] | 3083 | context.move_to(xOffset + width, yOffset + expectedY - triangleSize)
|
---|
| 3084 | context.line_to(xOffset + width, yOffset + expectedY + triangleSize)
|
---|
| 3085 | context.line_to(xOffset + rectangleX1 - 1, yOffset + expectedY)
|
---|
| 3086 | context.line_to(xOffset + width, yOffset + expectedY - triangleSize)
|
---|
[141] | 3087 | context.fill()
|
---|
| 3088 |
|
---|
[142] | 3089 | return True
|
---|
| 3090 |
|
---|
[144] | 3091 | def _setExpectedFromY(self, y):
|
---|
| 3092 | """Set the expected weight from the given Y-coordinate."""
|
---|
| 3093 | level = (self._rectangleInnerBottom - y) / \
|
---|
| 3094 | (self._rectangleInnerBottom - self._rectangleInnerTop)
|
---|
| 3095 | level = min(1.0, max(0.0, level))
|
---|
| 3096 | self._expectedButton.set_value(level * self.capacity)
|
---|
[347] | 3097 |
|
---|
[144] | 3098 | def _buttonPressed(self, tankFigure, event):
|
---|
| 3099 | """Called when a button is pressed in the figure.
|
---|
| 3100 |
|
---|
| 3101 | The expected level will be set there."""
|
---|
[146] | 3102 | if self._enabled and event.button==1:
|
---|
[144] | 3103 | self._setExpectedFromY(event.y)
|
---|
[347] | 3104 |
|
---|
[144] | 3105 | def _motionNotify(self, tankFigure, event):
|
---|
| 3106 | """Called when the mouse pointer moves within the area of a tank figure."""
|
---|
[347] | 3107 | if self._enabled and event.state==BUTTON1_MASK:
|
---|
[144] | 3108 | self._setExpectedFromY(event.y)
|
---|
| 3109 |
|
---|
| 3110 | def _scrolled(self, tankFigure, event):
|
---|
| 3111 | """Called when a scroll event is received."""
|
---|
[146] | 3112 | if self._enabled:
|
---|
| 3113 | increment = 1 if event.state==CONTROL_MASK \
|
---|
| 3114 | else 100 if event.state==SHIFT_MASK \
|
---|
| 3115 | else 10 if event.state==0 else 0
|
---|
| 3116 | if increment!=0:
|
---|
| 3117 | if event.direction==SCROLL_DOWN:
|
---|
| 3118 | increment *= -1
|
---|
| 3119 | self._expectedButton.spin(SPIN_USER_DEFINED, increment)
|
---|
[347] | 3120 |
|
---|
[141] | 3121 | def _expectedChanged(self, spinButton):
|
---|
| 3122 | """Called when the expected value has changed."""
|
---|
| 3123 | self.expectedWeight = spinButton.get_value_as_int()
|
---|
[347] | 3124 | self._redraw()
|
---|
[141] | 3125 |
|
---|
| 3126 | #-----------------------------------------------------------------------------
|
---|
| 3127 |
|
---|
| 3128 | class FuelPage(Page):
|
---|
| 3129 | """The page containing the fuel tank filling."""
|
---|
| 3130 | _pumpStep = 0.02
|
---|
[347] | 3131 |
|
---|
[141] | 3132 | def __init__(self, wizard):
|
---|
| 3133 | """Construct the page."""
|
---|
[754] | 3134 | super(FuelPage, self).__init__(wizard, "fuel",
|
---|
| 3135 | xstr("fuel_title"),
|
---|
[592] | 3136 | xstr("fuel_help_pre") +
|
---|
| 3137 | xstr("fuel_help_post"),
|
---|
[141] | 3138 | completedHelp = xstr("fuel_chelp"))
|
---|
| 3139 |
|
---|
| 3140 | self._fuelTanks = []
|
---|
| 3141 | self._fuelTable = None
|
---|
| 3142 | self._fuelAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 3143 | xscale = 0.0, yscale = 1.0)
|
---|
| 3144 | self.setMainWidget(self._fuelAlignment)
|
---|
| 3145 |
|
---|
[274] | 3146 | tankData = [(tank, 2500, 3900) for tank in acft.mostFuelTanks]
|
---|
| 3147 | self._setupTanks(tankData)
|
---|
[141] | 3148 |
|
---|
[208] | 3149 | self.addCancelFlightButton()
|
---|
| 3150 |
|
---|
[141] | 3151 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 3152 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 3153 |
|
---|
| 3154 | self._pumpIndex = 0
|
---|
| 3155 |
|
---|
[145] | 3156 | def activate(self):
|
---|
| 3157 | """Activate the page."""
|
---|
[274] | 3158 | self._setupTanks(self._wizard._fuelData)
|
---|
[141] | 3159 |
|
---|
[592] | 3160 | aircraft = self._wizard.gui.flight.aircraft
|
---|
| 3161 | minLandingFuel = aircraft.minLandingFuel
|
---|
| 3162 | recommendedLandingFuel = aircraft.recommendedLandingFuel
|
---|
| 3163 |
|
---|
| 3164 | middleHelp = "" if minLandingFuel is None else \
|
---|
| 3165 | (xstr("fuel_help_min") % (minLandingFuel,)) \
|
---|
| 3166 | if recommendedLandingFuel is None else \
|
---|
| 3167 | (xstr("fuel_help_min_rec") % (minLandingFuel,
|
---|
| 3168 | recommendedLandingFuel))
|
---|
| 3169 | self.setHelp(xstr("fuel_help_pre") + middleHelp + xstr("fuel_help_post"))
|
---|
| 3170 |
|
---|
[141] | 3171 | def finalize(self):
|
---|
| 3172 | """Finalize the page."""
|
---|
| 3173 | for fuelTank in self._fuelTanks:
|
---|
| 3174 | fuelTank.disable()
|
---|
| 3175 |
|
---|
| 3176 | def _backClicked(self, button):
|
---|
| 3177 | """Called when the Back button is pressed."""
|
---|
| 3178 | self.goBack()
|
---|
[347] | 3179 |
|
---|
[141] | 3180 | def _forwardClicked(self, button):
|
---|
| 3181 | """Called when the forward button is clicked."""
|
---|
| 3182 | if not self._completed:
|
---|
| 3183 | self._pumpIndex = 0
|
---|
| 3184 | self._wizard.gui.beginBusy(xstr("fuel_pump_busy"))
|
---|
| 3185 | self._pump()
|
---|
[687] | 3186 | elif self._wizard.usingSimBrief:
|
---|
[754] | 3187 | self._wizard.jumpPage("takeoff")
|
---|
[141] | 3188 | else:
|
---|
[754] | 3189 | self._wizard.jumpPage("briefing1")
|
---|
[141] | 3190 |
|
---|
[274] | 3191 | def _setupTanks(self, tankData):
|
---|
[141] | 3192 | """Setup the tanks for the given data."""
|
---|
[274] | 3193 | numTanks = len(tankData)
|
---|
[141] | 3194 | if self._fuelTable is not None:
|
---|
| 3195 | self._fuelAlignment.remove(self._fuelTable)
|
---|
| 3196 |
|
---|
| 3197 | self._fuelTanks = []
|
---|
| 3198 | self._fuelTable = gtk.Table(numTanks, 1)
|
---|
| 3199 | self._fuelTable.set_col_spacings(16)
|
---|
[274] | 3200 | index = 0
|
---|
| 3201 | for (tank, current, capacity) in tankData:
|
---|
[141] | 3202 | fuelTank = FuelTank(tank,
|
---|
| 3203 | xstr("fuel_tank_" +
|
---|
| 3204 | const.fuelTank2string(tank)),
|
---|
| 3205 | capacity, current)
|
---|
[274] | 3206 | self._fuelTable.attach(fuelTank, index, index+1, 0, 1)
|
---|
[141] | 3207 | self._fuelTanks.append(fuelTank)
|
---|
[274] | 3208 | index += 1
|
---|
[347] | 3209 |
|
---|
[141] | 3210 | self._fuelAlignment.add(self._fuelTable)
|
---|
| 3211 | self.show_all()
|
---|
| 3212 |
|
---|
| 3213 | def _pump(self):
|
---|
| 3214 | """Perform one step of pumping.
|
---|
| 3215 |
|
---|
| 3216 | It is checked, if the current tank's contents are of the right
|
---|
| 3217 | quantity. If not, it is filled one step further to the desired
|
---|
| 3218 | contents. Otherwise the next tank is started. If all tanks are are
|
---|
| 3219 | filled, the next page is selected."""
|
---|
| 3220 | numTanks = len(self._fuelTanks)
|
---|
| 3221 |
|
---|
| 3222 | fuelTank = None
|
---|
| 3223 | while self._pumpIndex < numTanks:
|
---|
| 3224 | fuelTank = self._fuelTanks[self._pumpIndex]
|
---|
| 3225 | if fuelTank.isCorrect():
|
---|
| 3226 | self._pumpIndex += 1
|
---|
| 3227 | fuelTank = None
|
---|
| 3228 | else:
|
---|
| 3229 | break
|
---|
| 3230 |
|
---|
| 3231 | if fuelTank is None:
|
---|
| 3232 | self._wizard.gui.endBusy()
|
---|
[687] | 3233 | if self._wizard.usingSimBrief:
|
---|
| 3234 | self._wizard.gui.startMonitoring()
|
---|
[754] | 3235 | self._wizard.jumpPage("takeoff")
|
---|
[687] | 3236 | else:
|
---|
| 3237 | bookedFlight = self._wizard._bookedFlight
|
---|
| 3238 | self._wizard.gui.beginBusy(xstr("route_down_notams"))
|
---|
| 3239 | self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback,
|
---|
| 3240 | bookedFlight.departureICAO,
|
---|
| 3241 | bookedFlight.arrivalICAO)
|
---|
| 3242 | startSound(const.SOUND_NOTAM)
|
---|
[141] | 3243 | else:
|
---|
| 3244 | currentLevel = fuelTank.currentWeight / fuelTank.capacity
|
---|
| 3245 | expectedLevel = fuelTank.expectedWeight / fuelTank.capacity
|
---|
| 3246 | if currentLevel<expectedLevel:
|
---|
| 3247 | currentLevel += FuelPage._pumpStep
|
---|
| 3248 | if currentLevel>expectedLevel: currentLevel = expectedLevel
|
---|
| 3249 | else:
|
---|
| 3250 | currentLevel -= FuelPage._pumpStep
|
---|
| 3251 | if currentLevel<expectedLevel: currentLevel = expectedLevel
|
---|
| 3252 | fuelTank.setCurrent(currentLevel * fuelTank.capacity)
|
---|
| 3253 | self._wizard.gui.simulator.setFuelLevel([(fuelTank.fuelTank,
|
---|
| 3254 | currentLevel)])
|
---|
| 3255 | gobject.timeout_add(50, self._pump)
|
---|
[347] | 3256 |
|
---|
[64] | 3257 | def _notamsCallback(self, returned, result):
|
---|
| 3258 | """Callback for the NOTAMs."""
|
---|
| 3259 | gobject.idle_add(self._handleNOTAMs, returned, result)
|
---|
| 3260 |
|
---|
| 3261 | def _handleNOTAMs(self, returned, result):
|
---|
| 3262 | """Handle the NOTAMs."""
|
---|
| 3263 | if returned:
|
---|
| 3264 | self._wizard._departureNOTAMs = result.departureNOTAMs
|
---|
| 3265 | self._wizard._arrivalNOTAMs = result.arrivalNOTAMs
|
---|
[67] | 3266 | else:
|
---|
| 3267 | self._wizard._departureNOTAMs = None
|
---|
| 3268 | self._wizard._arrivalNOTAMs = None
|
---|
[64] | 3269 |
|
---|
[67] | 3270 | bookedFlight = self._wizard._bookedFlight
|
---|
[107] | 3271 | self._wizard.gui.beginBusy(xstr("route_down_metars"))
|
---|
[67] | 3272 | self._wizard.gui.webHandler.getMETARs(self._metarsCallback,
|
---|
| 3273 | [bookedFlight.departureICAO,
|
---|
| 3274 | bookedFlight.arrivalICAO])
|
---|
| 3275 |
|
---|
| 3276 | def _metarsCallback(self, returned, result):
|
---|
| 3277 | """Callback for the METARs."""
|
---|
| 3278 | gobject.idle_add(self._handleMETARs, returned, result)
|
---|
| 3279 |
|
---|
| 3280 | def _handleMETARs(self, returned, result):
|
---|
| 3281 | """Handle the METARs."""
|
---|
| 3282 | self._wizard._departureMETAR = None
|
---|
| 3283 | self._wizard._arrivalMETAR = None
|
---|
| 3284 | bookedFlight = self._wizard._bookedFlight
|
---|
| 3285 | if returned:
|
---|
| 3286 | if bookedFlight.departureICAO in result.metars:
|
---|
| 3287 | self._wizard._departureMETAR = result.metars[bookedFlight.departureICAO]
|
---|
| 3288 | if bookedFlight.arrivalICAO in result.metars:
|
---|
| 3289 | self._wizard._arrivalMETAR = result.metars[bookedFlight.arrivalICAO]
|
---|
| 3290 |
|
---|
| 3291 | self._wizard.gui.endBusy()
|
---|
[70] | 3292 | self._backButton.set_sensitive(True)
|
---|
| 3293 | self._button.set_sensitive(True)
|
---|
[62] | 3294 | self._wizard.nextPage()
|
---|
| 3295 |
|
---|
| 3296 | #-----------------------------------------------------------------------------
|
---|
| 3297 |
|
---|
[67] | 3298 | class BriefingPage(Page):
|
---|
| 3299 | """Page for the briefing."""
|
---|
| 3300 | def __init__(self, wizard, departure):
|
---|
| 3301 | """Construct the briefing page."""
|
---|
| 3302 | self._departure = departure
|
---|
[347] | 3303 |
|
---|
[754] | 3304 | number = 1 if departure else 2
|
---|
| 3305 |
|
---|
| 3306 | title = xstr("briefing_title") % (number,
|
---|
[107] | 3307 | xstr("briefing_departure")
|
---|
| 3308 | if departure
|
---|
| 3309 | else xstr("briefing_arrival"))
|
---|
[754] | 3310 | super(BriefingPage, self).__init__(wizard,
|
---|
| 3311 | "briefing%d" % (number,),
|
---|
| 3312 | title, xstr("briefing_help"),
|
---|
[107] | 3313 | completedHelp = xstr("briefing_chelp"))
|
---|
[64] | 3314 |
|
---|
| 3315 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 3316 | xscale = 1.0, yscale = 1.0)
|
---|
| 3317 |
|
---|
| 3318 | mainBox = gtk.VBox()
|
---|
| 3319 | alignment.add(mainBox)
|
---|
| 3320 | self.setMainWidget(alignment)
|
---|
| 3321 |
|
---|
[67] | 3322 | self._notamsFrame = gtk.Frame()
|
---|
[107] | 3323 | self._notamsFrame.set_label(xstr("briefing_notams_init"))
|
---|
[64] | 3324 | scrolledWindow = gtk.ScrolledWindow()
|
---|
[67] | 3325 | scrolledWindow.set_size_request(-1, 128)
|
---|
[94] | 3326 | # FIXME: these constants should be in common
|
---|
[69] | 3327 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 3328 | else gtk.POLICY_AUTOMATIC,
|
---|
| 3329 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 3330 | else gtk.POLICY_AUTOMATIC)
|
---|
[67] | 3331 | self._notams = gtk.TextView()
|
---|
| 3332 | self._notams.set_editable(False)
|
---|
| 3333 | self._notams.set_accepts_tab(False)
|
---|
| 3334 | self._notams.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
| 3335 | scrolledWindow.add(self._notams)
|
---|
| 3336 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 3337 | xscale = 1.0, yscale = 1.0)
|
---|
| 3338 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 3339 | padding_left = 0, padding_right = 0)
|
---|
| 3340 | alignment.add(scrolledWindow)
|
---|
| 3341 | self._notamsFrame.add(alignment)
|
---|
| 3342 | mainBox.pack_start(self._notamsFrame, True, True, 4)
|
---|
[347] | 3343 |
|
---|
[67] | 3344 | self._metarFrame = gtk.Frame()
|
---|
[107] | 3345 | self._metarFrame.set_label(xstr("briefing_metar_init"))
|
---|
[67] | 3346 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 3347 | scrolledWindow.set_size_request(-1, 32)
|
---|
[69] | 3348 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 3349 | else gtk.POLICY_AUTOMATIC,
|
---|
| 3350 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 3351 | else gtk.POLICY_AUTOMATIC)
|
---|
[138] | 3352 |
|
---|
[586] | 3353 | self._updatingMETAR = False
|
---|
[138] | 3354 |
|
---|
[67] | 3355 | self._metar = gtk.TextView()
|
---|
| 3356 | self._metar.set_accepts_tab(False)
|
---|
| 3357 | self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
[106] | 3358 | self._metar.get_buffer().connect("changed", self._metarChanged)
|
---|
[138] | 3359 | self._metar.get_buffer().connect_after("insert-text", self._metarInserted)
|
---|
[67] | 3360 | scrolledWindow.add(self._metar)
|
---|
| 3361 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 3362 | xscale = 1.0, yscale = 1.0)
|
---|
| 3363 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 3364 | padding_left = 0, padding_right = 0)
|
---|
| 3365 | alignment.add(scrolledWindow)
|
---|
| 3366 | self._metarFrame.add(alignment)
|
---|
| 3367 | mainBox.pack_start(self._metarFrame, True, True, 4)
|
---|
[106] | 3368 | self.metarEdited = False
|
---|
[64] | 3369 |
|
---|
[208] | 3370 | self.addCancelFlightButton()
|
---|
| 3371 |
|
---|
[107] | 3372 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 3373 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[64] | 3374 |
|
---|
[97] | 3375 | @property
|
---|
| 3376 | def metar(self):
|
---|
| 3377 | """Get the METAR on the page."""
|
---|
| 3378 | buffer = self._metar.get_buffer()
|
---|
| 3379 | return buffer.get_text(buffer.get_start_iter(),
|
---|
[347] | 3380 | buffer.get_end_iter(), True)
|
---|
[97] | 3381 |
|
---|
[106] | 3382 | def setMETAR(self, metar):
|
---|
[586] | 3383 | """Set the METAR."""
|
---|
[106] | 3384 | self._metar.get_buffer().set_text(metar)
|
---|
| 3385 | self.metarEdited = False
|
---|
| 3386 |
|
---|
[586] | 3387 | def changeMETAR(self, metar):
|
---|
| 3388 | """Change the METAR as a result of an edit on one of the other
|
---|
| 3389 | pages."""
|
---|
| 3390 | self._updatingMETAR = True
|
---|
| 3391 | self._metar.get_buffer().set_text(metar)
|
---|
| 3392 | self._updatingMETAR = False
|
---|
[588] | 3393 |
|
---|
| 3394 | self._updateButton()
|
---|
[586] | 3395 | self.metarEdited = True
|
---|
| 3396 |
|
---|
[64] | 3397 | def activate(self):
|
---|
| 3398 | """Activate the page."""
|
---|
[70] | 3399 | if not self._departure:
|
---|
[107] | 3400 | self._button.set_label(xstr("briefing_button"))
|
---|
| 3401 | self._button.set_has_tooltip(False)
|
---|
[70] | 3402 | self._button.set_use_stock(False)
|
---|
| 3403 |
|
---|
| 3404 | bookedFlight = self._wizard._bookedFlight
|
---|
[67] | 3405 |
|
---|
[70] | 3406 | icao = bookedFlight.departureICAO if self._departure \
|
---|
| 3407 | else bookedFlight.arrivalICAO
|
---|
| 3408 | notams = self._wizard._departureNOTAMs if self._departure \
|
---|
| 3409 | else self._wizard._arrivalNOTAMs
|
---|
| 3410 | metar = self._wizard._departureMETAR if self._departure \
|
---|
| 3411 | else self._wizard._arrivalMETAR
|
---|
[64] | 3412 |
|
---|
[107] | 3413 | self._notamsFrame.set_label(xstr("briefing_notams_template") % (icao,))
|
---|
[70] | 3414 | buffer = self._notams.get_buffer()
|
---|
| 3415 | if notams is None:
|
---|
[107] | 3416 | buffer.set_text(xstr("briefing_notams_failed"))
|
---|
[92] | 3417 | elif not notams:
|
---|
[107] | 3418 | buffer.set_text(xstr("briefing_notams_missing"))
|
---|
[70] | 3419 | else:
|
---|
| 3420 | s = ""
|
---|
| 3421 | for notam in notams:
|
---|
[570] | 3422 | s += str(notam)
|
---|
[70] | 3423 | s += "-------------------- * --------------------\n"
|
---|
| 3424 | buffer.set_text(s)
|
---|
[67] | 3425 |
|
---|
[107] | 3426 | self._metarFrame.set_label(xstr("briefing_metar_template") % (icao,))
|
---|
[70] | 3427 | buffer = self._metar.get_buffer()
|
---|
[586] | 3428 | self._updatingMETAR = True
|
---|
[70] | 3429 | if metar is None:
|
---|
[584] | 3430 | buffer.set_text("")
|
---|
| 3431 | self.setHelp(xstr("briefing_help_nometar"))
|
---|
[70] | 3432 | else:
|
---|
| 3433 | buffer.set_text(metar)
|
---|
[586] | 3434 | self._updatingMETAR = False
|
---|
[584] | 3435 | self._updateButton()
|
---|
[67] | 3436 |
|
---|
[107] | 3437 | label = self._metarFrame.get_label_widget()
|
---|
| 3438 | label.set_use_underline(True)
|
---|
| 3439 | label.set_mnemonic_widget(self._metar)
|
---|
| 3440 |
|
---|
[106] | 3441 | self.metarEdited = False
|
---|
| 3442 |
|
---|
[70] | 3443 | def _backClicked(self, button):
|
---|
| 3444 | """Called when the Back button is pressed."""
|
---|
| 3445 | self.goBack()
|
---|
[347] | 3446 |
|
---|
[67] | 3447 | def _forwardClicked(self, button):
|
---|
[64] | 3448 | """Called when the forward button is clicked."""
|
---|
[70] | 3449 | if not self._departure:
|
---|
[94] | 3450 | if not self._completed:
|
---|
[70] | 3451 | self._wizard.gui.startMonitoring()
|
---|
[107] | 3452 | self._button.set_label(xstr("button_next"))
|
---|
| 3453 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
[94] | 3454 | self.complete()
|
---|
[71] | 3455 |
|
---|
| 3456 | self._wizard.nextPage()
|
---|
| 3457 |
|
---|
[106] | 3458 | def _metarChanged(self, buffer):
|
---|
| 3459 | """Called when the METAR has changed."""
|
---|
[586] | 3460 | print "BriefingPage.metarChanged", self._updatingMETAR
|
---|
| 3461 | if not self._updatingMETAR:
|
---|
[138] | 3462 | self.metarEdited = True
|
---|
[584] | 3463 | self._updateButton()
|
---|
[586] | 3464 | metar = buffer.get_text(buffer.get_start_iter(),
|
---|
| 3465 | buffer.get_end_iter(), True)
|
---|
| 3466 | self._wizard.metarChanged(metar, self)
|
---|
[138] | 3467 |
|
---|
| 3468 | def _metarInserted(self, textBuffer, iter, text, length):
|
---|
| 3469 | """Called when new characters are inserted into the METAR.
|
---|
| 3470 |
|
---|
| 3471 | It uppercases all characters."""
|
---|
[586] | 3472 | print "BriefingPage.metarInserted", self._updatingMETAR
|
---|
| 3473 | if not self._updatingMETAR:
|
---|
| 3474 | self._updatingMETAR = True
|
---|
[138] | 3475 |
|
---|
| 3476 | iter1 = iter.copy()
|
---|
| 3477 | iter1.backward_chars(length)
|
---|
| 3478 | textBuffer.delete(iter, iter1)
|
---|
| 3479 |
|
---|
| 3480 | textBuffer.insert(iter, text.upper())
|
---|
| 3481 |
|
---|
[586] | 3482 | self._updatingMETAR = False
|
---|
[106] | 3483 |
|
---|
[584] | 3484 | def _updateButton(self):
|
---|
| 3485 | """Update the sensitivity of the Next button based on the contents of
|
---|
| 3486 | the METAR field."""
|
---|
| 3487 | buffer = self._metar.get_buffer()
|
---|
| 3488 | self._button.set_sensitive(buffer.get_text(buffer.get_start_iter(),
|
---|
| 3489 | buffer.get_end_iter(),
|
---|
| 3490 | True)!="")
|
---|
| 3491 |
|
---|
| 3492 |
|
---|
[71] | 3493 | #-----------------------------------------------------------------------------
|
---|
| 3494 |
|
---|
| 3495 | class TakeoffPage(Page):
|
---|
| 3496 | """Page for entering the takeoff data."""
|
---|
| 3497 | def __init__(self, wizard):
|
---|
| 3498 | """Construct the takeoff page."""
|
---|
[754] | 3499 | super(TakeoffPage, self).__init__(wizard, "takeoff",
|
---|
| 3500 | xstr("takeoff_title"),
|
---|
[107] | 3501 | xstr("takeoff_help"),
|
---|
| 3502 | completedHelp = xstr("takeoff_chelp"))
|
---|
[71] | 3503 |
|
---|
[101] | 3504 | self._forwardAllowed = False
|
---|
| 3505 |
|
---|
[71] | 3506 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 3507 | xscale = 0.0, yscale = 0.0)
|
---|
| 3508 |
|
---|
[586] | 3509 | table = gtk.Table(9, 24)
|
---|
[71] | 3510 | table.set_row_spacings(4)
|
---|
| 3511 | table.set_col_spacings(16)
|
---|
| 3512 | table.set_homogeneous(False)
|
---|
| 3513 | alignment.add(table)
|
---|
| 3514 | self.setMainWidget(alignment)
|
---|
| 3515 |
|
---|
[586] | 3516 | row = 0
|
---|
| 3517 |
|
---|
| 3518 | label = gtk.Label(xstr("takeoff_metar"))
|
---|
| 3519 | label.set_use_underline(True)
|
---|
| 3520 | label.set_alignment(0.0, 0.5)
|
---|
| 3521 | table.attach(label, 0, 1, row, row+1)
|
---|
| 3522 |
|
---|
| 3523 | self._metar = gtk.Entry()
|
---|
| 3524 | self._metar.set_width_chars(40)
|
---|
[590] | 3525 | self._metar.set_tooltip_text(xstr("takeoff_metar_tooltip"))
|
---|
[586] | 3526 | self._metar.connect("changed", self._metarChanged)
|
---|
[587] | 3527 | self._metar.get_buffer().connect_after("inserted-text", self._metarInserted)
|
---|
[586] | 3528 | table.attach(self._metar, 1, 24, row, row+1)
|
---|
| 3529 | label.set_mnemonic_widget(self._metar)
|
---|
| 3530 |
|
---|
| 3531 | self._updatingMETAR = False
|
---|
| 3532 |
|
---|
| 3533 | row += 1
|
---|
| 3534 |
|
---|
[107] | 3535 | label = gtk.Label(xstr("takeoff_runway"))
|
---|
[71] | 3536 | label.set_use_underline(True)
|
---|
| 3537 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 3538 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 3539 |
|
---|
| 3540 | self._runway = gtk.Entry()
|
---|
| 3541 | self._runway.set_width_chars(10)
|
---|
[107] | 3542 | self._runway.set_tooltip_text(xstr("takeoff_runway_tooltip"))
|
---|
[138] | 3543 | self._runway.connect("changed", self._upperChanged)
|
---|
[586] | 3544 | table.attach(self._runway, 1, 3, row, row+1)
|
---|
[71] | 3545 | label.set_mnemonic_widget(self._runway)
|
---|
[347] | 3546 |
|
---|
[586] | 3547 | row += 1
|
---|
| 3548 |
|
---|
[107] | 3549 | label = gtk.Label(xstr("takeoff_sid"))
|
---|
[71] | 3550 | label.set_use_underline(True)
|
---|
| 3551 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 3552 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 3553 |
|
---|
[621] | 3554 | if pygobject:
|
---|
| 3555 | self._sid = gtk.ComboBox.new_with_model_and_entry(comboModel)
|
---|
| 3556 | else:
|
---|
| 3557 | self._sid = gtk.ComboBoxEntry(comboModel)
|
---|
| 3558 |
|
---|
| 3559 | self._sid.set_entry_text_column(0)
|
---|
| 3560 | self._sid.get_child().set_width_chars(10)
|
---|
[107] | 3561 | self._sid.set_tooltip_text(xstr("takeoff_sid_tooltip"))
|
---|
[621] | 3562 | self._sid.connect("changed", self._upperChangedComboBox)
|
---|
[586] | 3563 | table.attach(self._sid, 1, 3, row, row+1)
|
---|
[71] | 3564 | label.set_mnemonic_widget(self._sid)
|
---|
[347] | 3565 |
|
---|
[586] | 3566 | row += 1
|
---|
| 3567 |
|
---|
[107] | 3568 | label = gtk.Label(xstr("takeoff_v1"))
|
---|
[71] | 3569 | label.set_use_markup(True)
|
---|
| 3570 | label.set_use_underline(True)
|
---|
| 3571 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 3572 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 3573 |
|
---|
[84] | 3574 | self._v1 = IntegerEntry()
|
---|
[86] | 3575 | self._v1.set_width_chars(4)
|
---|
[241] | 3576 | self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip_knots"))
|
---|
[101] | 3577 | self._v1.connect("integer-changed", self._valueChanged)
|
---|
[586] | 3578 | table.attach(self._v1, 2, 3, row, row+1)
|
---|
[71] | 3579 | label.set_mnemonic_widget(self._v1)
|
---|
[241] | 3580 |
|
---|
| 3581 | self._v1Unit = gtk.Label(xstr("label_knots"))
|
---|
[384] | 3582 | self._v1Unit.set_alignment(0.0, 0.5)
|
---|
[586] | 3583 | table.attach(self._v1Unit, 3, 4, row, row+1)
|
---|
| 3584 |
|
---|
| 3585 | row += 1
|
---|
[347] | 3586 |
|
---|
[107] | 3587 | label = gtk.Label(xstr("takeoff_vr"))
|
---|
[71] | 3588 | label.set_use_markup(True)
|
---|
| 3589 | label.set_use_underline(True)
|
---|
| 3590 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 3591 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 3592 |
|
---|
[84] | 3593 | self._vr = IntegerEntry()
|
---|
[86] | 3594 | self._vr.set_width_chars(4)
|
---|
[241] | 3595 | self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip_knots"))
|
---|
[101] | 3596 | self._vr.connect("integer-changed", self._valueChanged)
|
---|
[586] | 3597 | table.attach(self._vr, 2, 3, row, row+1)
|
---|
[71] | 3598 | label.set_mnemonic_widget(self._vr)
|
---|
[347] | 3599 |
|
---|
[241] | 3600 | self._vrUnit = gtk.Label(xstr("label_knots"))
|
---|
[384] | 3601 | self._vrUnit.set_alignment(0.0, 0.5)
|
---|
[586] | 3602 | table.attach(self._vrUnit, 3, 4, row, row+1)
|
---|
| 3603 |
|
---|
| 3604 | row += 1
|
---|
[347] | 3605 |
|
---|
[107] | 3606 | label = gtk.Label(xstr("takeoff_v2"))
|
---|
[71] | 3607 | label.set_use_markup(True)
|
---|
| 3608 | label.set_use_underline(True)
|
---|
| 3609 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 3610 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 3611 |
|
---|
[84] | 3612 | self._v2 = IntegerEntry()
|
---|
[86] | 3613 | self._v2.set_width_chars(4)
|
---|
[241] | 3614 | self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip_knots"))
|
---|
[101] | 3615 | self._v2.connect("integer-changed", self._valueChanged)
|
---|
[586] | 3616 | table.attach(self._v2, 2, 3, row, row+1)
|
---|
[71] | 3617 | label.set_mnemonic_widget(self._v2)
|
---|
[347] | 3618 |
|
---|
[241] | 3619 | self._v2Unit = gtk.Label(xstr("label_knots"))
|
---|
[384] | 3620 | self._v2Unit.set_alignment(0.0, 0.5)
|
---|
[586] | 3621 | table.attach(self._v2Unit, 3, 4, row, row+1)
|
---|
| 3622 |
|
---|
| 3623 | row += 1
|
---|
[71] | 3624 |
|
---|
[512] | 3625 | self._derateType = acft.DERATE_NONE
|
---|
[384] | 3626 |
|
---|
| 3627 | self._derateLabel = gtk.Label()
|
---|
| 3628 | self._derateLabel.set_use_underline(True)
|
---|
| 3629 | self._derateLabel.set_markup(xstr("takeoff_derate_tupolev"))
|
---|
| 3630 | self._derateLabel.set_alignment(0.0, 0.5)
|
---|
[586] | 3631 | table.attach(self._derateLabel, 0, 1, row, row+1)
|
---|
[384] | 3632 |
|
---|
[512] | 3633 | self._derate = gtk.Alignment()
|
---|
[586] | 3634 | table.attach(self._derate, 2, 4, row, row+1)
|
---|
[512] | 3635 | self._derateWidget = None
|
---|
| 3636 | self._derateEntry = None
|
---|
| 3637 | self._derateUnit = None
|
---|
| 3638 | self._derateButtons = None
|
---|
[384] | 3639 |
|
---|
[586] | 3640 | row += 1
|
---|
| 3641 |
|
---|
[391] | 3642 | self._antiIceOn = gtk.CheckButton(xstr("takeoff_antiice"))
|
---|
| 3643 | self._antiIceOn.set_use_underline(True)
|
---|
| 3644 | self._antiIceOn.set_tooltip_text(xstr("takeoff_antiice_tooltip"))
|
---|
[586] | 3645 | table.attach(self._antiIceOn, 2, 4, row, row+1)
|
---|
| 3646 |
|
---|
| 3647 | row += 1
|
---|
[391] | 3648 |
|
---|
[349] | 3649 | self._rto = gtk.CheckButton(xstr("takeoff_rto"))
|
---|
| 3650 | self._rto.set_use_underline(True)
|
---|
| 3651 | self._rto.set_tooltip_text(xstr("takeoff_rto_tooltip"))
|
---|
| 3652 | self._rto.connect("toggled", self._rtoToggled)
|
---|
[586] | 3653 | table.attach(self._rto, 2, 4, row, row+1, ypadding = 8)
|
---|
[349] | 3654 |
|
---|
[208] | 3655 | self.addCancelFlightButton()
|
---|
| 3656 |
|
---|
[107] | 3657 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 3658 |
|
---|
| 3659 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[71] | 3660 |
|
---|
[586] | 3661 | self._active = False
|
---|
| 3662 |
|
---|
[84] | 3663 | @property
|
---|
[97] | 3664 | def runway(self):
|
---|
| 3665 | """Get the runway."""
|
---|
| 3666 | return self._runway.get_text()
|
---|
| 3667 |
|
---|
| 3668 | @property
|
---|
| 3669 | def sid(self):
|
---|
| 3670 | """Get the SID."""
|
---|
[621] | 3671 | text = self._sid.get_child().get_text()
|
---|
| 3672 | return text if self._sid.get_active()!=0 and text and text!="N/A" \
|
---|
| 3673 | else None
|
---|
[97] | 3674 |
|
---|
| 3675 | @property
|
---|
[84] | 3676 | def v1(self):
|
---|
| 3677 | """Get the v1 speed."""
|
---|
| 3678 | return self._v1.get_int()
|
---|
| 3679 |
|
---|
| 3680 | @property
|
---|
| 3681 | def vr(self):
|
---|
| 3682 | """Get the vr speed."""
|
---|
| 3683 | return self._vr.get_int()
|
---|
| 3684 |
|
---|
| 3685 | @property
|
---|
| 3686 | def v2(self):
|
---|
| 3687 | """Get the v2 speed."""
|
---|
| 3688 | return self._v2.get_int()
|
---|
| 3689 |
|
---|
[349] | 3690 | @property
|
---|
[384] | 3691 | def derate(self):
|
---|
| 3692 | """Get the derate value, if any."""
|
---|
[512] | 3693 | if self._derateWidget is None:
|
---|
| 3694 | return None
|
---|
| 3695 | if self._derateType==acft.DERATE_BOEING:
|
---|
| 3696 | derate = self._derateEntry.get_text()
|
---|
[384] | 3697 | return derate if derate else None
|
---|
[512] | 3698 | elif self._derateType==acft.DERATE_EPR:
|
---|
| 3699 | derate = self._derateWidget.get_text()
|
---|
| 3700 | return derate if derate else None
|
---|
| 3701 | elif self._derateType==acft.DERATE_TUPOLEV:
|
---|
| 3702 | return acft.DERATE_TUPOLEV_NOMINAL \
|
---|
| 3703 | if self._derateButtons[0].get_active() \
|
---|
| 3704 | else acft.DERATE_TUPOLEV_TAKEOFF
|
---|
| 3705 | elif self._derateType==acft.DERATE_B462:
|
---|
| 3706 | return self._derateWidget.get_active()
|
---|
[384] | 3707 | else:
|
---|
| 3708 | return None
|
---|
| 3709 |
|
---|
| 3710 | @property
|
---|
[391] | 3711 | def antiIceOn(self):
|
---|
| 3712 | """Get whether the anti-ice system has been turned on."""
|
---|
| 3713 | return self._antiIceOn.get_active()
|
---|
| 3714 |
|
---|
| 3715 | @antiIceOn.setter
|
---|
| 3716 | def antiIceOn(self, value):
|
---|
| 3717 | """Set the anti-ice indicator."""
|
---|
| 3718 | self._antiIceOn.set_active(value)
|
---|
| 3719 |
|
---|
| 3720 | @property
|
---|
[349] | 3721 | def rtoIndicated(self):
|
---|
| 3722 | """Get whether the pilot has indicated if there was an RTO."""
|
---|
| 3723 | return self._rto.get_active()
|
---|
| 3724 |
|
---|
[71] | 3725 | def activate(self):
|
---|
| 3726 | """Activate the page."""
|
---|
[551] | 3727 | print "TakeoffPage.activate"
|
---|
| 3728 |
|
---|
[586] | 3729 | self._updatingMETAR = True
|
---|
| 3730 | self._metar.get_buffer().set_text(self._wizard.departureMETAR, -1)
|
---|
| 3731 | self._updatingMETAR = False
|
---|
| 3732 |
|
---|
[717] | 3733 | if self._wizard.takeoffRunway is None:
|
---|
| 3734 | self._runway.set_text("")
|
---|
| 3735 | else:
|
---|
| 3736 | self._runway.set_text(self._wizard.takeoffRunway)
|
---|
[71] | 3737 | self._runway.set_sensitive(True)
|
---|
[621] | 3738 | self._sid.set_active(0)
|
---|
[71] | 3739 | self._sid.set_sensitive(True)
|
---|
[84] | 3740 | self._v1.set_int(None)
|
---|
[71] | 3741 | self._v1.set_sensitive(True)
|
---|
[86] | 3742 | self._vr.set_int(None)
|
---|
[71] | 3743 | self._vr.set_sensitive(True)
|
---|
[86] | 3744 | self._v2.set_int(None)
|
---|
[71] | 3745 | self._v2.set_sensitive(True)
|
---|
[241] | 3746 |
|
---|
| 3747 | i18nSpeedUnit = self._wizard.gui.flight.getI18NSpeedUnit()
|
---|
| 3748 | speedUnit = xstr("label" + i18nSpeedUnit)
|
---|
| 3749 | self._v1Unit.set_text(speedUnit)
|
---|
| 3750 | self._vrUnit.set_text(speedUnit)
|
---|
| 3751 | self._v2Unit.set_text(speedUnit)
|
---|
| 3752 |
|
---|
| 3753 | self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip" + i18nSpeedUnit))
|
---|
| 3754 | self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip" + i18nSpeedUnit))
|
---|
| 3755 | self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip" + i18nSpeedUnit))
|
---|
| 3756 |
|
---|
[512] | 3757 | self._derateType = self._wizard.gui.flight.aircraft.derateType
|
---|
| 3758 |
|
---|
| 3759 | self._setupDerateWidget()
|
---|
[384] | 3760 |
|
---|
[349] | 3761 | self._rto.set_active(False)
|
---|
| 3762 | self._rto.set_sensitive(False)
|
---|
| 3763 |
|
---|
[84] | 3764 | self._button.set_sensitive(False)
|
---|
[218] | 3765 | self._forwardAllowed = False
|
---|
[347] | 3766 |
|
---|
[586] | 3767 | self._active = True
|
---|
| 3768 |
|
---|
[101] | 3769 | def allowForward(self):
|
---|
| 3770 | """Allow going to the next page."""
|
---|
[551] | 3771 | print "TakeoffPage.allowForward"
|
---|
[101] | 3772 | self._forwardAllowed = True
|
---|
| 3773 | self._updateForwardButton()
|
---|
| 3774 |
|
---|
[241] | 3775 | def reset(self):
|
---|
| 3776 | """Reset the page if the wizard is reset."""
|
---|
[551] | 3777 | print "TakeoffPage.reset"
|
---|
| 3778 |
|
---|
[241] | 3779 | super(TakeoffPage, self).reset()
|
---|
| 3780 | self._v1.reset()
|
---|
| 3781 | self._vr.reset()
|
---|
| 3782 | self._v2.reset()
|
---|
[384] | 3783 | self._hasDerate = False
|
---|
[391] | 3784 | self._antiIceOn.set_active(False)
|
---|
[586] | 3785 | self._active = False
|
---|
[384] | 3786 |
|
---|
[349] | 3787 | def setRTOEnabled(self, enabled):
|
---|
| 3788 | """Set the RTO checkbox enabled or disabled."""
|
---|
| 3789 | if not enabled:
|
---|
| 3790 | self._rto.set_active(False)
|
---|
| 3791 | self._rto.set_sensitive(enabled)
|
---|
| 3792 |
|
---|
[586] | 3793 | def changeMETAR(self, metar):
|
---|
| 3794 | """Change the METAR as a result of an edit on one of the other
|
---|
| 3795 | pages."""
|
---|
| 3796 | if self._active:
|
---|
| 3797 | print "TakeoffPage.changeMETAR"
|
---|
| 3798 | self._updatingMETAR = True
|
---|
| 3799 | self._metar.get_buffer().set_text(metar, -1)
|
---|
| 3800 | self._updatingMETAR = False
|
---|
| 3801 |
|
---|
[588] | 3802 | self._updateForwardButton()
|
---|
| 3803 |
|
---|
[101] | 3804 | def _updateForwardButton(self):
|
---|
| 3805 | """Update the sensitivity of the forward button based on some conditions."""
|
---|
| 3806 | sensitive = self._forwardAllowed and \
|
---|
[588] | 3807 | self._metar.get_text()!="" and \
|
---|
[101] | 3808 | self._runway.get_text()!="" and \
|
---|
[621] | 3809 | self.sid is not None and \
|
---|
[101] | 3810 | self.v1 is not None and \
|
---|
| 3811 | self.vr is not None and \
|
---|
| 3812 | self.v2 is not None and \
|
---|
| 3813 | self.v1 <= self.vr and \
|
---|
[384] | 3814 | self.vr <= self.v2 and \
|
---|
[512] | 3815 | (self._derateType==acft.DERATE_NONE or
|
---|
| 3816 | self.derate is not None)
|
---|
[551] | 3817 |
|
---|
| 3818 | print "TakeoffPage._updateForwardButton: forwardAllowed:", self._forwardAllowed, ", sensitive:", sensitive
|
---|
[638] | 3819 | if self._forwardAllowed:
|
---|
| 3820 | print " METAR: ", self._metar.get_text()
|
---|
| 3821 | print " runway: ", self._runway.get_text()
|
---|
| 3822 | print " SID:", self.sid
|
---|
| 3823 | print " V1:", self.v1
|
---|
| 3824 | print " VR:", self.vr
|
---|
| 3825 | print " V2:", self.v2
|
---|
| 3826 | print " derateType:", self._derateType
|
---|
| 3827 | print " derate:", self.derate
|
---|
[551] | 3828 |
|
---|
[101] | 3829 | self._button.set_sensitive(sensitive)
|
---|
| 3830 |
|
---|
| 3831 | def _valueChanged(self, widget, arg = None):
|
---|
| 3832 | """Called when the value of some widget has changed."""
|
---|
[551] | 3833 | print "TakeoffPage._valueChanged"
|
---|
| 3834 |
|
---|
[101] | 3835 | self._updateForwardButton()
|
---|
[347] | 3836 |
|
---|
[138] | 3837 | def _upperChanged(self, entry, arg = None):
|
---|
| 3838 | """Called when the value of some entry widget has changed and the value
|
---|
| 3839 | should be converted to uppercase."""
|
---|
[551] | 3840 | print "TakeoffPage._upperChanged"
|
---|
[138] | 3841 | entry.set_text(entry.get_text().upper())
|
---|
| 3842 | self._valueChanged(entry, arg)
|
---|
[347] | 3843 |
|
---|
[621] | 3844 | def _upperChangedComboBox(self, comboBox):
|
---|
| 3845 | """Called for combo box widgets that must be converted to uppercase."""
|
---|
| 3846 | entry = comboBox.get_child()
|
---|
| 3847 | if comboBox.get_active()==-1:
|
---|
| 3848 | entry.set_text(entry.get_text().upper())
|
---|
| 3849 | self._valueChanged(entry)
|
---|
| 3850 |
|
---|
[384] | 3851 | def _derateChanged(self, entry):
|
---|
| 3852 | """Called when the value of the derate is changed."""
|
---|
[551] | 3853 | print "TakeoffPage._derateChanged"
|
---|
[384] | 3854 | self._updateForwardButton()
|
---|
| 3855 |
|
---|
[349] | 3856 | def _rtoToggled(self, button):
|
---|
| 3857 | """Called when the RTO check button is toggled."""
|
---|
| 3858 | self._wizard.rtoToggled(button.get_active())
|
---|
| 3859 |
|
---|
[71] | 3860 | def _backClicked(self, button):
|
---|
| 3861 | """Called when the Back button is pressed."""
|
---|
| 3862 | self.goBack()
|
---|
[347] | 3863 |
|
---|
[71] | 3864 | def _forwardClicked(self, button):
|
---|
| 3865 | """Called when the forward button is clicked."""
|
---|
[391] | 3866 | aircraft = self._wizard.gui.flight.aircraft
|
---|
| 3867 | aircraft.updateV1R2()
|
---|
[512] | 3868 | if self.derate is not None:
|
---|
[391] | 3869 | aircraft.updateDerate()
|
---|
| 3870 | aircraft.updateTakeoffAntiIce()
|
---|
[75] | 3871 | self._wizard.nextPage()
|
---|
| 3872 |
|
---|
[512] | 3873 | def _setupDerateWidget(self):
|
---|
| 3874 | """Setup the derate widget."""
|
---|
| 3875 | if self._derateWidget is not None:
|
---|
| 3876 | self._derate.remove(self._derateWidget)
|
---|
| 3877 |
|
---|
| 3878 | if self._derateType==acft.DERATE_BOEING:
|
---|
| 3879 | self._derateLabel.set_text(xstr("takeoff_derate_boeing"))
|
---|
| 3880 | self._derateLabel.set_use_underline(True)
|
---|
| 3881 | self._derateLabel.set_sensitive(True)
|
---|
| 3882 |
|
---|
| 3883 | self._derateEntry = gtk.Entry()
|
---|
| 3884 | self._derateEntry.set_width_chars(7)
|
---|
| 3885 | self._derateEntry.set_tooltip_text(xstr("takeoff_derate_boeing_tooltip"))
|
---|
| 3886 | self._derateEntry.set_alignment(1.0)
|
---|
| 3887 | self._derateEntry.connect("changed", self._derateChanged)
|
---|
| 3888 | self._derateLabel.set_mnemonic_widget(self._derateEntry)
|
---|
| 3889 |
|
---|
| 3890 | self._derateUnit = gtk.Label("%")
|
---|
| 3891 | self._derateUnit.set_alignment(0.0, 0.5)
|
---|
| 3892 |
|
---|
| 3893 | self._derateWidget = gtk.Table(3, 1)
|
---|
| 3894 | self._derateWidget.set_row_spacings(4)
|
---|
| 3895 | self._derateWidget.set_col_spacings(16)
|
---|
| 3896 | self._derateWidget.set_homogeneous(False)
|
---|
| 3897 |
|
---|
| 3898 | self._derateWidget.attach(self._derateEntry, 0, 2, 0, 1)
|
---|
| 3899 | self._derateWidget.attach(self._derateUnit, 2, 3, 0, 1)
|
---|
| 3900 |
|
---|
| 3901 | self._derate.add(self._derateWidget)
|
---|
| 3902 | elif self._derateType==acft.DERATE_EPR:
|
---|
| 3903 | self._derateLabel.set_text("_EPR:")
|
---|
| 3904 | self._derateLabel.set_use_underline(True)
|
---|
| 3905 | self._derateLabel.set_sensitive(True)
|
---|
| 3906 |
|
---|
| 3907 | self._derateWidget = gtk.Entry()
|
---|
| 3908 | self._derateWidget.set_width_chars(7)
|
---|
| 3909 | self._derateWidget.set_tooltip_text(xstr("takeoff_derate_epr_tooltip"))
|
---|
| 3910 | self._derateWidget.set_alignment(1.0)
|
---|
| 3911 | self._derateWidget.connect("changed", self._derateChanged)
|
---|
| 3912 | self._derateLabel.set_mnemonic_widget(self._derateWidget)
|
---|
| 3913 |
|
---|
| 3914 | self._derate.add(self._derateWidget)
|
---|
| 3915 | elif self._derateType==acft.DERATE_TUPOLEV:
|
---|
| 3916 | self._derateLabel.set_text(xstr("takeoff_derate_tupolev"))
|
---|
| 3917 | self._derateLabel.set_use_underline(True)
|
---|
| 3918 | self._derateLabel.set_sensitive(True)
|
---|
| 3919 |
|
---|
| 3920 | if pygobject:
|
---|
| 3921 | nominal = gtk.RadioButton.\
|
---|
| 3922 | new_with_label_from_widget(None,
|
---|
| 3923 | xstr("takeoff_derate_tupolev_nominal"))
|
---|
| 3924 | else:
|
---|
| 3925 | nominal = gtk.RadioButton(None,
|
---|
| 3926 | xstr("takeoff_derate_tupolev_nominal"))
|
---|
| 3927 | nominal.set_use_underline(True)
|
---|
| 3928 | nominal.set_tooltip_text(xstr("takeoff_derate_tupolev_nominal_tooltip"))
|
---|
| 3929 | nominal.connect("toggled", self._derateChanged)
|
---|
| 3930 |
|
---|
| 3931 | if pygobject:
|
---|
| 3932 | takeoff = gtk.RadioButton.\
|
---|
| 3933 | new_with_label_from_widget(nominal,
|
---|
| 3934 | xstr("takeoff_derate_tupolev_takeoff"))
|
---|
| 3935 | else:
|
---|
| 3936 | takeoff = gtk.RadioButton(nominal,
|
---|
| 3937 | xstr("takeoff_derate_tupolev_takeoff"))
|
---|
| 3938 |
|
---|
| 3939 | takeoff.set_use_underline(True)
|
---|
| 3940 | takeoff.set_tooltip_text(xstr("takeoff_derate_tupolev_takeoff_tooltip"))
|
---|
| 3941 | takeoff.connect("toggled", self._derateChanged)
|
---|
| 3942 |
|
---|
| 3943 | self._derateButtons = [nominal, takeoff]
|
---|
| 3944 |
|
---|
| 3945 | self._derateWidget = gtk.HBox()
|
---|
| 3946 | self._derateWidget.pack_start(nominal, False, False, 4)
|
---|
| 3947 | self._derateWidget.pack_start(takeoff, False, False, 4)
|
---|
| 3948 |
|
---|
| 3949 | self._derate.add(self._derateWidget)
|
---|
| 3950 | elif self._derateType==acft.DERATE_B462:
|
---|
| 3951 | self._derateLabel.set_text("")
|
---|
| 3952 |
|
---|
| 3953 | self._derateWidget = gtk.CheckButton(xstr("takeoff_derate_b462"))
|
---|
| 3954 | self._derateWidget.set_tooltip_text(xstr("takeoff_derate_b462_tooltip"))
|
---|
| 3955 | self._derateWidget.set_use_underline(True)
|
---|
| 3956 | self._derate.add(self._derateWidget)
|
---|
| 3957 | else:
|
---|
| 3958 | self._derateWidget = None
|
---|
| 3959 | self._derateLabel.set_text("")
|
---|
| 3960 | self._derateLabel.set_sensitive(False)
|
---|
| 3961 |
|
---|
[586] | 3962 | def _metarChanged(self, entry):
|
---|
| 3963 | """Called when the METAR has changed."""
|
---|
| 3964 | print "TakeoffPage.metarChanged", self._updatingMETAR
|
---|
| 3965 | if not self._updatingMETAR:
|
---|
| 3966 | self._updateForwardButton()
|
---|
| 3967 | self._wizard.metarChanged(entry.get_text(), self)
|
---|
| 3968 |
|
---|
[587] | 3969 | def _metarInserted(self, buffer, position, text, length):
|
---|
[586] | 3970 | """Called when new characters are inserted into the METAR.
|
---|
| 3971 |
|
---|
| 3972 | It uppercases all characters."""
|
---|
| 3973 | print "TakeoffPage.metarInserted", self._updatingMETAR
|
---|
| 3974 | if not self._updatingMETAR:
|
---|
| 3975 | self._updatingMETAR = True
|
---|
| 3976 |
|
---|
[587] | 3977 | buffer.delete_text(position, length)
|
---|
| 3978 | buffer.insert_text(position, text.upper(), length)
|
---|
[586] | 3979 |
|
---|
| 3980 | self._updatingMETAR = False
|
---|
| 3981 |
|
---|
[75] | 3982 | #-----------------------------------------------------------------------------
|
---|
| 3983 |
|
---|
[383] | 3984 | class CruisePage(Page):
|
---|
| 3985 | """The page containing the flight level that might change during flight."""
|
---|
| 3986 | def __init__(self, wizard):
|
---|
| 3987 | """Construct the page."""
|
---|
[754] | 3988 | super(CruisePage, self).__init__(wizard, "cruise",
|
---|
| 3989 | xstr("cruise_title"),
|
---|
[383] | 3990 | xstr("cruise_help"))
|
---|
| 3991 |
|
---|
| 3992 | self._loggable = False
|
---|
| 3993 | self._loggedCruiseLevel = 240
|
---|
| 3994 | self._activated = False
|
---|
| 3995 |
|
---|
| 3996 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
| 3997 | xscale = 0.0, yscale = 1.0)
|
---|
| 3998 |
|
---|
| 3999 | mainBox = gtk.VBox()
|
---|
| 4000 | alignment.add(mainBox)
|
---|
| 4001 | self.setMainWidget(alignment)
|
---|
| 4002 |
|
---|
| 4003 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 4004 | xscale = 0.0, yscale = 0.0)
|
---|
| 4005 | mainBox.pack_start(alignment, False, False, 16)
|
---|
| 4006 |
|
---|
| 4007 | levelBox = gtk.HBox()
|
---|
| 4008 |
|
---|
| 4009 | label = gtk.Label(xstr("route_level"))
|
---|
| 4010 | label.set_use_underline(True)
|
---|
| 4011 | levelBox.pack_start(label, True, True, 0)
|
---|
| 4012 |
|
---|
| 4013 | self._cruiseLevel = gtk.SpinButton()
|
---|
| 4014 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
| 4015 | self._cruiseLevel.set_range(min = 50, max = 500)
|
---|
| 4016 | self._cruiseLevel.set_tooltip_text(xstr("cruise_route_level_tooltip"))
|
---|
| 4017 | self._cruiseLevel.set_numeric(True)
|
---|
| 4018 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
| 4019 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
| 4020 |
|
---|
| 4021 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
| 4022 |
|
---|
| 4023 | self._updateButton = gtk.Button(xstr("cruise_route_level_update"));
|
---|
| 4024 | self._updateButton.set_use_underline(True)
|
---|
| 4025 | self._updateButton.set_tooltip_text(xstr("cruise_route_level_update_tooltip"))
|
---|
| 4026 | self._updateButton.connect("clicked", self._updateButtonClicked)
|
---|
| 4027 |
|
---|
| 4028 | levelBox.pack_start(self._updateButton, False, False, 16)
|
---|
| 4029 |
|
---|
| 4030 | mainBox.pack_start(levelBox, False, False, 0)
|
---|
| 4031 |
|
---|
| 4032 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 4033 | xscale = 0.0, yscale = 1.0)
|
---|
| 4034 | mainBox.pack_start(alignment, True, True, 0)
|
---|
| 4035 |
|
---|
| 4036 | self.addCancelFlightButton()
|
---|
| 4037 |
|
---|
| 4038 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 4039 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 4040 |
|
---|
| 4041 | @property
|
---|
| 4042 | def activated(self):
|
---|
| 4043 | """Determine if the page is already activated or not."""
|
---|
| 4044 | return self._activated
|
---|
| 4045 |
|
---|
| 4046 | @property
|
---|
| 4047 | def cruiseLevel(self):
|
---|
| 4048 | """Get the cruise level."""
|
---|
| 4049 | return self._loggedCruiseLevel
|
---|
| 4050 |
|
---|
| 4051 | @property
|
---|
| 4052 | def loggableCruiseLevel(self):
|
---|
| 4053 | """Get the cruise level which should be logged."""
|
---|
| 4054 | return self._cruiseLevel.get_value_as_int()
|
---|
| 4055 |
|
---|
| 4056 | def setLoggable(self, loggable):
|
---|
| 4057 | """Set whether the cruise altitude can be logged."""
|
---|
| 4058 | self._loggable = loggable
|
---|
| 4059 | self._updateButtons()
|
---|
| 4060 |
|
---|
| 4061 | def activate(self):
|
---|
| 4062 | """Setup the route from the booked flight."""
|
---|
| 4063 | self._loggedCruiseLevel = self._wizard.filedCruiseLevel
|
---|
| 4064 | self._cruiseLevel.set_value(self._loggedCruiseLevel)
|
---|
| 4065 | self._activated = True
|
---|
| 4066 |
|
---|
| 4067 | def reset(self):
|
---|
| 4068 | """Reset the page."""
|
---|
| 4069 | self._loggable = False
|
---|
| 4070 | self._activated = False
|
---|
| 4071 | super(CruisePage, self).reset()
|
---|
| 4072 |
|
---|
| 4073 | def _updateButtons(self):
|
---|
| 4074 | """Update the sensitivity of the buttons."""
|
---|
| 4075 | self._updateButton.set_sensitive(self._loggable and
|
---|
| 4076 | self.loggableCruiseLevel!=
|
---|
| 4077 | self._loggedCruiseLevel)
|
---|
| 4078 |
|
---|
| 4079 | def _cruiseLevelChanged(self, spinButton):
|
---|
| 4080 | """Called when the cruise level has changed."""
|
---|
| 4081 | self._updateButtons()
|
---|
| 4082 |
|
---|
| 4083 | def _updateButtonClicked(self, button):
|
---|
| 4084 | """Called when the update button is clicked."""
|
---|
| 4085 | if self._wizard.cruiseLevelChanged():
|
---|
| 4086 | self._loggedCruiseLevel = self.loggableCruiseLevel
|
---|
| 4087 | self._updateButtons()
|
---|
| 4088 |
|
---|
| 4089 | def _backClicked(self, button):
|
---|
| 4090 | """Called when the Back button is pressed."""
|
---|
| 4091 | self.goBack()
|
---|
| 4092 |
|
---|
| 4093 | def _forwardClicked(self, button):
|
---|
| 4094 | """Called when the Forward button is clicked."""
|
---|
| 4095 | self._wizard.nextPage()
|
---|
| 4096 |
|
---|
| 4097 | #-----------------------------------------------------------------------------
|
---|
| 4098 |
|
---|
[75] | 4099 | class LandingPage(Page):
|
---|
| 4100 | """Page for entering landing data."""
|
---|
| 4101 | def __init__(self, wizard):
|
---|
| 4102 | """Construct the landing page."""
|
---|
[754] | 4103 | super(LandingPage, self).__init__(wizard, "landing",
|
---|
| 4104 | xstr("landing_title"),
|
---|
[107] | 4105 | xstr("landing_help"),
|
---|
| 4106 | completedHelp = xstr("landing_chelp"))
|
---|
[75] | 4107 |
|
---|
[88] | 4108 | self._flightEnded = False
|
---|
| 4109 |
|
---|
[75] | 4110 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 4111 | xscale = 0.0, yscale = 0.0)
|
---|
| 4112 |
|
---|
[589] | 4113 | table = gtk.Table(7, 24)
|
---|
[75] | 4114 | table.set_row_spacings(4)
|
---|
| 4115 | table.set_col_spacings(16)
|
---|
| 4116 | table.set_homogeneous(False)
|
---|
| 4117 | alignment.add(table)
|
---|
| 4118 | self.setMainWidget(alignment)
|
---|
| 4119 |
|
---|
[589] | 4120 | row = 0
|
---|
| 4121 |
|
---|
| 4122 | label = gtk.Label(xstr("landing_metar"))
|
---|
| 4123 | label.set_use_underline(True)
|
---|
| 4124 | label.set_alignment(0.0, 0.5)
|
---|
[728] | 4125 | table.attach(label, 1, 2, row, row+1)
|
---|
[589] | 4126 |
|
---|
| 4127 | self._metar = gtk.Entry()
|
---|
| 4128 | self._metar.set_width_chars(40)
|
---|
[590] | 4129 | self._metar.set_tooltip_text(xstr("landing_metar_tooltip"))
|
---|
[589] | 4130 | self._metar.connect("changed", self._metarChanged)
|
---|
| 4131 | self._metar.get_buffer().connect_after("inserted-text", self._metarInserted)
|
---|
[728] | 4132 | table.attach(self._metar, 2, 24, row, row+1)
|
---|
[589] | 4133 | label.set_mnemonic_widget(self._metar)
|
---|
| 4134 |
|
---|
| 4135 | self._updatingMETAR = False
|
---|
| 4136 |
|
---|
| 4137 | row += 1
|
---|
| 4138 |
|
---|
[107] | 4139 | label = gtk.Label(xstr("landing_star"))
|
---|
[75] | 4140 | label.set_use_underline(True)
|
---|
| 4141 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 4142 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 4143 |
|
---|
[621] | 4144 | if pygobject:
|
---|
| 4145 | self._star = gtk.ComboBox.new_with_model_and_entry(comboModel)
|
---|
| 4146 | else:
|
---|
| 4147 | self._star = gtk.ComboBoxEntry(comboModel)
|
---|
| 4148 |
|
---|
| 4149 | self._star.set_entry_text_column(0)
|
---|
| 4150 | self._star.get_child().set_width_chars(10)
|
---|
[107] | 4151 | self._star.set_tooltip_text(xstr("landing_star_tooltip"))
|
---|
[621] | 4152 | self._star.connect("changed", self._upperChangedComboBox)
|
---|
[75] | 4153 | self._star.set_sensitive(False)
|
---|
[589] | 4154 | table.attach(self._star, 2, 4, row, row + 1)
|
---|
[621] | 4155 | label.set_mnemonic_widget(self._star)
|
---|
[75] | 4156 |
|
---|
[589] | 4157 | row += 1
|
---|
| 4158 |
|
---|
[107] | 4159 | label = gtk.Label(xstr("landing_transition"))
|
---|
[75] | 4160 | label.set_use_underline(True)
|
---|
| 4161 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 4162 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 4163 |
|
---|
[621] | 4164 | if pygobject:
|
---|
| 4165 | self._transition = gtk.ComboBox.new_with_model_and_entry(comboModel)
|
---|
| 4166 | else:
|
---|
| 4167 | self._transition = gtk.ComboBoxEntry(comboModel)
|
---|
| 4168 |
|
---|
| 4169 | self._transition.set_entry_text_column(0)
|
---|
| 4170 | self._transition.get_child().set_width_chars(10)
|
---|
[107] | 4171 | self._transition.set_tooltip_text(xstr("landing_transition_tooltip"))
|
---|
[621] | 4172 | self._transition.connect("changed", self._upperChangedComboBox)
|
---|
[75] | 4173 | self._transition.set_sensitive(False)
|
---|
[589] | 4174 | table.attach(self._transition, 2, 4, row, row + 1)
|
---|
[621] | 4175 | label.set_mnemonic_widget(self._transition)
|
---|
[75] | 4176 |
|
---|
[589] | 4177 | row += 1
|
---|
| 4178 |
|
---|
[107] | 4179 | label = gtk.Label(xstr("landing_runway"))
|
---|
[75] | 4180 | label.set_use_underline(True)
|
---|
| 4181 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 4182 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 4183 |
|
---|
| 4184 | self._runway = gtk.Entry()
|
---|
| 4185 | self._runway.set_width_chars(10)
|
---|
[107] | 4186 | self._runway.set_tooltip_text(xstr("landing_runway_tooltip"))
|
---|
[138] | 4187 | self._runway.connect("changed", self._upperChanged)
|
---|
[589] | 4188 | table.attach(self._runway, 2, 4, row, row + 1)
|
---|
[75] | 4189 | label.set_mnemonic_widget(self._runway)
|
---|
| 4190 |
|
---|
[589] | 4191 | row += 1
|
---|
| 4192 |
|
---|
[107] | 4193 | label = gtk.Label(xstr("landing_approach"))
|
---|
[75] | 4194 | label.set_use_underline(True)
|
---|
| 4195 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 4196 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 4197 |
|
---|
| 4198 | self._approachType = gtk.Entry()
|
---|
| 4199 | self._approachType.set_width_chars(10)
|
---|
[107] | 4200 | self._approachType.set_tooltip_text(xstr("landing_approach_tooltip"))
|
---|
[138] | 4201 | self._approachType.connect("changed", self._upperChanged)
|
---|
[589] | 4202 | table.attach(self._approachType, 2, 4, row, row + 1)
|
---|
[75] | 4203 | label.set_mnemonic_widget(self._approachType)
|
---|
| 4204 |
|
---|
[589] | 4205 | row += 1
|
---|
| 4206 |
|
---|
[107] | 4207 | label = gtk.Label(xstr("landing_vref"))
|
---|
[75] | 4208 | label.set_use_markup(True)
|
---|
| 4209 | label.set_use_underline(True)
|
---|
| 4210 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 4211 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 4212 |
|
---|
[86] | 4213 | self._vref = IntegerEntry()
|
---|
| 4214 | self._vref.set_width_chars(5)
|
---|
[241] | 4215 | self._vref.set_tooltip_markup(xstr("landing_vref_tooltip_knots"))
|
---|
[86] | 4216 | self._vref.connect("integer-changed", self._vrefChanged)
|
---|
[589] | 4217 | table.attach(self._vref, 3, 4, row, row + 1)
|
---|
[75] | 4218 | label.set_mnemonic_widget(self._vref)
|
---|
[241] | 4219 |
|
---|
| 4220 | self._vrefUnit = gtk.Label(xstr("label_knots"))
|
---|
[589] | 4221 | table.attach(self._vrefUnit, 4, 5, row, row + 1)
|
---|
| 4222 |
|
---|
| 4223 | row += 1
|
---|
[391] | 4224 |
|
---|
| 4225 | self._antiIceOn = gtk.CheckButton(xstr("landing_antiice"))
|
---|
| 4226 | self._antiIceOn.set_use_underline(True)
|
---|
| 4227 | self._antiIceOn.set_tooltip_text(xstr("landing_antiice_tooltip"))
|
---|
[589] | 4228 | table.attach(self._antiIceOn, 3, 5, row, row + 1)
|
---|
[75] | 4229 |
|
---|
[208] | 4230 | self.addCancelFlightButton()
|
---|
| 4231 |
|
---|
[107] | 4232 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 4233 |
|
---|
| 4234 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[75] | 4235 |
|
---|
[589] | 4236 | self._active = False
|
---|
| 4237 |
|
---|
[86] | 4238 | @property
|
---|
[97] | 4239 | def star(self):
|
---|
| 4240 | """Get the STAR or None if none entered."""
|
---|
[621] | 4241 | text = self._star.get_child().get_text()
|
---|
| 4242 | return text if self._star.get_active()!=0 and text and text!="N/A" \
|
---|
| 4243 | else None
|
---|
[97] | 4244 |
|
---|
| 4245 | @property
|
---|
| 4246 | def transition(self):
|
---|
| 4247 | """Get the transition or None if none entered."""
|
---|
[621] | 4248 | text = self._transition.get_child().get_text()
|
---|
| 4249 | return text if self._transition.get_active()!=0 and text and text!="N/A" \
|
---|
| 4250 | else None
|
---|
[97] | 4251 |
|
---|
| 4252 | @property
|
---|
| 4253 | def approachType(self):
|
---|
| 4254 | """Get the approach type."""
|
---|
| 4255 | return self._approachType.get_text()
|
---|
| 4256 |
|
---|
| 4257 | @property
|
---|
| 4258 | def runway(self):
|
---|
| 4259 | """Get the runway."""
|
---|
| 4260 | return self._runway.get_text()
|
---|
| 4261 |
|
---|
| 4262 | @property
|
---|
[86] | 4263 | def vref(self):
|
---|
| 4264 | """Return the landing reference speed."""
|
---|
| 4265 | return self._vref.get_int()
|
---|
| 4266 |
|
---|
[391] | 4267 | @property
|
---|
| 4268 | def antiIceOn(self):
|
---|
| 4269 | """Get whether the anti-ice system has been turned on."""
|
---|
| 4270 | return self._antiIceOn.get_active()
|
---|
| 4271 |
|
---|
| 4272 | @antiIceOn.setter
|
---|
| 4273 | def antiIceOn(self, value):
|
---|
| 4274 | """Set the anti-ice indicator."""
|
---|
| 4275 | self._antiIceOn.set_active(value)
|
---|
| 4276 |
|
---|
[218] | 4277 | def reset(self):
|
---|
| 4278 | """Reset the page if the wizard is reset."""
|
---|
| 4279 | super(LandingPage, self).reset()
|
---|
[241] | 4280 | self._vref.reset()
|
---|
[391] | 4281 | self._antiIceOn.set_active(False)
|
---|
[218] | 4282 | self._flightEnded = False
|
---|
[589] | 4283 | self._active = False
|
---|
[347] | 4284 |
|
---|
[75] | 4285 | def activate(self):
|
---|
| 4286 | """Called when the page is activated."""
|
---|
[589] | 4287 | self._updatingMETAR = True
|
---|
| 4288 | self._metar.get_buffer().set_text(self._wizard.arrivalMETAR, -1)
|
---|
| 4289 | self._updatingMETAR = False
|
---|
| 4290 |
|
---|
[621] | 4291 | self._star.set_active(0)
|
---|
| 4292 | self._star.set_sensitive(True)
|
---|
| 4293 |
|
---|
| 4294 | self._transition.set_active(0)
|
---|
| 4295 | self._transition.set_sensitive(True)
|
---|
[75] | 4296 |
|
---|
[717] | 4297 | if self._wizard.landingRunway is None:
|
---|
| 4298 | self._runway.set_text("")
|
---|
| 4299 | else:
|
---|
| 4300 | self._runway.set_text(self._wizard.landingRunway)
|
---|
[75] | 4301 | self._runway.set_sensitive(True)
|
---|
| 4302 |
|
---|
| 4303 | self._approachType.set_text("")
|
---|
| 4304 | self._approachType.set_sensitive(True)
|
---|
| 4305 |
|
---|
[86] | 4306 | self._vref.set_int(None)
|
---|
[75] | 4307 | self._vref.set_sensitive(True)
|
---|
| 4308 |
|
---|
[241] | 4309 | i18nSpeedUnit = self._wizard.gui.flight.getI18NSpeedUnit()
|
---|
| 4310 | speedUnit = xstr("label" + i18nSpeedUnit)
|
---|
| 4311 | self._vrefUnit.set_text(speedUnit)
|
---|
| 4312 |
|
---|
| 4313 | self._vref.set_tooltip_markup(xstr("landing_vref_tooltip" +
|
---|
| 4314 | i18nSpeedUnit))
|
---|
| 4315 |
|
---|
[75] | 4316 | self._updateForwardButton()
|
---|
| 4317 |
|
---|
[589] | 4318 | self._active = True
|
---|
| 4319 |
|
---|
[88] | 4320 | def flightEnded(self):
|
---|
| 4321 | """Called when the flight has ended."""
|
---|
[275] | 4322 | super(LandingPage, self).flightEnded()
|
---|
[88] | 4323 | self._flightEnded = True
|
---|
| 4324 | self._updateForwardButton()
|
---|
| 4325 |
|
---|
[589] | 4326 | def changeMETAR(self, metar):
|
---|
| 4327 | """Change the METAR as a result of an edit on one of the other
|
---|
| 4328 | pages."""
|
---|
| 4329 | if self._active:
|
---|
| 4330 | print "LandingPage.changeMETAR"
|
---|
| 4331 | self._updatingMETAR = True
|
---|
| 4332 | self._metar.get_buffer().set_text(metar, -1)
|
---|
| 4333 | self._updatingMETAR = False
|
---|
| 4334 |
|
---|
| 4335 | self._updateForwardButton()
|
---|
| 4336 |
|
---|
[138] | 4337 | def _updateForwardButton(self):
|
---|
[75] | 4338 | """Update the sensitivity of the forward button."""
|
---|
[88] | 4339 | sensitive = self._flightEnded and \
|
---|
[589] | 4340 | self._metar.get_text()!="" and \
|
---|
[621] | 4341 | (self.star is not None or
|
---|
| 4342 | self.transition is not None) and \
|
---|
[75] | 4343 | self._runway.get_text()!="" and \
|
---|
[86] | 4344 | self._approachType.get_text()!="" and \
|
---|
| 4345 | self.vref is not None
|
---|
[75] | 4346 | self._button.set_sensitive(sensitive)
|
---|
| 4347 |
|
---|
[138] | 4348 | def _upperChanged(self, entry):
|
---|
| 4349 | """Called for entry widgets that must be converted to uppercase."""
|
---|
| 4350 | entry.set_text(entry.get_text().upper())
|
---|
| 4351 | self._updateForwardButton()
|
---|
| 4352 |
|
---|
[621] | 4353 | def _upperChangedComboBox(self, comboBox):
|
---|
| 4354 | """Called for combo box widgets that must be converted to uppercase."""
|
---|
| 4355 | if comboBox.get_active()==-1:
|
---|
| 4356 | entry = comboBox.get_child()
|
---|
| 4357 | entry.set_text(entry.get_text().upper())
|
---|
| 4358 | self._updateForwardButton()
|
---|
| 4359 |
|
---|
[86] | 4360 | def _vrefChanged(self, widget, value):
|
---|
| 4361 | """Called when the Vref has changed."""
|
---|
| 4362 | self._updateForwardButton()
|
---|
| 4363 |
|
---|
[75] | 4364 | def _backClicked(self, button):
|
---|
| 4365 | """Called when the Back button is pressed."""
|
---|
| 4366 | self.goBack()
|
---|
[347] | 4367 |
|
---|
[75] | 4368 | def _forwardClicked(self, button):
|
---|
| 4369 | """Called when the forward button is clicked."""
|
---|
[769] | 4370 | wizard = self._wizard
|
---|
| 4371 |
|
---|
| 4372 | aircraft = wizard.gui.flight.aircraft
|
---|
[391] | 4373 | aircraft.updateVRef()
|
---|
| 4374 | aircraft.updateLandingAntiIce()
|
---|
[769] | 4375 | if wizard.gui.config.onlineGateSystem and \
|
---|
| 4376 | wizard.loggedIn and not self._completed and \
|
---|
| 4377 | wizard.bookedFlight.arrivalICAO=="LHBP" and \
|
---|
| 4378 | not wizard.entranceExam:
|
---|
| 4379 | wizard.getFleet(callback = self._fleetRetrieved, force = True)
|
---|
| 4380 | elif wizard.entranceExam:
|
---|
| 4381 | self._handleEntranceExamDone()
|
---|
[130] | 4382 | else:
|
---|
[769] | 4383 | wizard.nextPage()
|
---|
[130] | 4384 |
|
---|
| 4385 | def _fleetRetrieved(self, fleet):
|
---|
| 4386 | """Callback for the fleet retrieval."""
|
---|
[89] | 4387 | self._wizard.nextPage()
|
---|
| 4388 |
|
---|
[589] | 4389 | def _metarChanged(self, entry):
|
---|
| 4390 | """Called when the METAR has changed."""
|
---|
| 4391 | print "LandingPage.metarChanged", self._updatingMETAR
|
---|
| 4392 | if not self._updatingMETAR:
|
---|
| 4393 | self._updateForwardButton()
|
---|
| 4394 | self._wizard.metarChanged(entry.get_text(), self)
|
---|
| 4395 |
|
---|
| 4396 | def _metarInserted(self, buffer, position, text, length):
|
---|
| 4397 | """Called when new characters are inserted into the METAR.
|
---|
| 4398 |
|
---|
| 4399 | It uppercases all characters."""
|
---|
| 4400 | print "LandingPage.metarInserted", self._updatingMETAR
|
---|
| 4401 | if not self._updatingMETAR:
|
---|
| 4402 | self._updatingMETAR = True
|
---|
| 4403 |
|
---|
| 4404 | buffer.delete_text(position, length)
|
---|
| 4405 | buffer.insert_text(position, text.upper(), length)
|
---|
| 4406 |
|
---|
| 4407 | self._updatingMETAR = False
|
---|
| 4408 |
|
---|
[769] | 4409 | def _handleEntranceExamDone(self):
|
---|
| 4410 | """Handle the end of the entrance exam.
|
---|
| 4411 |
|
---|
| 4412 | If the there was a NO-GO fault, notify the user that exam is a failure
|
---|
| 4413 | and take them back to the student page. Otherwise congratulate, update
|
---|
| 4414 | the database to reflect that the exam has been taken and go back to the
|
---|
| 4415 | student page."""
|
---|
| 4416 | self._wizard.jumpPage("chkfinish")
|
---|
| 4417 |
|
---|
| 4418 | #-----------------------------------------------------------------------------
|
---|
| 4419 |
|
---|
| 4420 | class PIREPSaveHelper(object):
|
---|
| 4421 | """A helper to use for saving PIREPs."""
|
---|
| 4422 | def __init__(self, wizard):
|
---|
| 4423 | """Construct the helper."""
|
---|
| 4424 | super(PIREPSaveHelper, self).__init__()
|
---|
| 4425 |
|
---|
| 4426 | self._wizard = wizard
|
---|
| 4427 |
|
---|
| 4428 | self._lastSavePath = None
|
---|
| 4429 | self._savePIREPDialog = None
|
---|
| 4430 |
|
---|
| 4431 | def addButton(self, page):
|
---|
| 4432 | """Add a button to save the PIREP to the given page."""
|
---|
| 4433 | return page.addButton(xstr("finish_save"), sensitive = False,
|
---|
| 4434 | clicked = self._saveClicked,
|
---|
| 4435 | tooltip = xstr("finish_save_tooltip"),
|
---|
| 4436 | clickedArg = page)
|
---|
| 4437 |
|
---|
[777] | 4438 | def autoSavePIREP(self, page):
|
---|
[769] | 4439 | """Perform the automatic saving of the PIREP."""
|
---|
| 4440 | self._lastSavePath = os.path.join(self._wizard.gui.config.pirepDirectory,
|
---|
| 4441 | self._getDefaultPIREPName())
|
---|
| 4442 | self._lastSavePath = text2unicode(self._lastSavePath)
|
---|
[777] | 4443 | self._savePIREP(page, automatic = True)
|
---|
[769] | 4444 |
|
---|
| 4445 | def _getDefaultPIREPName(self):
|
---|
| 4446 | """Get the default name of the PIREP."""
|
---|
| 4447 | gui = self._wizard.gui
|
---|
| 4448 |
|
---|
| 4449 | bookedFlight = gui.bookedFlight
|
---|
| 4450 | tm = time.gmtime()
|
---|
| 4451 |
|
---|
| 4452 | pilotID = self._wizard.pilotID
|
---|
| 4453 | if pilotID: pilotID += " "
|
---|
| 4454 | return "%s%s %02d%02d %s-%s.pirep" % \
|
---|
| 4455 | (pilotID, str(bookedFlight.departureTime.date()),
|
---|
| 4456 | tm.tm_hour, tm.tm_min,
|
---|
| 4457 | bookedFlight.departureICAO, bookedFlight.arrivalICAO)
|
---|
| 4458 |
|
---|
| 4459 | def _saveClicked(self, button, page):
|
---|
| 4460 | """Called when the Save PIREP button is clicked."""
|
---|
| 4461 | gui = self._wizard.gui
|
---|
| 4462 |
|
---|
| 4463 | fileName = self._getDefaultPIREPName()
|
---|
| 4464 |
|
---|
| 4465 | dialog = self._getSaveDialog()
|
---|
| 4466 |
|
---|
| 4467 | if self._lastSavePath is None:
|
---|
| 4468 | pirepDirectory = gui.config.pirepDirectory
|
---|
| 4469 | if pirepDirectory is not None:
|
---|
| 4470 | dialog.set_current_folder(pirepDirectory)
|
---|
| 4471 | else:
|
---|
| 4472 | dialog.set_current_folder(os.path.dirname(self._lastSavePath))
|
---|
| 4473 |
|
---|
| 4474 | dialog.set_current_name(fileName)
|
---|
| 4475 | result = dialog.run()
|
---|
| 4476 | dialog.hide()
|
---|
| 4477 |
|
---|
| 4478 | if result==RESPONSETYPE_OK:
|
---|
| 4479 | self._lastSavePath = text2unicode(dialog.get_filename())
|
---|
| 4480 | self._savePIREP(page)
|
---|
| 4481 |
|
---|
| 4482 | def _savePIREP(self, page, automatic = False):
|
---|
| 4483 | """Perform the saving of the PIREP."""
|
---|
| 4484 |
|
---|
| 4485 | gui = self._wizard.gui
|
---|
| 4486 |
|
---|
| 4487 | if automatic:
|
---|
| 4488 | gui.beginBusy(xstr("finish_autosave_busy"))
|
---|
| 4489 |
|
---|
| 4490 | pirep = PIREP(gui.flight)
|
---|
| 4491 | error = pirep.save(self._lastSavePath)
|
---|
| 4492 |
|
---|
| 4493 | if automatic:
|
---|
| 4494 | gui.endBusy()
|
---|
| 4495 |
|
---|
| 4496 | if error:
|
---|
| 4497 | type = MESSAGETYPE_ERROR
|
---|
| 4498 | message = xstr("finish_save_failed")
|
---|
| 4499 | secondary = xstr("finish_save_failed_sec") % (text2unicode(error),)
|
---|
| 4500 | else:
|
---|
| 4501 | type = MESSAGETYPE_INFO
|
---|
| 4502 | message = xstr("finish_save_done")
|
---|
| 4503 | if automatic:
|
---|
| 4504 | secondary = xstr("finish_save_done_sec") % (self._lastSavePath,)
|
---|
| 4505 | else:
|
---|
| 4506 | secondary = None
|
---|
| 4507 | page.setPIREPSaved()
|
---|
| 4508 |
|
---|
| 4509 | dialog = gtk.MessageDialog(parent = gui.mainWindow,
|
---|
| 4510 | type = type, message_format = message)
|
---|
| 4511 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 4512 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 4513 | if secondary is not None:
|
---|
| 4514 | dialog.format_secondary_markup(secondary)
|
---|
| 4515 |
|
---|
| 4516 | dialog.run()
|
---|
| 4517 | dialog.hide()
|
---|
| 4518 |
|
---|
| 4519 | def _getSaveDialog(self):
|
---|
| 4520 | """Get the PIREP saving dialog.
|
---|
| 4521 |
|
---|
| 4522 | If it does not exist yet, create it."""
|
---|
| 4523 | if self._savePIREPDialog is None:
|
---|
| 4524 | gui = self._wizard.gui
|
---|
| 4525 | dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
| 4526 | xstr("finish_save_title"),
|
---|
| 4527 | action = FILE_CHOOSER_ACTION_SAVE,
|
---|
| 4528 | buttons = (gtk.STOCK_CANCEL,
|
---|
| 4529 | RESPONSETYPE_CANCEL,
|
---|
| 4530 | gtk.STOCK_OK, RESPONSETYPE_OK),
|
---|
| 4531 | parent = gui.mainWindow)
|
---|
| 4532 | dialog.set_modal(True)
|
---|
| 4533 | dialog.set_do_overwrite_confirmation(True)
|
---|
| 4534 |
|
---|
| 4535 | filter = gtk.FileFilter()
|
---|
| 4536 | filter.set_name(xstr("file_filter_pireps"))
|
---|
| 4537 | filter.add_pattern("*.pirep")
|
---|
| 4538 | dialog.add_filter(filter)
|
---|
| 4539 |
|
---|
| 4540 | filter = gtk.FileFilter()
|
---|
| 4541 | filter.set_name(xstr("file_filter_all"))
|
---|
| 4542 | filter.add_pattern("*.*")
|
---|
| 4543 | dialog.add_filter(filter)
|
---|
| 4544 |
|
---|
| 4545 | self._savePIREPDialog = dialog
|
---|
| 4546 |
|
---|
| 4547 | return self._savePIREPDialog
|
---|
| 4548 |
|
---|
[89] | 4549 | #-----------------------------------------------------------------------------
|
---|
| 4550 |
|
---|
| 4551 | class FinishPage(Page):
|
---|
| 4552 | """Flight finish page."""
|
---|
[769] | 4553 | def __init__(self, wizard, saveHelper):
|
---|
[89] | 4554 | """Construct the finish page."""
|
---|
[564] | 4555 | help = xstr("finish_help") + xstr("finish_help_goodtime")
|
---|
[754] | 4556 | super(FinishPage, self).__init__(wizard, "finish",
|
---|
| 4557 | xstr("finish_title"), help)
|
---|
[347] | 4558 |
|
---|
[89] | 4559 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 4560 | xscale = 0.0, yscale = 0.0)
|
---|
| 4561 |
|
---|
[556] | 4562 | table = gtk.Table(10, 2)
|
---|
[89] | 4563 | table.set_row_spacings(4)
|
---|
| 4564 | table.set_col_spacings(16)
|
---|
[96] | 4565 | table.set_homogeneous(False)
|
---|
[89] | 4566 | alignment.add(table)
|
---|
| 4567 | self.setMainWidget(alignment)
|
---|
| 4568 |
|
---|
[555] | 4569 | row = 0
|
---|
| 4570 |
|
---|
[89] | 4571 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 4572 | label = gtk.Label(xstr("finish_rating"))
|
---|
[89] | 4573 | labelAlignment.add(label)
|
---|
[555] | 4574 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 4575 |
|
---|
| 4576 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4577 | self._flightRating = gtk.Label()
|
---|
[154] | 4578 | self._flightRating.set_width_chars(8)
|
---|
[89] | 4579 | self._flightRating.set_alignment(0.0, 0.5)
|
---|
| 4580 | self._flightRating.set_use_markup(True)
|
---|
| 4581 | labelAlignment.add(self._flightRating)
|
---|
[555] | 4582 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 4583 |
|
---|
| 4584 | row += 1
|
---|
| 4585 |
|
---|
| 4586 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 4587 | label = gtk.Label(xstr("finish_dep_time"))
|
---|
| 4588 | labelAlignment.add(label)
|
---|
| 4589 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
| 4590 |
|
---|
| 4591 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4592 | self._depTime = gtk.Label()
|
---|
[556] | 4593 | self._depTime.set_width_chars(13)
|
---|
[555] | 4594 | self._depTime.set_alignment(0.0, 0.5)
|
---|
| 4595 | self._depTime.set_use_markup(True)
|
---|
[558] | 4596 | self._depTime.set_tooltip_markup(xstr("finish_dep_time_tooltip"))
|
---|
[555] | 4597 | labelAlignment.add(self._depTime)
|
---|
| 4598 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 4599 |
|
---|
| 4600 | row += 1
|
---|
[89] | 4601 |
|
---|
| 4602 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 4603 | label = gtk.Label(xstr("finish_flight_time"))
|
---|
[89] | 4604 | labelAlignment.add(label)
|
---|
[555] | 4605 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 4606 |
|
---|
| 4607 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4608 | self._flightTime = gtk.Label()
|
---|
| 4609 | self._flightTime.set_width_chars(10)
|
---|
| 4610 | self._flightTime.set_alignment(0.0, 0.5)
|
---|
| 4611 | self._flightTime.set_use_markup(True)
|
---|
| 4612 | labelAlignment.add(self._flightTime)
|
---|
[555] | 4613 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 4614 |
|
---|
| 4615 | row += 1
|
---|
[89] | 4616 |
|
---|
| 4617 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 4618 | label = gtk.Label(xstr("finish_block_time"))
|
---|
[89] | 4619 | labelAlignment.add(label)
|
---|
[555] | 4620 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 4621 |
|
---|
| 4622 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4623 | self._blockTime = gtk.Label()
|
---|
| 4624 | self._blockTime.set_width_chars(10)
|
---|
| 4625 | self._blockTime.set_alignment(0.0, 0.5)
|
---|
| 4626 | self._blockTime.set_use_markup(True)
|
---|
| 4627 | labelAlignment.add(self._blockTime)
|
---|
[555] | 4628 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 4629 |
|
---|
| 4630 | row += 1
|
---|
| 4631 |
|
---|
| 4632 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 4633 | label = gtk.Label(xstr("finish_arr_time"))
|
---|
| 4634 | labelAlignment.add(label)
|
---|
| 4635 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
| 4636 |
|
---|
| 4637 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4638 | self._arrTime = gtk.Label()
|
---|
[556] | 4639 | self._arrTime.set_width_chars(13)
|
---|
[555] | 4640 | self._arrTime.set_alignment(0.0, 0.5)
|
---|
| 4641 | self._arrTime.set_use_markup(True)
|
---|
[558] | 4642 | self._arrTime.set_tooltip_markup(xstr("finish_arr_time_tooltip"))
|
---|
[555] | 4643 | labelAlignment.add(self._arrTime)
|
---|
| 4644 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 4645 |
|
---|
| 4646 | row += 1
|
---|
[89] | 4647 |
|
---|
| 4648 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 4649 | label = gtk.Label(xstr("finish_distance"))
|
---|
[89] | 4650 | labelAlignment.add(label)
|
---|
[555] | 4651 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 4652 |
|
---|
| 4653 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4654 | self._distanceFlown = gtk.Label()
|
---|
| 4655 | self._distanceFlown.set_width_chars(10)
|
---|
| 4656 | self._distanceFlown.set_alignment(0.0, 0.5)
|
---|
| 4657 | self._distanceFlown.set_use_markup(True)
|
---|
| 4658 | labelAlignment.add(self._distanceFlown)
|
---|
[555] | 4659 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 4660 |
|
---|
| 4661 | row += 1
|
---|
[347] | 4662 |
|
---|
[89] | 4663 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 4664 | label = gtk.Label(xstr("finish_fuel"))
|
---|
[89] | 4665 | labelAlignment.add(label)
|
---|
[555] | 4666 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 4667 |
|
---|
| 4668 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4669 | self._fuelUsed = gtk.Label()
|
---|
| 4670 | self._fuelUsed.set_width_chars(10)
|
---|
| 4671 | self._fuelUsed.set_alignment(0.0, 0.5)
|
---|
| 4672 | self._fuelUsed.set_use_markup(True)
|
---|
| 4673 | labelAlignment.add(self._fuelUsed)
|
---|
[555] | 4674 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 4675 |
|
---|
| 4676 | row += 1
|
---|
[89] | 4677 |
|
---|
[107] | 4678 | labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0,
|
---|
| 4679 | yalign = 0.5, yscale = 0.0)
|
---|
| 4680 | label = gtk.Label(xstr("finish_type"))
|
---|
[96] | 4681 | label.set_use_underline(True)
|
---|
| 4682 | labelAlignment.add(label)
|
---|
[555] | 4683 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[96] | 4684 |
|
---|
[836] | 4685 | self._flightType = createFlightTypeComboBox()
|
---|
[107] | 4686 | self._flightType.set_tooltip_text(xstr("finish_type_tooltip"))
|
---|
[96] | 4687 | self._flightType.set_active(0)
|
---|
| 4688 | self._flightType.connect("changed", self._flightTypeChanged)
|
---|
| 4689 | flightTypeAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4690 | flightTypeAlignment.add(self._flightType)
|
---|
[555] | 4691 | table.attach(flightTypeAlignment, 1, 2, row, row+1)
|
---|
[347] | 4692 | label.set_mnemonic_widget(self._flightType)
|
---|
[96] | 4693 |
|
---|
[555] | 4694 | row += 1
|
---|
| 4695 |
|
---|
[107] | 4696 | self._onlineFlight = gtk.CheckButton(xstr("finish_online"))
|
---|
[96] | 4697 | self._onlineFlight.set_use_underline(True)
|
---|
[107] | 4698 | self._onlineFlight.set_tooltip_text(xstr("finish_online_tooltip"))
|
---|
[96] | 4699 | onlineFlightAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 4700 | onlineFlightAlignment.add(self._onlineFlight)
|
---|
[555] | 4701 | table.attach(onlineFlightAlignment, 1, 2, row, row + 1)
|
---|
| 4702 |
|
---|
| 4703 | row += 1
|
---|
[96] | 4704 |
|
---|
[130] | 4705 | labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0,
|
---|
| 4706 | yalign = 0.5, yscale = 0.0)
|
---|
| 4707 | self._gateLabel = gtk.Label(xstr("finish_gate"))
|
---|
| 4708 | self._gateLabel.set_use_underline(True)
|
---|
| 4709 | labelAlignment.add(self._gateLabel)
|
---|
[555] | 4710 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[130] | 4711 |
|
---|
| 4712 | self._gatesModel = gtk.ListStore(str)
|
---|
| 4713 |
|
---|
| 4714 | self._gate = gtk.ComboBox(model = self._gatesModel)
|
---|
| 4715 | renderer = gtk.CellRendererText()
|
---|
| 4716 | self._gate.pack_start(renderer, True)
|
---|
| 4717 | self._gate.add_attribute(renderer, "text", 0)
|
---|
| 4718 | self._gate.set_tooltip_text(xstr("finish_gate_tooltip"))
|
---|
[347] | 4719 | self._gate.connect("changed", self._gateChanged)
|
---|
[130] | 4720 | gateAlignment = gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 4721 | gateAlignment.add(self._gate)
|
---|
[555] | 4722 | table.attach(gateAlignment, 1, 2, row, row+1)
|
---|
[130] | 4723 | self._gateLabel.set_mnemonic_widget(self._gate)
|
---|
| 4724 |
|
---|
[208] | 4725 | self.addButton(xstr("finish_newFlight"),
|
---|
| 4726 | sensitive = True,
|
---|
| 4727 | clicked = self._newFlightClicked,
|
---|
| 4728 | tooltip = xstr("finish_newFlight_tooltip"),
|
---|
| 4729 | padding = 16)
|
---|
| 4730 |
|
---|
[107] | 4731 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[94] | 4732 |
|
---|
[769] | 4733 | self._saveHelper = saveHelper
|
---|
| 4734 | self._saveButton = saveHelper.addButton(self)
|
---|
[208] | 4735 |
|
---|
[555] | 4736 | self._tooBigTimeDifference = False
|
---|
| 4737 | self._deferredAutoSave = False
|
---|
[208] | 4738 | self._pirepSaved = False
|
---|
| 4739 | self._pirepSent = False
|
---|
[347] | 4740 |
|
---|
[151] | 4741 | self._sendButton = self.addButton(xstr("sendPIREP"), default = True,
|
---|
[107] | 4742 | sensitive = False,
|
---|
| 4743 | clicked = self._sendClicked,
|
---|
[151] | 4744 | tooltip = xstr("sendPIREP_tooltip"))
|
---|
[347] | 4745 |
|
---|
[555] | 4746 | # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 10*60.0)
|
---|
| 4747 | # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 20*60.0)
|
---|
| 4748 | # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 0*60.0)
|
---|
| 4749 | # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), (23*60.0+50)*60.0)
|
---|
| 4750 | # self._formatTime(datetime.datetime(1970, 1, 1, 1, 0), (1*60.0+5)*60.0)
|
---|
| 4751 | # self._formatTime(datetime.datetime(1970, 1, 1, 1, 0), (0*60.0+50)*60.0)
|
---|
| 4752 | # self._formatTime(datetime.datetime(1970, 1, 1, 23, 55), (0*60.0+5)*60.0)
|
---|
| 4753 | # self._formatTime(datetime.datetime(1970, 1, 1, 23, 55), (23*60.0+45)*60.0)
|
---|
| 4754 |
|
---|
[97] | 4755 | @property
|
---|
| 4756 | def flightType(self):
|
---|
| 4757 | """Get the flight type."""
|
---|
| 4758 | index = self._flightType.get_active()
|
---|
| 4759 | return None if index<0 else self._flightType.get_model()[index][1]
|
---|
| 4760 |
|
---|
| 4761 | @property
|
---|
| 4762 | def online(self):
|
---|
| 4763 | """Get whether the flight was an online flight or not."""
|
---|
| 4764 | return self._onlineFlight.get_active()
|
---|
[89] | 4765 |
|
---|
| 4766 | def activate(self):
|
---|
| 4767 | """Activate the page."""
|
---|
[555] | 4768 | self._deferredAutoSave = False
|
---|
[208] | 4769 | self._pirepSaved = False
|
---|
| 4770 | self._pirepSent = False
|
---|
| 4771 |
|
---|
[89] | 4772 | flight = self._wizard.gui._flight
|
---|
| 4773 | rating = flight.logger.getRating()
|
---|
| 4774 | if rating<0:
|
---|
| 4775 | self._flightRating.set_markup('<b><span foreground="red">NO GO</span></b>')
|
---|
| 4776 | else:
|
---|
| 4777 | self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
|
---|
| 4778 |
|
---|
| 4779 | flightLength = flight.flightTimeEnd - flight.flightTimeStart
|
---|
| 4780 | self._flightTime.set_markup("<b>%s</b>" % \
|
---|
| 4781 | (util.getTimeIntervalString(flightLength),))
|
---|
[347] | 4782 |
|
---|
[89] | 4783 | blockLength = flight.blockTimeEnd - flight.blockTimeStart
|
---|
| 4784 | self._blockTime.set_markup("<b>%s</b>" % \
|
---|
| 4785 | (util.getTimeIntervalString(blockLength),))
|
---|
| 4786 |
|
---|
| 4787 | self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
|
---|
| 4788 | (flight.flownDistance,))
|
---|
[347] | 4789 |
|
---|
[89] | 4790 | self._fuelUsed.set_markup("<b>%.0f kg</b>" % \
|
---|
[102] | 4791 | (flight.startFuel - flight.endFuel,))
|
---|
[64] | 4792 |
|
---|
[96] | 4793 | self._flightType.set_active(-1)
|
---|
[215] | 4794 | self._onlineFlight.set_active(self._wizard.loggedIn)
|
---|
[96] | 4795 |
|
---|
[130] | 4796 | self._gatesModel.clear()
|
---|
[136] | 4797 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 4798 | self._wizard.loggedIn and \
|
---|
[184] | 4799 | self._wizard.bookedFlight.arrivalICAO=="LHBP" and \
|
---|
| 4800 | not self._wizard.entranceExam:
|
---|
[619] | 4801 | occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
| 4802 | for gate in lhbpGates.gates:
|
---|
| 4803 | if gate.isAvailable(lhbpGates, occupiedGateNumbers):
|
---|
| 4804 | self._gatesModel.append([gate.number])
|
---|
[130] | 4805 | self._gateLabel.set_sensitive(True)
|
---|
| 4806 | self._gate.set_sensitive(True)
|
---|
| 4807 | self._gate.set_active(-1)
|
---|
| 4808 | else:
|
---|
| 4809 | self._gateLabel.set_sensitive(False)
|
---|
| 4810 | self._gate.set_sensitive(False)
|
---|
| 4811 |
|
---|
[564] | 4812 | self._updateTimes()
|
---|
[555] | 4813 |
|
---|
| 4814 | def updateButtons(self):
|
---|
[130] | 4815 | """Update the sensitivity state of the buttons."""
|
---|
[555] | 4816 | gui = self._wizard.gui
|
---|
[607] | 4817 | faultsExplained = gui.faultsFullyExplained
|
---|
| 4818 | timesCorrect = self.flightType is None or \
|
---|
| 4819 | not self._tooBigTimeDifference or \
|
---|
| 4820 | gui.hasComments or gui.hasDelayCode
|
---|
[625] | 4821 | sensitive = gui.flight is not None and \
|
---|
| 4822 | gui.flight.stage==const.STAGE_END and \
|
---|
| 4823 | self._flightType.get_active()>=0 and \
|
---|
[130] | 4824 | (self._gatesModel.get_iter_first() is None or
|
---|
[555] | 4825 | self._gate.get_active()>=0) and \
|
---|
[607] | 4826 | faultsExplained and timesCorrect
|
---|
| 4827 |
|
---|
| 4828 | self._updateHelp(faultsExplained, timesCorrect)
|
---|
[347] | 4829 |
|
---|
[393] | 4830 | wasSensitive = self._saveButton.get_sensitive()
|
---|
| 4831 |
|
---|
[555] | 4832 | if gui.config.pirepAutoSave and sensitive and not wasSensitive:
|
---|
| 4833 | if gui.isWizardActive():
|
---|
[777] | 4834 | self._saveHelper.autoSavePIREP(self)
|
---|
[555] | 4835 | else:
|
---|
| 4836 | self._deferredAutoSave = True
|
---|
| 4837 |
|
---|
| 4838 | if not sensitive:
|
---|
| 4839 | self._deferredAutoSave = False
|
---|
[393] | 4840 |
|
---|
[151] | 4841 | self._saveButton.set_sensitive(sensitive)
|
---|
[184] | 4842 | self._sendButton.set_sensitive(sensitive and
|
---|
| 4843 | self._wizard.bookedFlight.id is not None)
|
---|
[130] | 4844 |
|
---|
[555] | 4845 | def grabDefault(self):
|
---|
| 4846 | """If the page has a default button, make it the default one."""
|
---|
| 4847 | super(FinishPage, self).grabDefault()
|
---|
| 4848 | if self._deferredAutoSave:
|
---|
[777] | 4849 | self._saveHelper.autoSavePIREP(self)
|
---|
[555] | 4850 | self._deferredAutoSave = False
|
---|
| 4851 |
|
---|
[769] | 4852 | def setPIREPSaved(self):
|
---|
| 4853 | """Mark the PIREP as saved."""
|
---|
| 4854 | self._pirepSaved = True
|
---|
[555] | 4855 |
|
---|
| 4856 | def _backClicked(self, button):
|
---|
| 4857 | """Called when the Back button is pressed."""
|
---|
| 4858 | self.goBack()
|
---|
| 4859 |
|
---|
[96] | 4860 | def _flightTypeChanged(self, comboBox):
|
---|
| 4861 | """Called when the flight type has changed."""
|
---|
[564] | 4862 | self._updateTimes()
|
---|
[130] | 4863 |
|
---|
| 4864 | def _gateChanged(self, comboBox):
|
---|
| 4865 | """Called when the arrival gate has changed."""
|
---|
[555] | 4866 | self.updateButtons()
|
---|
[97] | 4867 |
|
---|
[208] | 4868 | def _newFlightClicked(self, button):
|
---|
| 4869 | """Called when the new flight button is clicked."""
|
---|
| 4870 | gui = self._wizard.gui
|
---|
| 4871 | if not self._pirepSent and not self._pirepSaved:
|
---|
| 4872 | dialog = gtk.MessageDialog(parent = gui.mainWindow,
|
---|
| 4873 | type = MESSAGETYPE_QUESTION,
|
---|
| 4874 | message_format = xstr("finish_newFlight_question"))
|
---|
| 4875 |
|
---|
| 4876 | dialog.add_button(xstr("button_no"), RESPONSETYPE_NO)
|
---|
| 4877 | dialog.add_button(xstr("button_yes"), RESPONSETYPE_YES)
|
---|
| 4878 |
|
---|
| 4879 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 4880 | result = dialog.run()
|
---|
| 4881 | dialog.hide()
|
---|
| 4882 | if result!=RESPONSETYPE_YES:
|
---|
| 4883 | return
|
---|
[347] | 4884 |
|
---|
[208] | 4885 | gui.reset()
|
---|
| 4886 |
|
---|
[97] | 4887 | def _sendClicked(self, button):
|
---|
| 4888 | """Called when the Send button is clicked."""
|
---|
[262] | 4889 | pirep = PIREP(self._wizard.gui.flight)
|
---|
[151] | 4890 | self._wizard.gui.sendPIREP(pirep,
|
---|
| 4891 | callback = self._handlePIREPSent)
|
---|
[97] | 4892 |
|
---|
| 4893 | def _handlePIREPSent(self, returned, result):
|
---|
| 4894 | """Callback for the PIREP sending result."""
|
---|
[208] | 4895 | self._pirepSent = returned and result.success
|
---|
[184] | 4896 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 4897 | self._wizard.loggedIn and not self._wizard.entranceExam and \
|
---|
[184] | 4898 | returned and result.success:
|
---|
[130] | 4899 | bookedFlight = self._wizard.bookedFlight
|
---|
| 4900 | if bookedFlight.arrivalICAO=="LHBP":
|
---|
[347] | 4901 | iter = self._gate.get_active_iter()
|
---|
[130] | 4902 | gateNumber = None if iter is None \
|
---|
| 4903 | else self._gatesModel.get_value(iter, 0)
|
---|
[347] | 4904 |
|
---|
[130] | 4905 | status = const.PLANE_PARKING if gateNumber is None \
|
---|
| 4906 | else const.PLANE_HOME
|
---|
| 4907 | else:
|
---|
| 4908 | gateNumber = None
|
---|
| 4909 | status = const.PLANE_AWAY
|
---|
| 4910 |
|
---|
| 4911 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 4912 | bookedFlight.tailNumber,
|
---|
| 4913 | status, gateNumber = gateNumber)
|
---|
| 4914 |
|
---|
| 4915 | def _planeUpdated(self, success):
|
---|
| 4916 | """Callback for the plane updating."""
|
---|
| 4917 | pass
|
---|
[347] | 4918 |
|
---|
[564] | 4919 | def _formatTime(self, scheduledTime, realTimestamp, (warning, error)):
|
---|
[555] | 4920 | """Format the departure or arrival time based on the given data as a
|
---|
[564] | 4921 | markup for a label."""
|
---|
[555] | 4922 | realTime = time.gmtime(realTimestamp)
|
---|
| 4923 |
|
---|
[564] | 4924 | if warning:
|
---|
| 4925 | colour = "red" if error else "orange"
|
---|
[555] | 4926 | markupBegin = '<span foreground="%s">' % (colour,)
|
---|
| 4927 | markupEnd = '</span>'
|
---|
| 4928 | else:
|
---|
| 4929 | markupBegin = markupEnd = ""
|
---|
| 4930 |
|
---|
| 4931 | markup = "<b>%s%02d:%02d [%02d:%02d]%s</b>" % \
|
---|
| 4932 | (markupBegin,
|
---|
| 4933 | realTime.tm_hour, realTime.tm_min,
|
---|
| 4934 | scheduledTime.hour, scheduledTime.minute,
|
---|
| 4935 | markupEnd)
|
---|
| 4936 |
|
---|
[564] | 4937 | return markup
|
---|
| 4938 |
|
---|
| 4939 | def _updateTimes(self):
|
---|
| 4940 | """Format the flight times and the help text according to the flight
|
---|
| 4941 | type.
|
---|
| 4942 |
|
---|
| 4943 | The buttons are also updated.
|
---|
| 4944 | """
|
---|
| 4945 | flight = self._wizard.gui._flight
|
---|
| 4946 | bookedFlight = flight.bookedFlight
|
---|
| 4947 |
|
---|
| 4948 | (departureWarning, departureError) = flight.blockTimeStartWrong
|
---|
| 4949 | (arrivalWarning, arrivalError) = flight.blockTimeEndWrong
|
---|
| 4950 |
|
---|
| 4951 | if self.flightType==const.FLIGHTTYPE_VIP:
|
---|
| 4952 | departureError = arrivalError = False
|
---|
| 4953 |
|
---|
| 4954 | self._tooBigTimeDifference = departureError or arrivalError
|
---|
| 4955 |
|
---|
| 4956 | self._depTime.set_markup(self._formatTime(bookedFlight.departureTime,
|
---|
| 4957 | flight.blockTimeStart,
|
---|
| 4958 | (departureWarning,
|
---|
| 4959 | departureError)))
|
---|
| 4960 |
|
---|
| 4961 | self._arrTime.set_markup(self._formatTime(bookedFlight.arrivalTime,
|
---|
| 4962 | flight.blockTimeEnd,
|
---|
| 4963 | (arrivalWarning,
|
---|
| 4964 | arrivalError)))
|
---|
| 4965 |
|
---|
| 4966 | self.updateButtons()
|
---|
[555] | 4967 |
|
---|
[607] | 4968 | def _updateHelp(self, faultsExplained, timesCorrect):
|
---|
| 4969 | """Update the help text according to the actual situation."""
|
---|
| 4970 | if not faultsExplained:
|
---|
| 4971 | self.setHelp(xstr("finish_help") + xstr("finish_help_faults"))
|
---|
| 4972 | elif not timesCorrect:
|
---|
| 4973 | self.setHelp(xstr("finish_help") + xstr("finish_help_wrongtime"))
|
---|
| 4974 | else:
|
---|
| 4975 | self.setHelp(xstr("finish_help") + xstr("finish_help_goodtime"))
|
---|
| 4976 |
|
---|
| 4977 |
|
---|
[64] | 4978 | #-----------------------------------------------------------------------------
|
---|
| 4979 |
|
---|
[769] | 4980 | class CheckFlightFinishPage(Page):
|
---|
| 4981 | """Finish page for a check flight."""
|
---|
| 4982 | def __init__(self, wizard, saveHelper):
|
---|
| 4983 | """Construct the check flight finish page."""
|
---|
| 4984 | super(CheckFlightFinishPage, self).__init__(wizard,
|
---|
| 4985 | "chkfinish",
|
---|
| 4986 | xstr("chkfinish_title"),
|
---|
| 4987 | "")
|
---|
| 4988 |
|
---|
| 4989 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 4990 | xscale = 1.0, yscale = 1.0)
|
---|
| 4991 | self._label = gtk.Label()
|
---|
| 4992 | alignment.add(self._label)
|
---|
| 4993 |
|
---|
| 4994 | self.setMainWidget(alignment)
|
---|
| 4995 |
|
---|
| 4996 | self._saveHelper = saveHelper
|
---|
| 4997 | self._saveButton = saveHelper.addButton(self)
|
---|
| 4998 |
|
---|
| 4999 | self._button = self.addNextButton(sensitive = False,
|
---|
| 5000 | clicked = self._forwardClicked)
|
---|
| 5001 |
|
---|
| 5002 | def activate(self):
|
---|
| 5003 | """Activate the page."""
|
---|
| 5004 | wizard = self._wizard
|
---|
| 5005 | loginResult = wizard.loginResult
|
---|
| 5006 | gui = wizard.gui
|
---|
| 5007 | rating = gui.flight.logger.getRating()
|
---|
| 5008 |
|
---|
| 5009 | if rating>=0:
|
---|
| 5010 | loginResult.checkFlightStatus = True
|
---|
| 5011 |
|
---|
| 5012 | firstOfficer = \
|
---|
| 5013 | loginResult.entryExamPassed and loginResult.checkFlightStatus
|
---|
| 5014 |
|
---|
| 5015 | if firstOfficer:
|
---|
| 5016 | loginResult.rank = "FO"
|
---|
| 5017 |
|
---|
| 5018 | if rating<0:
|
---|
| 5019 | mainMessage = xstr("chkfinish_failed")
|
---|
| 5020 | else:
|
---|
| 5021 | mainMessage = xstr("chkfinish_passed_begin")
|
---|
| 5022 | if firstOfficer:
|
---|
| 5023 | mainMessage += xstr("chkfinish_passed_fo")
|
---|
| 5024 | mainMessage += xstr("chkfinish_passed_end")
|
---|
| 5025 |
|
---|
| 5026 | if firstOfficer:
|
---|
| 5027 | nextMessage = xstr("chkfinish_next")
|
---|
| 5028 | else:
|
---|
| 5029 | nextMessage = xstr("chkfinish_next_student_begin")
|
---|
| 5030 | if not loginResult.entryExamPassed and \
|
---|
| 5031 | not loginResult.checkFlightStatus:
|
---|
| 5032 | nextMessage += xstr("chkfinish_next_student_nothing")
|
---|
| 5033 | elif loginResult.entryExamPassed and \
|
---|
| 5034 | not loginResult.checkFlightStatus:
|
---|
| 5035 | nextMessage += xstr("chkfinish_next_student_no_flight")
|
---|
| 5036 | elif not loginResult.entryExamPassed and \
|
---|
| 5037 | loginResult.checkFlightStatus:
|
---|
| 5038 | nextMessage += xstr("chkfinish_next_student_no_exam")
|
---|
| 5039 |
|
---|
| 5040 | self._label.set_text(mainMessage +
|
---|
| 5041 | xstr("chkfinish_savepirep") +
|
---|
| 5042 | nextMessage)
|
---|
| 5043 | self._label.set_use_markup(True)
|
---|
| 5044 | self._label.set_alignment(0.5, 0.0)
|
---|
| 5045 |
|
---|
| 5046 | self._saveButton.set_sensitive(True)
|
---|
| 5047 | self._button.set_sensitive(True)
|
---|
| 5048 |
|
---|
| 5049 | def _forwardClicked(self, button):
|
---|
| 5050 | """Jump to the student page if there are some tasks to do,
|
---|
| 5051 | or to the flight selection page, if the pilot is allowed to perform
|
---|
| 5052 | MAVA flights."""
|
---|
| 5053 | wizard = self._wizard
|
---|
| 5054 | gui = wizard.gui
|
---|
| 5055 |
|
---|
| 5056 | loginResult = wizard.loginResult
|
---|
| 5057 | if loginResult.checkFlightStatus:
|
---|
| 5058 | gui.beginBusy(xstr("chkfinish_updateweb_busy"))
|
---|
| 5059 | gui.webHandler.setCheckFlightPassed(self._checkFlightPassedSetCallback,
|
---|
| 5060 | wizard.checkFlightAircraftType)
|
---|
| 5061 | else:
|
---|
| 5062 | self._resetGUI()
|
---|
| 5063 |
|
---|
| 5064 | def _checkFlightPassedSetCallback(self, returned, result):
|
---|
| 5065 | """Called when the check flight status has been set."""
|
---|
| 5066 | gobject.idle_add(self._checkFlightPassedSet, returned, result)
|
---|
| 5067 |
|
---|
| 5068 | def _checkFlightPassedSet(self, returned, result):
|
---|
| 5069 | """Handle the result of an attempt to set the check flight status."""
|
---|
| 5070 | gui = self._wizard.gui
|
---|
| 5071 |
|
---|
| 5072 | gui.endBusy()
|
---|
| 5073 |
|
---|
| 5074 | if returned:
|
---|
| 5075 | self._resetGUI()
|
---|
| 5076 | else:
|
---|
| 5077 | dialog = gtk.MessageDialog(parent = gui.mainWindow,
|
---|
| 5078 | type = MESSAGETYPE_ERROR,
|
---|
| 5079 | message_format =
|
---|
| 5080 | xstr("chkfinish_passedset_failed"))
|
---|
| 5081 | dialog.set_title(WINDOW_TITLE_BASE + " - " +
|
---|
| 5082 | xstr("chkfinish_passedset_failed_title"))
|
---|
| 5083 | dialog.format_secondary_markup(xstr("chkfinish_passedset_failed_secondary"))
|
---|
| 5084 |
|
---|
| 5085 | dialog.add_button(xstr("button_ok"), 0)
|
---|
| 5086 |
|
---|
| 5087 | dialog.run()
|
---|
| 5088 | dialog.hide()
|
---|
| 5089 |
|
---|
| 5090 | def _resetGUI(self):
|
---|
| 5091 | """Reset the GUI."""
|
---|
| 5092 | gui = self._wizard.gui
|
---|
| 5093 | gui.reset()
|
---|
| 5094 |
|
---|
| 5095 | #-----------------------------------------------------------------------------
|
---|
| 5096 |
|
---|
[42] | 5097 | class Wizard(gtk.VBox):
|
---|
| 5098 | """The flight wizard."""
|
---|
| 5099 | def __init__(self, gui):
|
---|
| 5100 | """Construct the wizard."""
|
---|
| 5101 | super(Wizard, self).__init__()
|
---|
| 5102 |
|
---|
| 5103 | self.gui = gui
|
---|
| 5104 |
|
---|
| 5105 | self._pages = []
|
---|
| 5106 | self._currentPage = None
|
---|
[184] | 5107 |
|
---|
| 5108 | self._loginPage = LoginPage(self)
|
---|
| 5109 | self._pages.append(self._loginPage)
|
---|
[821] | 5110 | self._flightSelectionPage = FlightSelectionPage(self)
|
---|
| 5111 | self._pages.append(self._flightSelectionPage)
|
---|
[51] | 5112 | self._pages.append(GateSelectionPage(self))
|
---|
[753] | 5113 | self._pages.append(RegisterPage(self))
|
---|
[769] | 5114 | self._studentPage = StudentPage(self)
|
---|
| 5115 | self._pages.append(self._studentPage)
|
---|
[51] | 5116 | self._pages.append(ConnectPage(self))
|
---|
[347] | 5117 | self._payloadPage = PayloadPage(self)
|
---|
[84] | 5118 | self._pages.append(self._payloadPage)
|
---|
[117] | 5119 | self._payloadIndex = len(self._pages)
|
---|
[61] | 5120 | self._pages.append(TimePage(self))
|
---|
[84] | 5121 | self._routePage = RoutePage(self)
|
---|
| 5122 | self._pages.append(self._routePage)
|
---|
[687] | 5123 | self._simBriefSetupPage = SimBriefSetupPage(self)
|
---|
| 5124 | self._pages.append(self._simBriefSetupPage)
|
---|
| 5125 | self._simBriefingPage = SimBriefingPage(self)
|
---|
| 5126 | self._pages.append(self._simBriefingPage)
|
---|
| 5127 | self._pages.append(FuelPage(self))
|
---|
[97] | 5128 | self._departureBriefingPage = BriefingPage(self, True)
|
---|
| 5129 | self._pages.append(self._departureBriefingPage)
|
---|
| 5130 | self._arrivalBriefingPage = BriefingPage(self, False)
|
---|
| 5131 | self._pages.append(self._arrivalBriefingPage)
|
---|
[117] | 5132 | self._arrivalBriefingIndex = len(self._pages)
|
---|
[347] | 5133 | self._takeoffPage = TakeoffPage(self)
|
---|
[84] | 5134 | self._pages.append(self._takeoffPage)
|
---|
[383] | 5135 | self._cruisePage = CruisePage(self)
|
---|
| 5136 | self._pages.append(self._cruisePage)
|
---|
[347] | 5137 | self._landingPage = LandingPage(self)
|
---|
[86] | 5138 | self._pages.append(self._landingPage)
|
---|
[769] | 5139 |
|
---|
| 5140 | pirepSaveHelper = PIREPSaveHelper(self)
|
---|
| 5141 |
|
---|
| 5142 | self._finishPage = FinishPage(self, pirepSaveHelper)
|
---|
[97] | 5143 | self._pages.append(self._finishPage)
|
---|
[769] | 5144 | self._pages.append(CheckFlightFinishPage(self, pirepSaveHelper))
|
---|
[201] | 5145 |
|
---|
[556] | 5146 | self._requestedWidth = None
|
---|
| 5147 | self._requestedHeight = None
|
---|
| 5148 |
|
---|
| 5149 | self.connect("size-allocate", self._sizeAllocate)
|
---|
| 5150 |
|
---|
| 5151 | for page in self._pages:
|
---|
| 5152 | page.show_all()
|
---|
| 5153 | page.setStyle()
|
---|
| 5154 |
|
---|
| 5155 | self._initialize()
|
---|
| 5156 |
|
---|
| 5157 | def _sizeAllocate(self, widget, allocation):
|
---|
| 5158 | if self._requestedWidth is not None and \
|
---|
| 5159 | self._requestedHeight is not None:
|
---|
| 5160 | return
|
---|
| 5161 |
|
---|
| 5162 | if self._currentPage is not None:
|
---|
| 5163 | self.remove(self._pages[self._currentPage])
|
---|
| 5164 |
|
---|
[51] | 5165 | maxWidth = 0
|
---|
| 5166 | maxHeight = 0
|
---|
| 5167 | for page in self._pages:
|
---|
[556] | 5168 | self.add(page)
|
---|
| 5169 | self.show_all()
|
---|
[51] | 5170 | pageSizeRequest = page.size_request()
|
---|
| 5171 | width = pageSizeRequest.width if pygobject else pageSizeRequest[0]
|
---|
| 5172 | height = pageSizeRequest.height if pygobject else pageSizeRequest[1]
|
---|
| 5173 | maxWidth = max(maxWidth, width)
|
---|
| 5174 | maxHeight = max(maxHeight, height)
|
---|
[556] | 5175 | self.remove(page)
|
---|
| 5176 |
|
---|
| 5177 | if self._currentPage is not None:
|
---|
| 5178 | self.add(self._pages[self._currentPage])
|
---|
| 5179 |
|
---|
| 5180 | self._requestedWidth = maxWidth
|
---|
| 5181 | self._requestedHeight = maxHeight
|
---|
[51] | 5182 | self.set_size_request(maxWidth, maxHeight)
|
---|
| 5183 |
|
---|
[184] | 5184 | @property
|
---|
[215] | 5185 | def pilotID(self):
|
---|
| 5186 | """Get the pilot ID, if given."""
|
---|
| 5187 | return self._loginPage.pilotID
|
---|
| 5188 |
|
---|
| 5189 | @property
|
---|
[184] | 5190 | def entranceExam(self):
|
---|
| 5191 | """Get whether an entrance exam is about to be taken."""
|
---|
[760] | 5192 | return self._loginResult is not None and self._loginResult.rank=="STU"
|
---|
[215] | 5193 |
|
---|
| 5194 | @property
|
---|
| 5195 | def loggedIn(self):
|
---|
| 5196 | """Indicate if there was a successful login."""
|
---|
| 5197 | return self._loginResult is not None
|
---|
[347] | 5198 |
|
---|
[48] | 5199 | @property
|
---|
| 5200 | def loginResult(self):
|
---|
| 5201 | """Get the login result."""
|
---|
| 5202 | return self._loginResult
|
---|
| 5203 |
|
---|
[769] | 5204 | @property
|
---|
| 5205 | def checkFlightAircraftType(self):
|
---|
| 5206 | """Get the type of the aircraft used to perform the check flight."""
|
---|
| 5207 | return self._studentPage.aircraftType
|
---|
| 5208 |
|
---|
[692] | 5209 | def setCurrentPage(self, index, finalize = False, fromPageShift = None):
|
---|
| 5210 | """Set the current page to the one with the given index.
|
---|
| 5211 |
|
---|
| 5212 | @param fromPageShift if given, the relative index of one of the
|
---|
| 5213 | previous pages that should be used as the from-page of the next
|
---|
| 5214 | page. E.g. if fromPageShift is 1, the previous page will be the
|
---|
| 5215 | from-page."""
|
---|
[42] | 5216 | assert index < len(self._pages)
|
---|
[70] | 5217 |
|
---|
| 5218 | fromPage = self._currentPage
|
---|
| 5219 | if fromPage is not None:
|
---|
| 5220 | page = self._pages[fromPage]
|
---|
[94] | 5221 | if finalize and not page._completed:
|
---|
| 5222 | page.complete()
|
---|
[70] | 5223 | self.remove(page)
|
---|
[692] | 5224 | if fromPageShift is not None:
|
---|
| 5225 | fromPage -= fromPageShift
|
---|
[42] | 5226 |
|
---|
| 5227 | self._currentPage = index
|
---|
[70] | 5228 | page = self._pages[index]
|
---|
| 5229 | self.add(page)
|
---|
| 5230 | if page._fromPage is None:
|
---|
| 5231 | page._fromPage = fromPage
|
---|
[94] | 5232 | page.initialize()
|
---|
[42] | 5233 | self.show_all()
|
---|
[72] | 5234 | if fromPage is not None:
|
---|
| 5235 | self.grabDefault()
|
---|
[42] | 5236 |
|
---|
[84] | 5237 | @property
|
---|
[97] | 5238 | def bookedFlight(self):
|
---|
| 5239 | """Get the booked flight selected."""
|
---|
| 5240 | return self._bookedFlight
|
---|
| 5241 |
|
---|
| 5242 | @property
|
---|
[303] | 5243 | def numCrew(self):
|
---|
| 5244 | """Get the number of crew members."""
|
---|
| 5245 | return self._payloadPage.numCrew
|
---|
| 5246 |
|
---|
| 5247 | @property
|
---|
| 5248 | def numPassengers(self):
|
---|
| 5249 | """Get the number of passengers."""
|
---|
| 5250 | return self._payloadPage.numPassengers
|
---|
| 5251 |
|
---|
| 5252 | @property
|
---|
| 5253 | def bagWeight(self):
|
---|
| 5254 | """Get the baggage weight."""
|
---|
| 5255 | return self._payloadPage.bagWeight
|
---|
| 5256 |
|
---|
| 5257 | @property
|
---|
[97] | 5258 | def cargoWeight(self):
|
---|
[303] | 5259 | """Get the cargo weight."""
|
---|
[97] | 5260 | return self._payloadPage.cargoWeight
|
---|
| 5261 |
|
---|
| 5262 | @property
|
---|
[303] | 5263 | def mailWeight(self):
|
---|
| 5264 | """Get the mail weight."""
|
---|
| 5265 | return self._payloadPage.mailWeight
|
---|
| 5266 |
|
---|
| 5267 | @property
|
---|
[84] | 5268 | def zfw(self):
|
---|
| 5269 | """Get the calculated ZFW value."""
|
---|
| 5270 | return 0 if self._bookedFlight is None \
|
---|
| 5271 | else self._payloadPage.calculateZFW()
|
---|
| 5272 |
|
---|
| 5273 | @property
|
---|
[383] | 5274 | def filedCruiseLevel(self):
|
---|
| 5275 | """Get the filed cruise level."""
|
---|
| 5276 | return self._routePage.filedCruiseLevel
|
---|
| 5277 |
|
---|
| 5278 | @property
|
---|
[97] | 5279 | def filedCruiseAltitude(self):
|
---|
| 5280 | """Get the filed cruise altitude."""
|
---|
| 5281 | return self._routePage.filedCruiseLevel * 100
|
---|
| 5282 |
|
---|
| 5283 | @property
|
---|
[84] | 5284 | def cruiseAltitude(self):
|
---|
| 5285 | """Get the cruise altitude."""
|
---|
[383] | 5286 | level = self._cruisePage.cruiseLevel if self._cruisePage.activated \
|
---|
| 5287 | else self._routePage.filedCruiseLevel
|
---|
| 5288 | return level * 100
|
---|
| 5289 |
|
---|
| 5290 | @property
|
---|
| 5291 | def loggableCruiseAltitude(self):
|
---|
| 5292 | """Get the cruise altitude that can be logged."""
|
---|
| 5293 | if self._cruisePage.activated:
|
---|
| 5294 | return self._cruisePage.loggableCruiseLevel * 100
|
---|
| 5295 | else:
|
---|
| 5296 | return 0
|
---|
[84] | 5297 |
|
---|
| 5298 | @property
|
---|
[97] | 5299 | def route(self):
|
---|
| 5300 | """Get the route."""
|
---|
| 5301 | return self._routePage.route
|
---|
| 5302 |
|
---|
| 5303 | @property
|
---|
[687] | 5304 | def alternate(self):
|
---|
| 5305 | """Get the ICAO code of the alternate airport."""
|
---|
| 5306 | return self._routePage.alternate
|
---|
| 5307 |
|
---|
| 5308 | @property
|
---|
[97] | 5309 | def departureMETAR(self):
|
---|
| 5310 | """Get the METAR of the departure airport."""
|
---|
| 5311 | return self._departureBriefingPage.metar
|
---|
| 5312 |
|
---|
| 5313 | @property
|
---|
| 5314 | def arrivalMETAR(self):
|
---|
| 5315 | """Get the METAR of the arrival airport."""
|
---|
| 5316 | return self._arrivalBriefingPage.metar
|
---|
| 5317 |
|
---|
| 5318 | @property
|
---|
| 5319 | def departureRunway(self):
|
---|
| 5320 | """Get the departure runway."""
|
---|
| 5321 | return self._takeoffPage.runway
|
---|
| 5322 |
|
---|
| 5323 | @property
|
---|
| 5324 | def sid(self):
|
---|
| 5325 | """Get the SID."""
|
---|
| 5326 | return self._takeoffPage.sid
|
---|
| 5327 |
|
---|
| 5328 | @property
|
---|
[84] | 5329 | def v1(self):
|
---|
| 5330 | """Get the V1 speed."""
|
---|
[86] | 5331 | return self._takeoffPage.v1
|
---|
[84] | 5332 |
|
---|
| 5333 | @property
|
---|
| 5334 | def vr(self):
|
---|
| 5335 | """Get the Vr speed."""
|
---|
[86] | 5336 | return self._takeoffPage.vr
|
---|
[84] | 5337 |
|
---|
| 5338 | @property
|
---|
| 5339 | def v2(self):
|
---|
| 5340 | """Get the V2 speed."""
|
---|
[86] | 5341 | return self._takeoffPage.v2
|
---|
| 5342 |
|
---|
| 5343 | @property
|
---|
[384] | 5344 | def derate(self):
|
---|
| 5345 | """Get the derate value."""
|
---|
| 5346 | return self._takeoffPage.derate
|
---|
| 5347 |
|
---|
| 5348 | @property
|
---|
[391] | 5349 | def takeoffAntiIceOn(self):
|
---|
| 5350 | """Get whether the anti-ice system was on during take-off."""
|
---|
| 5351 | return self._takeoffPage.antiIceOn
|
---|
| 5352 |
|
---|
| 5353 | @takeoffAntiIceOn.setter
|
---|
| 5354 | def takeoffAntiIceOn(self, value):
|
---|
| 5355 | """Set anti-ice on indicator."""
|
---|
| 5356 | self._takeoffPage.antiIceOn = value
|
---|
| 5357 |
|
---|
| 5358 | @property
|
---|
[349] | 5359 | def rtoIndicated(self):
|
---|
| 5360 | """Get whether the pilot has indicated that an RTO has occured."""
|
---|
| 5361 | return self._takeoffPage.rtoIndicated
|
---|
| 5362 |
|
---|
| 5363 | @property
|
---|
[97] | 5364 | def arrivalRunway(self):
|
---|
| 5365 | """Get the arrival runway."""
|
---|
| 5366 | return self._landingPage.runway
|
---|
| 5367 |
|
---|
| 5368 | @property
|
---|
| 5369 | def star(self):
|
---|
| 5370 | """Get the STAR."""
|
---|
| 5371 | return self._landingPage.star
|
---|
| 5372 |
|
---|
| 5373 | @property
|
---|
| 5374 | def transition(self):
|
---|
| 5375 | """Get the transition."""
|
---|
| 5376 | return self._landingPage.transition
|
---|
| 5377 |
|
---|
| 5378 | @property
|
---|
| 5379 | def approachType(self):
|
---|
| 5380 | """Get the approach type."""
|
---|
| 5381 | return self._landingPage.approachType
|
---|
| 5382 |
|
---|
| 5383 | @property
|
---|
[86] | 5384 | def vref(self):
|
---|
| 5385 | """Get the Vref speed."""
|
---|
| 5386 | return self._landingPage.vref
|
---|
[84] | 5387 |
|
---|
[97] | 5388 | @property
|
---|
[391] | 5389 | def landingAntiIceOn(self):
|
---|
| 5390 | """Get whether the anti-ice system was on during landing."""
|
---|
| 5391 | return self._landingPage.antiIceOn
|
---|
| 5392 |
|
---|
| 5393 | @landingAntiIceOn.setter
|
---|
| 5394 | def landingAntiIceOn(self, value):
|
---|
| 5395 | """Set anti-ice on indicator."""
|
---|
| 5396 | self._landingPage.antiIceOn = value
|
---|
| 5397 |
|
---|
| 5398 | @property
|
---|
[97] | 5399 | def flightType(self):
|
---|
| 5400 | """Get the flight type."""
|
---|
| 5401 | return self._finishPage.flightType
|
---|
| 5402 |
|
---|
| 5403 | @property
|
---|
| 5404 | def online(self):
|
---|
| 5405 | """Get whether the flight was online or not."""
|
---|
| 5406 | return self._finishPage.online
|
---|
| 5407 |
|
---|
[687] | 5408 | @property
|
---|
| 5409 | def usingSimBrief(self):
|
---|
| 5410 | """Indicate if we are using a SimBrief briefing or not."""
|
---|
| 5411 | return self._usingSimBrief
|
---|
| 5412 |
|
---|
| 5413 | @usingSimBrief.setter
|
---|
| 5414 | def usingSimBrief(self, x):
|
---|
| 5415 | """Set whether we are using a SimBrief briefing or not."""
|
---|
| 5416 | self._usingSimBrief = x
|
---|
| 5417 |
|
---|
[70] | 5418 | def nextPage(self, finalize = True):
|
---|
[42] | 5419 | """Go to the next page."""
|
---|
[754] | 5420 | nextPageID = self._pages[self._currentPage].nextPageID
|
---|
| 5421 | self.jumpPage(1 if nextPageID is None else nextPageID, finalize)
|
---|
| 5422 |
|
---|
| 5423 | def jumpPage(self, countOrID, finalize = True, fromPageShift = None):
|
---|
[51] | 5424 | """Go to the page which is 'count' pages after the current one."""
|
---|
[754] | 5425 | if isinstance(countOrID, str):
|
---|
| 5426 | targetIndex = self._getIndexOf(countOrID)
|
---|
| 5427 | else:
|
---|
| 5428 | targetIndex = self._currentPage + countOrID
|
---|
| 5429 | self.setCurrentPage(targetIndex,
|
---|
[692] | 5430 | finalize = finalize, fromPageShift = fromPageShift)
|
---|
[46] | 5431 |
|
---|
| 5432 | def grabDefault(self):
|
---|
| 5433 | """Make the default button of the current page the default."""
|
---|
| 5434 | self._pages[self._currentPage].grabDefault()
|
---|
[51] | 5435 |
|
---|
[59] | 5436 | def connected(self, fsType, descriptor):
|
---|
| 5437 | """Called when the connection could be made to the simulator."""
|
---|
| 5438 | self.nextPage()
|
---|
| 5439 |
|
---|
[208] | 5440 | def reset(self, loginResult):
|
---|
[91] | 5441 | """Resets the wizard to go back to the login page."""
|
---|
[208] | 5442 | self._initialize(keepLoginResult = loginResult is None,
|
---|
| 5443 | loginResult = loginResult)
|
---|
[59] | 5444 |
|
---|
[84] | 5445 | def setStage(self, stage):
|
---|
| 5446 | """Set the flight stage to the given one."""
|
---|
[383] | 5447 | if stage!=const.STAGE_END:
|
---|
| 5448 | self._cruisePage.setLoggable(Flight.canLogCruiseAltitude(stage))
|
---|
| 5449 |
|
---|
[84] | 5450 | if stage==const.STAGE_TAKEOFF:
|
---|
[101] | 5451 | self._takeoffPage.allowForward()
|
---|
[106] | 5452 | elif stage==const.STAGE_LANDING:
|
---|
| 5453 | if not self._arrivalBriefingPage.metarEdited:
|
---|
| 5454 | print "Downloading arrival METAR again"
|
---|
| 5455 | self.gui.webHandler.getMETARs(self._arrivalMETARCallback,
|
---|
| 5456 | [self._bookedFlight.arrivalICAO])
|
---|
[347] | 5457 |
|
---|
[88] | 5458 | elif stage==const.STAGE_END:
|
---|
[275] | 5459 | for page in self._pages:
|
---|
| 5460 | page.flightEnded()
|
---|
[84] | 5461 |
|
---|
[208] | 5462 | def _initialize(self, keepLoginResult = False, loginResult = None):
|
---|
[59] | 5463 | """Initialize the wizard."""
|
---|
[208] | 5464 | if not keepLoginResult:
|
---|
| 5465 | self._loginResult = loginResult
|
---|
| 5466 |
|
---|
| 5467 | self._loginCallback = None
|
---|
| 5468 |
|
---|
[59] | 5469 | self._fleet = None
|
---|
| 5470 | self._fleetCallback = None
|
---|
[347] | 5471 |
|
---|
[59] | 5472 | self._bookedFlight = None
|
---|
| 5473 | self._departureGate = "-"
|
---|
[141] | 5474 | self._fuelData = None
|
---|
[64] | 5475 | self._departureNOTAMs = None
|
---|
[67] | 5476 | self._departureMETAR = None
|
---|
[64] | 5477 | self._arrivalNOTAMs = None
|
---|
[67] | 5478 | self._arrivalMETAR = None
|
---|
[692] | 5479 | self._usingSimBrief = None
|
---|
[717] | 5480 | self.takeoffRunway = None
|
---|
| 5481 | self.landingRunway = None
|
---|
[67] | 5482 |
|
---|
[208] | 5483 | firstPage = 0 if self._loginResult is None else 1
|
---|
| 5484 | for page in self._pages[firstPage:]:
|
---|
[67] | 5485 | page.reset()
|
---|
[347] | 5486 |
|
---|
[208] | 5487 | self.setCurrentPage(firstPage)
|
---|
[621] | 5488 | #self.setCurrentPage(10)
|
---|
[208] | 5489 |
|
---|
[760] | 5490 | def login(self, callback, pilotID, password):
|
---|
[208] | 5491 | """Called when the login button was clicked."""
|
---|
| 5492 | self._loginCallback = callback
|
---|
| 5493 | if pilotID is None:
|
---|
| 5494 | loginResult = self._loginResult
|
---|
| 5495 | assert loginResult is not None and loginResult.loggedIn
|
---|
| 5496 | pilotID = loginResult.pilotID
|
---|
| 5497 | password = loginResult.password
|
---|
| 5498 | busyMessage = xstr("reload_busy")
|
---|
| 5499 | else:
|
---|
| 5500 | self._loginResult = None
|
---|
| 5501 | busyMessage = xstr("login_busy")
|
---|
| 5502 |
|
---|
| 5503 | self.gui.beginBusy(busyMessage)
|
---|
[347] | 5504 |
|
---|
[208] | 5505 | self.gui.webHandler.login(self._loginResultCallback,
|
---|
[760] | 5506 | pilotID, password)
|
---|
[208] | 5507 |
|
---|
| 5508 | def reloadFlights(self, callback):
|
---|
| 5509 | """Reload the flights from the MAVA server."""
|
---|
[769] | 5510 | self.login(callback, None, None)
|
---|
| 5511 |
|
---|
[859] | 5512 | def addFlight(self, bookedFlight):
|
---|
| 5513 | """Add the given booked flight to the flight selection page."""
|
---|
| 5514 | self._flightSelectionPage.addFlight(bookedFlight)
|
---|
| 5515 |
|
---|
[821] | 5516 | def reflyFlight(self, bookedFlight):
|
---|
| 5517 | """Add the given booked flight to the flight selection page."""
|
---|
| 5518 | self._removePendingFlight(bookedFlight)
|
---|
| 5519 | self._flightSelectionPage._reflyFlight(bookedFlight)
|
---|
| 5520 |
|
---|
[824] | 5521 | def deleteFlight(self, bookedFlight):
|
---|
| 5522 | """Remove the given flight from the pending flight list."""
|
---|
| 5523 | self._removePendingFlight(bookedFlight)
|
---|
| 5524 | self._flightSelectionPage._updatePending()
|
---|
| 5525 |
|
---|
[769] | 5526 | def cancelFlight(self, reloadCallback):
|
---|
| 5527 | """Cancel the flight.
|
---|
| 5528 |
|
---|
| 5529 | If it is an entry exam flight, we go back to the student page.
|
---|
| 5530 | Otherwise we reload the flights."""
|
---|
| 5531 | if self.entranceExam:
|
---|
| 5532 | self.reset(None)
|
---|
| 5533 | self.jumpPage("student")
|
---|
| 5534 | else:
|
---|
| 5535 | self.reloadFlights(reloadCallback)
|
---|
[208] | 5536 |
|
---|
[304] | 5537 | def cruiseLevelChanged(self):
|
---|
| 5538 | """Called when the cruise level is changed."""
|
---|
[383] | 5539 | return self.gui.cruiseLevelChanged()
|
---|
[304] | 5540 |
|
---|
[586] | 5541 | def metarChanged(self, metar, originator):
|
---|
| 5542 | """Called when a METER is changed on on of the pages.
|
---|
| 5543 |
|
---|
| 5544 | originator is the page that originated the changed. It will be used to
|
---|
| 5545 | determine which METAR (departure or arrival) has changed."""
|
---|
| 5546 | metar = metar.upper()
|
---|
| 5547 | if originator in [self._departureBriefingPage, self._takeoffPage]:
|
---|
[718] | 5548 | self.departureMETARChanged(metar, originator)
|
---|
[586] | 5549 | else:
|
---|
[718] | 5550 | self.arrivalMETARChanged(metar, originator)
|
---|
| 5551 |
|
---|
| 5552 | def departureMETARChanged(self, metar, originator):
|
---|
[586] | 5553 | """Called when the departure METAR has been edited on one of the
|
---|
| 5554 | pages.
|
---|
| 5555 |
|
---|
| 5556 | originator is the page that originated the change. It will not be
|
---|
| 5557 | called to set the METAR, while others will be."""
|
---|
| 5558 | for page in [self._departureBriefingPage, self._takeoffPage]:
|
---|
| 5559 | if page is not originator:
|
---|
| 5560 | page.changeMETAR(metar)
|
---|
| 5561 |
|
---|
[718] | 5562 | def arrivalMETARChanged(self, metar, originator):
|
---|
[586] | 5563 | """Called when the arrival METAR has been edited on one of the
|
---|
| 5564 | pages.
|
---|
| 5565 |
|
---|
| 5566 | originator is the page that originated the change. It will not be
|
---|
| 5567 | called to set the METAR, while others will be."""
|
---|
[589] | 5568 | for page in [self._arrivalBriefingPage, self._landingPage]:
|
---|
[586] | 5569 | if page is not originator:
|
---|
| 5570 | page.changeMETAR(metar)
|
---|
| 5571 |
|
---|
[821] | 5572 | def _removePendingFlight(self, flight):
|
---|
| 5573 | """Remove the given pending flight from the login result."""
|
---|
| 5574 | for flights in [self._loginResult.reportedFlights,
|
---|
| 5575 | self._loginResult.rejectedFlights]:
|
---|
| 5576 | for f in flights:
|
---|
| 5577 | if f.id==flight.id:
|
---|
| 5578 | flights.remove(f)
|
---|
| 5579 | return
|
---|
| 5580 |
|
---|
[208] | 5581 | def _loginResultCallback(self, returned, result):
|
---|
| 5582 | """The login result callback, called in the web handler's thread."""
|
---|
| 5583 | gobject.idle_add(self._handleLoginResult, returned, result)
|
---|
| 5584 |
|
---|
| 5585 | def _handleLoginResult(self, returned, result):
|
---|
| 5586 | """Handle the login result."""
|
---|
| 5587 | self.gui.endBusy()
|
---|
| 5588 | isReload = self._loginResult is not None
|
---|
| 5589 | if returned:
|
---|
| 5590 | if result.loggedIn:
|
---|
| 5591 | self._loginResult = result
|
---|
[854] | 5592 | self.gui.loginSuccessful()
|
---|
[208] | 5593 | else:
|
---|
| 5594 | if isReload:
|
---|
| 5595 | message = xstr("reload_failed")
|
---|
| 5596 | else:
|
---|
| 5597 | message = xstr("login_entranceExam_invalid"
|
---|
| 5598 | if self.entranceExam else
|
---|
| 5599 | xstr("login_invalid"))
|
---|
| 5600 | dialog = gtk.MessageDialog(parent = self.gui.mainWindow,
|
---|
| 5601 | type = MESSAGETYPE_ERROR,
|
---|
| 5602 | message_format = message)
|
---|
| 5603 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 5604 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 5605 | if isReload:
|
---|
| 5606 | secondary = xstr("reload_failed_sec")
|
---|
| 5607 | else:
|
---|
| 5608 | secondary = xstr("login_entranceExam_invalid_sec"
|
---|
| 5609 | if self.entranceExam else
|
---|
| 5610 | xstr("login_invalid_sec"))
|
---|
| 5611 | dialog.format_secondary_markup(secondary)
|
---|
| 5612 | dialog.run()
|
---|
| 5613 | dialog.hide()
|
---|
| 5614 | else:
|
---|
| 5615 | message = xstr("reload_failconn") if isReload \
|
---|
| 5616 | else xstr("login_failconn")
|
---|
| 5617 | dialog = gtk.MessageDialog(parent = self.gui.mainWindow,
|
---|
| 5618 | type = MESSAGETYPE_ERROR,
|
---|
| 5619 | message_format = message)
|
---|
| 5620 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 5621 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 5622 | secondary = xstr("reload_failconn_sec") if isReload \
|
---|
| 5623 | else xstr("login_failconn_sec")
|
---|
| 5624 | dialog.format_secondary_markup(secondary)
|
---|
[347] | 5625 |
|
---|
[208] | 5626 | dialog.run()
|
---|
| 5627 | dialog.hide()
|
---|
| 5628 |
|
---|
| 5629 | callback = self._loginCallback
|
---|
| 5630 | self._loginCallback = None
|
---|
| 5631 | callback(returned, result)
|
---|
[126] | 5632 |
|
---|
[130] | 5633 | def getFleet(self, callback, force = False):
|
---|
[126] | 5634 | """Get the fleet via the GUI and call the given callback."""
|
---|
| 5635 | self._fleetCallback = callback
|
---|
[130] | 5636 | self.gui.getFleet(callback = self._fleetRetrieved, force = force)
|
---|
[126] | 5637 |
|
---|
| 5638 | def _fleetRetrieved(self, fleet):
|
---|
| 5639 | """Callback for the fleet retrieval."""
|
---|
| 5640 | self._fleet = fleet
|
---|
| 5641 | if self._fleetCallback is not None:
|
---|
| 5642 | self._fleetCallback(fleet)
|
---|
| 5643 | self._fleetCallback = None
|
---|
[347] | 5644 |
|
---|
[130] | 5645 | def updatePlane(self, callback, tailNumber, status, gateNumber = None):
|
---|
[51] | 5646 | """Update the given plane's gate information."""
|
---|
[130] | 5647 | self.gui.updatePlane(tailNumber, status, gateNumber = gateNumber,
|
---|
| 5648 | callback = callback)
|
---|
[51] | 5649 |
|
---|
[349] | 5650 | def updateRTO(self):
|
---|
| 5651 | """Update the RTO state.
|
---|
| 5652 |
|
---|
| 5653 | The RTO checkbox will be enabled if the flight has an RTO state and the
|
---|
| 5654 | comments field contains some text."""
|
---|
| 5655 | flight = self.gui.flight
|
---|
| 5656 | rtoEnabled = flight is not None and flight.hasRTO and \
|
---|
| 5657 | self.gui.hasComments
|
---|
| 5658 | self._takeoffPage.setRTOEnabled(rtoEnabled)
|
---|
| 5659 |
|
---|
[555] | 5660 | def commentsChanged(self):
|
---|
| 5661 | """Called when the comments have changed."""
|
---|
| 5662 | self.updateRTO()
|
---|
| 5663 | self._finishPage.updateButtons()
|
---|
| 5664 |
|
---|
| 5665 | def delayCodesChanged(self):
|
---|
| 5666 | """Called when the delay codes have changed."""
|
---|
| 5667 | self._finishPage.updateButtons()
|
---|
| 5668 |
|
---|
[605] | 5669 | def faultExplanationsChanged(self):
|
---|
| 5670 | """Called when the faults and their explanations have changed."""
|
---|
| 5671 | self._finishPage.updateButtons()
|
---|
| 5672 |
|
---|
[349] | 5673 | def rtoToggled(self, indicated):
|
---|
| 5674 | """Called when the RTO indication has changed."""
|
---|
| 5675 | self.gui.rtoToggled(indicated)
|
---|
| 5676 |
|
---|
[501] | 5677 | def _connectSimulator(self, simulatorType):
|
---|
[51] | 5678 | """Connect to the simulator."""
|
---|
[798] | 5679 | self.gui.connectSimulator(self._bookedFlight, simulatorType)
|
---|
[106] | 5680 |
|
---|
| 5681 | def _arrivalMETARCallback(self, returned, result):
|
---|
| 5682 | """Called when the METAR of the arrival airport is retrieved."""
|
---|
| 5683 | gobject.idle_add(self._handleArrivalMETAR, returned, result)
|
---|
[347] | 5684 |
|
---|
[106] | 5685 | def _handleArrivalMETAR(self, returned, result):
|
---|
| 5686 | """Called when the METAR of the arrival airport is retrieved."""
|
---|
| 5687 | icao = self._bookedFlight.arrivalICAO
|
---|
| 5688 | if returned and icao in result.metars:
|
---|
| 5689 | metar = result.metars[icao]
|
---|
| 5690 | if metar!="":
|
---|
| 5691 | self._arrivalBriefingPage.setMETAR(metar)
|
---|
[347] | 5692 |
|
---|
[754] | 5693 | def _getIndexOf(self, pageID):
|
---|
| 5694 | """Get the index for the given page ID.
|
---|
| 5695 |
|
---|
| 5696 | It is an assertion failure if the ID is not found."""
|
---|
| 5697 | for index in range(0, len(self._pages)):
|
---|
| 5698 | page = self._pages[index]
|
---|
| 5699 | if page.id==pageID:
|
---|
| 5700 | return index
|
---|
| 5701 | assert False
|
---|
| 5702 |
|
---|
[42] | 5703 | #-----------------------------------------------------------------------------
|
---|