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