[863] | 1 | # -*- encoding: utf-8 -*-
|
---|
| 2 |
|
---|
[42] | 3 | from mlx.gui.common import *
|
---|
[687] | 4 | import mlx.gui.cef as cef
|
---|
[819] | 5 | from mlx.gui.flightlist import ColumnDescriptor, FlightList, PendingFlightsWindow
|
---|
[42] | 6 |
|
---|
[51] | 7 | import mlx.const as const
|
---|
| 8 | import mlx.fs as fs
|
---|
[141] | 9 | import mlx.acft as acft
|
---|
[383] | 10 | from mlx.flight import Flight
|
---|
[60] | 11 | from mlx.checks import PayloadChecker
|
---|
[619] | 12 | from mlx.gates import lhbpGates
|
---|
[89] | 13 | import mlx.util as util
|
---|
[97] | 14 | from mlx.pirep import PIREP
|
---|
[759] | 15 | from mlx.i18n import xstr, getLanguage
|
---|
[170] | 16 | from mlx.sound import startSound
|
---|
[1033] | 17 | from mlx.rpc import BookedFlight
|
---|
[184] | 18 | import mlx.web as web
|
---|
[1106] | 19 | from mlx.gates import lhbpGates
|
---|
[51] | 20 |
|
---|
[61] | 21 | import datetime
|
---|
| 22 | import time
|
---|
[393] | 23 | import os
|
---|
[687] | 24 | import tempfile
|
---|
[700] | 25 | import threading
|
---|
[753] | 26 | import re
|
---|
[764] | 27 | import webbrowser
|
---|
[1076] | 28 | import urllib.request, urllib.error, urllib.parse
|
---|
| 29 | from lxml import etree
|
---|
| 30 | from io import StringIO
|
---|
| 31 | import lxml.html
|
---|
| 32 | import certifi
|
---|
[61] | 33 |
|
---|
[42] | 34 | #-----------------------------------------------------------------------------
|
---|
| 35 |
|
---|
[300] | 36 | ## @package mlx.gui.flight
|
---|
| 37 | #
|
---|
| 38 | # The flight "wizard".
|
---|
| 39 | #
|
---|
| 40 | # This module implements the main tab of the application, the flight
|
---|
| 41 | # wizard. The wizard consists of \ref Page "pages", that come one after the
|
---|
| 42 | # other. As some pages might be skipped, the pages dynamically store the index
|
---|
| 43 | # of the previous page so that going back to it is simpler. The \ref
|
---|
| 44 | # Page.activate "activate" function is called before a page is first shown
|
---|
| 45 | # during a flight. This function should initialize the page's controls and fill
|
---|
| 46 | # it with initial data. When a page is left for the first time, its \ref
|
---|
| 47 | # Page.finalize "finalize" function is called. It should set those controls
|
---|
| 48 | # insensitive, that will not be available if the user comes back to this page.
|
---|
| 49 | #
|
---|
| 50 | # Each page has a title at the top displayed in inverted colors and a big
|
---|
| 51 | # font. There is a help text below it centered, that shortly describes what is
|
---|
| 52 | # expected on the page. There can be two help texts: one shown when the page is
|
---|
| 53 | # first displayed during a flight, another shown when the user goes back to the
|
---|
| 54 | # page. The main content area is below this, also centered. Finally, there are
|
---|
| 55 | # some buttons at the bottom on the right. As some buttons occur very
|
---|
| 56 | # frequently, there are functions to add them (\ref Page.addCancelFlightButton
|
---|
| 57 | # "addCancelFlightButton", \ref Page.addPreviousButton "addPreviousButton" and
|
---|
| 58 | # \ref Page.addNextButton "addNextButton".
|
---|
| 59 | #
|
---|
| 60 | # The \ref Wizard class is the main class to collect the pages. It also stores
|
---|
| 61 | # some data passed from one page to another and provides properties to access
|
---|
| 62 | # data items set via the wizard pages.
|
---|
| 63 |
|
---|
| 64 | #-----------------------------------------------------------------------------
|
---|
| 65 |
|
---|
[996] | 66 | comboModel = Gtk.ListStore(GObject.TYPE_STRING)
|
---|
[621] | 67 | comboModel.append(("N/A",))
|
---|
| 68 | comboModel.append(("VECTORS",))
|
---|
| 69 |
|
---|
| 70 | #-----------------------------------------------------------------------------
|
---|
| 71 |
|
---|
[996] | 72 | class Page(Gtk.Alignment):
|
---|
[42] | 73 | """A page in the flight wizard."""
|
---|
[754] | 74 | def __init__(self, wizard, id, title, help, completedHelp = None):
|
---|
[42] | 75 | """Construct the page."""
|
---|
[44] | 76 | super(Page, self).__init__(xalign = 0.0, yalign = 0.0,
|
---|
| 77 | xscale = 1.0, yscale = 1.0)
|
---|
| 78 | self.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 79 | padding_left = 12, padding_right = 12)
|
---|
| 80 |
|
---|
[996] | 81 | frame = Gtk.Frame()
|
---|
[44] | 82 | self.add(frame)
|
---|
| 83 |
|
---|
[996] | 84 | self._vbox = Gtk.VBox()
|
---|
[48] | 85 | self._vbox.set_homogeneous(False)
|
---|
[44] | 86 | frame.add(self._vbox)
|
---|
| 87 |
|
---|
[996] | 88 | eventBox = Gtk.EventBox()
|
---|
| 89 |
|
---|
| 90 | alignment = Gtk.Alignment(xalign = 0.0, xscale = 0.0)
|
---|
| 91 |
|
---|
| 92 | titleLabel = Gtk.Label(title)
|
---|
[998] | 93 | titleLabel.modify_font(Pango.FontDescription("bold 24"))
|
---|
[44] | 94 | alignment.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 95 | padding_left = 6, padding_right = 0)
|
---|
[347] | 96 |
|
---|
[201] | 97 | alignment.add(titleLabel)
|
---|
[44] | 98 | eventBox.add(alignment)
|
---|
[347] | 99 |
|
---|
[44] | 100 | self._vbox.pack_start(eventBox, False, False, 0)
|
---|
| 101 |
|
---|
[201] | 102 | self._titleEventBox = eventBox
|
---|
| 103 | self._titleLabel = titleLabel
|
---|
| 104 |
|
---|
[996] | 105 | mainBox = Gtk.VBox()
|
---|
| 106 |
|
---|
| 107 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[347] | 108 | xscale = 1.0, yscale = 1.0)
|
---|
[48] | 109 | alignment.set_padding(padding_top = 16, padding_bottom = 16,
|
---|
| 110 | padding_left = 16, padding_right = 16)
|
---|
[79] | 111 | alignment.add(mainBox)
|
---|
[48] | 112 | self._vbox.pack_start(alignment, True, True, 0)
|
---|
[347] | 113 |
|
---|
[996] | 114 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
[94] | 115 | xscale = 0.0, yscale = 0.0)
|
---|
[50] | 116 | alignment.set_padding(padding_top = 0, padding_bottom = 16,
|
---|
| 117 | padding_left = 0, padding_right = 0)
|
---|
[48] | 118 |
|
---|
[94] | 119 | self._help = help
|
---|
| 120 | self._completedHelp = completedHelp
|
---|
| 121 |
|
---|
| 122 | if self._completedHelp is None or \
|
---|
| 123 | len(help.splitlines())>=len(completedHelp.splitlines()):
|
---|
| 124 | longerHelp = help
|
---|
| 125 | else:
|
---|
| 126 | longerHelp = completedHelp
|
---|
[347] | 127 |
|
---|
[996] | 128 | self._helpLabel = Gtk.Label(longerHelp)
|
---|
[94] | 129 | # FIXME: should be a constant in common
|
---|
[996] | 130 | self._helpLabel.set_justify(Gtk.Justification.CENTER)
|
---|
[94] | 131 | self._helpLabel.set_use_markup(True)
|
---|
| 132 | alignment.add(self._helpLabel)
|
---|
[79] | 133 | mainBox.pack_start(alignment, False, False, 0)
|
---|
[44] | 134 |
|
---|
[996] | 135 | self._mainAlignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[48] | 136 | xscale = 1.0, yscale = 1.0)
|
---|
[79] | 137 | mainBox.pack_start(self._mainAlignment, True, True, 0)
|
---|
[347] | 138 |
|
---|
[996] | 139 | buttonAlignment = Gtk.Alignment(xalign = 1.0, xscale=0.0, yscale = 0.0)
|
---|
[44] | 140 | buttonAlignment.set_padding(padding_top = 4, padding_bottom = 10,
|
---|
| 141 | padding_left = 16, padding_right = 16)
|
---|
| 142 |
|
---|
[996] | 143 | self._buttonBox = Gtk.HBox()
|
---|
[70] | 144 | self._buttonBox.set_homogeneous(False)
|
---|
[46] | 145 | self._defaultButton = None
|
---|
[44] | 146 | buttonAlignment.add(self._buttonBox)
|
---|
| 147 |
|
---|
| 148 | self._vbox.pack_start(buttonAlignment, False, False, 0)
|
---|
| 149 |
|
---|
[42] | 150 | self._wizard = wizard
|
---|
[754] | 151 | self._id = id
|
---|
| 152 | self._nextPageID = None
|
---|
[42] | 153 |
|
---|
[275] | 154 | self._cancelFlightButton = None
|
---|
| 155 |
|
---|
[94] | 156 | self._completed = False
|
---|
[70] | 157 | self._fromPage = None
|
---|
| 158 |
|
---|
[754] | 159 | @property
|
---|
| 160 | def id(self):
|
---|
| 161 | """Get the identifier of the page."""
|
---|
| 162 | return self._id
|
---|
| 163 |
|
---|
| 164 | @property
|
---|
| 165 | def nextPageID(self):
|
---|
| 166 | """Get the identifier of the next page, if set."""
|
---|
| 167 | return self._nextPageID
|
---|
| 168 |
|
---|
| 169 | @nextPageID.setter
|
---|
| 170 | def nextPageID(self, nextPageID):
|
---|
| 171 | """Set the identifier of the next page."""
|
---|
| 172 | self._nextPageID = nextPageID
|
---|
| 173 |
|
---|
[44] | 174 | def setMainWidget(self, widget):
|
---|
| 175 | """Set the given widget as the main one."""
|
---|
| 176 | self._mainAlignment.add(widget)
|
---|
| 177 |
|
---|
[107] | 178 | def addButton(self, label, default = False, sensitive = True,
|
---|
[769] | 179 | tooltip = None, clicked = None, padding = 4,
|
---|
| 180 | clickedArg = None):
|
---|
[44] | 181 | """Add a button with the given label.
|
---|
| 182 |
|
---|
| 183 | Return the button object created."""
|
---|
[996] | 184 | button = Gtk.Button(label)
|
---|
[208] | 185 | self._buttonBox.pack_start(button, False, False, padding)
|
---|
[48] | 186 | button.set_use_underline(True)
|
---|
[46] | 187 | if default:
|
---|
| 188 | button.set_can_default(True)
|
---|
| 189 | self._defaultButton = button
|
---|
[107] | 190 | button.set_sensitive(sensitive)
|
---|
| 191 | if tooltip is not None:
|
---|
| 192 | button.set_tooltip_text(tooltip)
|
---|
| 193 | if clicked is not None:
|
---|
[769] | 194 | if clickedArg is None:
|
---|
| 195 | button.connect("clicked", clicked)
|
---|
| 196 | else:
|
---|
| 197 | button.connect("clicked", clicked, clickedArg)
|
---|
[44] | 198 | return button
|
---|
| 199 |
|
---|
[208] | 200 | def addCancelFlightButton(self):
|
---|
| 201 | """Add the 'Cancel flight' button to the page."""
|
---|
[275] | 202 | self._cancelFlightButton = \
|
---|
| 203 | self.addButton(xstr("button_cancelFlight"),
|
---|
| 204 | sensitive = True,
|
---|
| 205 | tooltip = xstr("button_cancelFlight_tooltip"),
|
---|
| 206 | clicked = self._cancelFlight,
|
---|
| 207 | padding = 16)
|
---|
| 208 | return self._cancelFlightButton
|
---|
[208] | 209 |
|
---|
[107] | 210 | def addPreviousButton(self, sensitive = True, clicked = None):
|
---|
| 211 | """Add the 'Next' button to the page."""
|
---|
| 212 | return self.addButton(xstr("button_previous"),
|
---|
| 213 | sensitive = sensitive,
|
---|
| 214 | tooltip = xstr("button_previous_tooltip"),
|
---|
| 215 | clicked = clicked)
|
---|
| 216 |
|
---|
| 217 | def addNextButton(self, default = True, sensitive = True,
|
---|
| 218 | clicked = None):
|
---|
| 219 | """Add the 'Next' button to the page."""
|
---|
| 220 | return self.addButton(xstr("button_next"),
|
---|
| 221 | default = default,
|
---|
| 222 | sensitive = sensitive,
|
---|
| 223 | tooltip = xstr("button_next_tooltip"),
|
---|
| 224 | clicked = clicked)
|
---|
| 225 |
|
---|
[201] | 226 | def setStyle(self):
|
---|
| 227 | """Set the styles of some of the items on the page."""
|
---|
[994] | 228 | context = self.get_style_context()
|
---|
[996] | 229 | color = context.get_background_color(Gtk.StateFlags.SELECTED)
|
---|
[994] | 230 | self._titleEventBox.modify_bg(0, color.to_color())
|
---|
[996] | 231 | color = context.get_color(Gtk.StateFlags.SELECTED)
|
---|
[994] | 232 | self._titleLabel.modify_fg(0, color.to_color())
|
---|
[347] | 233 |
|
---|
[94] | 234 | def initialize(self):
|
---|
| 235 | """Initialize the page.
|
---|
| 236 |
|
---|
| 237 | It sets up the primary help, and calls the activate() function."""
|
---|
| 238 | self._helpLabel.set_markup(self._help)
|
---|
| 239 | self._helpLabel.set_sensitive(True)
|
---|
| 240 | self.activate()
|
---|
| 241 |
|
---|
[48] | 242 | def activate(self):
|
---|
| 243 | """Called when this page becomes active.
|
---|
| 244 |
|
---|
| 245 | This default implementation does nothing."""
|
---|
| 246 | pass
|
---|
| 247 |
|
---|
[1075] | 248 | def prepareShow(self):
|
---|
| 249 | """Prepare the page for showing, either initially on when later
|
---|
| 250 | returned to."""
|
---|
| 251 | pass
|
---|
| 252 |
|
---|
[563] | 253 | def setHelp(self, help):
|
---|
| 254 | """Set the help string."""
|
---|
| 255 | self._help = help
|
---|
| 256 | if not self._completed:
|
---|
| 257 | self._helpLabel.set_markup(self._help)
|
---|
| 258 | self._helpLabel.set_sensitive(True)
|
---|
| 259 |
|
---|
[94] | 260 | def complete(self):
|
---|
| 261 | """Called when the page is completed.
|
---|
| 262 |
|
---|
| 263 | It greys out/changes the help text and then calls finalize()."""
|
---|
| 264 | self.finalize()
|
---|
| 265 | if self._completedHelp is None:
|
---|
| 266 | self._helpLabel.set_sensitive(False)
|
---|
| 267 | else:
|
---|
| 268 | self._helpLabel.set_markup(self._completedHelp)
|
---|
| 269 | self._completed = True
|
---|
| 270 |
|
---|
[70] | 271 | def finalize(self):
|
---|
| 272 | """Called when the page is finalized."""
|
---|
| 273 | pass
|
---|
| 274 |
|
---|
[46] | 275 | def grabDefault(self):
|
---|
| 276 | """If the page has a default button, make it the default one."""
|
---|
| 277 | if self._defaultButton is not None:
|
---|
| 278 | self._defaultButton.grab_default()
|
---|
[67] | 279 |
|
---|
[1075] | 280 | def prepareHide(self):
|
---|
| 281 | """Prepare the page for hiding, either initially on when later
|
---|
| 282 | the user returned to it and then navigates away from it."""
|
---|
| 283 | pass
|
---|
| 284 |
|
---|
[67] | 285 | def reset(self):
|
---|
| 286 | """Reset the page if the wizard is reset."""
|
---|
[94] | 287 | self._completed = False
|
---|
[70] | 288 | self._fromPage = None
|
---|
[275] | 289 | if self._cancelFlightButton is not None:
|
---|
| 290 | self._cancelFlightButton.set_sensitive(True)
|
---|
[70] | 291 |
|
---|
| 292 | def goBack(self):
|
---|
| 293 | """Go to the page we were invoked from."""
|
---|
| 294 | assert self._fromPage is not None
|
---|
[347] | 295 |
|
---|
[70] | 296 | self._wizard.setCurrentPage(self._fromPage, finalize = False)
|
---|
[208] | 297 |
|
---|
[275] | 298 | def flightEnded(self):
|
---|
| 299 | """Called when the flight has ended.
|
---|
| 300 |
|
---|
| 301 | This default implementation disables the cancel flight button."""
|
---|
| 302 | if self._cancelFlightButton is not None:
|
---|
| 303 | self._cancelFlightButton.set_sensitive(False)
|
---|
| 304 |
|
---|
[208] | 305 | def _cancelFlight(self, button):
|
---|
| 306 | """Called when the Cancel flight button is clicked."""
|
---|
| 307 | self._wizard.gui.cancelFlight()
|
---|
[347] | 308 |
|
---|
[42] | 309 | #-----------------------------------------------------------------------------
|
---|
| 310 |
|
---|
| 311 | class LoginPage(Page):
|
---|
| 312 | """The login page."""
|
---|
| 313 | def __init__(self, wizard):
|
---|
| 314 | """Construct the login page."""
|
---|
[754] | 315 | super(LoginPage, self).__init__(wizard, "login",
|
---|
| 316 | xstr("login"), xstr("loginHelp"))
|
---|
[42] | 317 |
|
---|
[996] | 318 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[48] | 319 | xscale = 0.0, yscale = 0.0)
|
---|
[139] | 320 |
|
---|
[996] | 321 | table = Gtk.Table(3, 2)
|
---|
[42] | 322 | table.set_row_spacings(4)
|
---|
| 323 | table.set_col_spacings(32)
|
---|
[48] | 324 | alignment.add(table)
|
---|
| 325 | self.setMainWidget(alignment)
|
---|
[42] | 326 |
|
---|
[996] | 327 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[107] | 328 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 329 | label = Gtk.Label(xstr("label_pilotID"))
|
---|
[45] | 330 | label.set_use_underline(True)
|
---|
| 331 | labelAlignment.add(label)
|
---|
[42] | 332 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 333 |
|
---|
[996] | 334 | self._pilotID = Gtk.Entry()
|
---|
[578] | 335 | self._pilotID.connect("changed", self._pilotIDChanged)
|
---|
[107] | 336 | self._pilotID.set_tooltip_text(xstr("login_pilotID_tooltip"))
|
---|
[42] | 337 | table.attach(self._pilotID, 1, 2, 0, 1)
|
---|
[45] | 338 | label.set_mnemonic_widget(self._pilotID)
|
---|
[42] | 339 |
|
---|
[996] | 340 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[107] | 341 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 342 | label = Gtk.Label(xstr("label_password"))
|
---|
[45] | 343 | label.set_use_underline(True)
|
---|
| 344 | labelAlignment.add(label)
|
---|
[42] | 345 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 346 |
|
---|
[996] | 347 | self._password = Gtk.Entry()
|
---|
[42] | 348 | self._password.set_visibility(False)
|
---|
[184] | 349 | self._password.connect("changed", self._setControls)
|
---|
[107] | 350 | self._password.set_tooltip_text(xstr("login_password_tooltip"))
|
---|
[42] | 351 | table.attach(self._password, 1, 2, 1, 2)
|
---|
[45] | 352 | label.set_mnemonic_widget(self._password)
|
---|
[42] | 353 |
|
---|
[996] | 354 | self._rememberButton = Gtk.CheckButton(xstr("remember_password"))
|
---|
[45] | 355 | self._rememberButton.set_use_underline(True)
|
---|
[107] | 356 | self._rememberButton.set_tooltip_text(xstr("login_remember_tooltip"))
|
---|
[45] | 357 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
| 358 |
|
---|
[753] | 359 | self.addButton(xstr("button_login_register"),
|
---|
| 360 | clicked = self._registerClicked,
|
---|
| 361 | tooltip = xstr("button_login_register_tooltip"))
|
---|
| 362 |
|
---|
[215] | 363 | self.addButton(xstr("button_offline"),
|
---|
| 364 | clicked = self._offlineClicked,
|
---|
| 365 | tooltip = xstr("button_offline_tooltip"))
|
---|
| 366 |
|
---|
[107] | 367 | self._loginButton = self.addButton(xstr("button_login"), default = True)
|
---|
[42] | 368 | self._loginButton.connect("clicked", self._loginClicked)
|
---|
[184] | 369 | self._loginButton.set_tooltip_text(xstr("login_button_tooltip"))
|
---|
| 370 |
|
---|
| 371 |
|
---|
| 372 | @property
|
---|
[215] | 373 | def pilotID(self):
|
---|
| 374 | """Get the pilot ID, if given."""
|
---|
| 375 | return self._pilotID.get_text()
|
---|
| 376 |
|
---|
[92] | 377 | def activate(self):
|
---|
| 378 | """Activate the page."""
|
---|
[42] | 379 | config = self._wizard.gui.config
|
---|
| 380 | self._pilotID.set_text(config.pilotID)
|
---|
| 381 | self._password.set_text(config.password)
|
---|
[45] | 382 | self._rememberButton.set_active(config.rememberPassword)
|
---|
[347] | 383 | self._setControls(None)
|
---|
[184] | 384 |
|
---|
[578] | 385 | def _pilotIDChanged(self, entry):
|
---|
| 386 | """Called when the pilot ID has changed.
|
---|
| 387 |
|
---|
| 388 | It sets the text to upper-case and calls _setControls to update other
|
---|
| 389 | stuff."""
|
---|
| 390 | entry.set_text(entry.get_text().upper())
|
---|
| 391 | self._setControls(entry)
|
---|
| 392 |
|
---|
[184] | 393 | def _setControls(self, entry = None):
|
---|
| 394 | """Set the sensitivity of the various controls.
|
---|
| 395 |
|
---|
| 396 | The login button is sensitive only if both the pilot ID and the
|
---|
| 397 | password fields contain values.
|
---|
| 398 |
|
---|
| 399 | The password field is sensitive only, if the entrance exam checkbox is
|
---|
| 400 | not selected.
|
---|
| 401 |
|
---|
| 402 | The remember password checkbox is sensitive only, if the password field
|
---|
| 403 | contains text.
|
---|
| 404 |
|
---|
[208] | 405 | The entrance exam checkbox is sensitive only, if the pilot ID is not
|
---|
[184] | 406 | empty."""
|
---|
| 407 | pilotID = self._pilotID.get_text()
|
---|
| 408 | password = self._password.get_text()
|
---|
[760] | 409 | self._rememberButton.set_sensitive(password!="")
|
---|
| 410 | self._loginButton.set_sensitive(pilotID!="" and password!="")
|
---|
[42] | 411 |
|
---|
[753] | 412 | def _registerClicked(self, button):
|
---|
| 413 | """Called when the Register button was clicked."""
|
---|
[754] | 414 | self._wizard.jumpPage("register")
|
---|
[753] | 415 |
|
---|
[215] | 416 | def _offlineClicked(self, button):
|
---|
| 417 | """Called when the offline button was clicked."""
|
---|
[919] | 418 | print("mlx.flight.LoginPage: offline flight selected")
|
---|
[215] | 419 | self._wizard.nextPage()
|
---|
| 420 |
|
---|
[42] | 421 | def _loginClicked(self, button):
|
---|
| 422 | """Called when the login button was clicked."""
|
---|
[919] | 423 | print("mlx.flight.LoginPage: logging in")
|
---|
[208] | 424 | self._wizard.login(self._handleLoginResult,
|
---|
| 425 | self._pilotID.get_text(),
|
---|
[760] | 426 | self._password.get_text())
|
---|
[42] | 427 |
|
---|
| 428 | def _handleLoginResult(self, returned, result):
|
---|
| 429 | """Handle the login result."""
|
---|
[70] | 430 | self._loginButton.set_sensitive(True)
|
---|
[208] | 431 | if returned and result.loggedIn:
|
---|
| 432 | config = self._wizard.gui.config
|
---|
| 433 |
|
---|
| 434 | config.pilotID = self._pilotID.get_text()
|
---|
| 435 |
|
---|
[347] | 436 | rememberPassword = self._rememberButton.get_active()
|
---|
[208] | 437 | config.password = result.password if rememberPassword else ""
|
---|
| 438 |
|
---|
| 439 | config.rememberPassword = rememberPassword
|
---|
| 440 |
|
---|
| 441 | config.save()
|
---|
[760] | 442 | if result.rank=="STU":
|
---|
| 443 | self._wizard.jumpPage("student")
|
---|
| 444 | else:
|
---|
| 445 | self._wizard.nextPage()
|
---|
[42] | 446 |
|
---|
| 447 | #-----------------------------------------------------------------------------
|
---|
| 448 |
|
---|
| 449 | class FlightSelectionPage(Page):
|
---|
| 450 | """The page to select the flight."""
|
---|
| 451 | def __init__(self, wizard):
|
---|
| 452 | """Construct the flight selection page."""
|
---|
[347] | 453 | help = xstr("flightsel_help")
|
---|
[107] | 454 | completedHelp = xstr("flightsel_chelp")
|
---|
[754] | 455 | super(FlightSelectionPage, self).__init__(wizard, "flightsel",
|
---|
| 456 | xstr("flightsel_title"),
|
---|
[94] | 457 | help, completedHelp = completedHelp)
|
---|
[48] | 458 |
|
---|
[996] | 459 | mainBox = Gtk.HBox()
|
---|
[860] | 460 | mainBox.set_homogeneous(False)
|
---|
| 461 |
|
---|
[996] | 462 | leftVBox = Gtk.VBox()
|
---|
| 463 |
|
---|
| 464 | alignment = Gtk.Alignment(xscale = 1.0)
|
---|
[872] | 465 | alignment.set_size_request(100, 0)
|
---|
[860] | 466 |
|
---|
| 467 | leftVBox.pack_start(alignment, False, False, 0)
|
---|
| 468 |
|
---|
| 469 | mainBox.pack_start(leftVBox, True, True, 0)
|
---|
| 470 |
|
---|
[818] | 471 | self._flightList = FlightList(popupMenuProducer =
|
---|
[811] | 472 | self._createListPopupMenu,
|
---|
| 473 | widthRequest = 400)
|
---|
[277] | 474 | self._flightList.connect("row-activated", self._rowActivated)
|
---|
[811] | 475 | self._flightList.connect("selection-changed", self._selectionChanged)
|
---|
| 476 |
|
---|
[860] | 477 | mainBox.pack_start(self._flightList, False, False, 8)
|
---|
| 478 |
|
---|
[996] | 479 | flightButtonBox = Gtk.VBox()
|
---|
| 480 |
|
---|
| 481 | alignment = Gtk.Alignment(xscale = 1.0)
|
---|
[872] | 482 | alignment.set_size_request(100, 0)
|
---|
[860] | 483 | flightButtonBox.pack_start(alignment, False, False, 0)
|
---|
| 484 |
|
---|
[996] | 485 | flightButtonWidthAlignment = Gtk.Alignment(xscale=1.0, yscale=0.0,
|
---|
[863] | 486 | xalign=0.0, yalign=0.0)
|
---|
[866] | 487 | flightButtonWidthAlignment.set_padding(padding_top = 0,
|
---|
| 488 | padding_bottom = 0,
|
---|
| 489 | padding_left = 8,
|
---|
| 490 | padding_right = 0)
|
---|
[996] | 491 | flightButtonWidthBox = Gtk.VBox()
|
---|
| 492 |
|
---|
| 493 | self._saveButton = Gtk.Button(xstr("flightsel_save"))
|
---|
[860] | 494 | self._saveButton.set_use_underline(True)
|
---|
| 495 | self._saveButton.set_sensitive(False)
|
---|
| 496 | self._saveButton.set_tooltip_text(xstr("flightsel_save_tooltip"))
|
---|
| 497 | self._saveButton.connect("clicked", self._saveClicked)
|
---|
| 498 |
|
---|
[863] | 499 | flightButtonWidthBox.pack_start(self._saveButton, True, True, 4)
|
---|
| 500 |
|
---|
[996] | 501 | self._printButton = Gtk.Button(xstr("flightsel_print"))
|
---|
[863] | 502 | self._printButton.set_use_underline(True)
|
---|
| 503 | self._printButton.set_sensitive(False)
|
---|
| 504 | self._printButton.set_tooltip_text(xstr("flightsel_print_tooltip"))
|
---|
| 505 | self._printButton.connect("clicked", self._printClicked)
|
---|
| 506 |
|
---|
| 507 | flightButtonWidthBox.pack_start(self._printButton, True, True, 4)
|
---|
| 508 |
|
---|
[996] | 509 | self._deleteButton = Gtk.Button(xstr("flightsel_delete"))
|
---|
[864] | 510 | self._deleteButton.set_use_underline(True)
|
---|
| 511 | self._deleteButton.set_sensitive(False)
|
---|
| 512 | self._deleteButton.set_tooltip_text(xstr("flightsel_delete_tooltip"))
|
---|
| 513 | self._deleteButton.connect("clicked", self._deleteClicked)
|
---|
| 514 |
|
---|
| 515 | flightButtonWidthBox.pack_start(self._deleteButton, True, True, 4)
|
---|
[863] | 516 |
|
---|
| 517 | flightButtonWidthAlignment.add(flightButtonWidthBox)
|
---|
| 518 | flightButtonBox.pack_start(flightButtonWidthAlignment, False, False, 0)
|
---|
[860] | 519 |
|
---|
| 520 | mainBox.pack_start(flightButtonBox, True, True, 0)
|
---|
| 521 |
|
---|
| 522 | self.setMainWidget(mainBox)
|
---|
[48] | 523 |
|
---|
[869] | 524 | self._bookButton = self.addButton(xstr("flightsel_book"),
|
---|
| 525 | sensitive = True,
|
---|
| 526 | clicked = self._bookClicked,
|
---|
| 527 | tooltip = xstr("flightsel_book_tooltip"))
|
---|
| 528 |
|
---|
[819] | 529 | self._pendingButton = self.addButton(xstr("flightsel_pending"),
|
---|
| 530 | sensitive = False,
|
---|
| 531 | clicked = self._pendingClicked,
|
---|
| 532 | tooltip = xstr("flightsel_pending_tooltip"))
|
---|
| 533 |
|
---|
[214] | 534 | self._saveDialog = None
|
---|
| 535 |
|
---|
[208] | 536 | self._refreshButton = self.addButton(xstr("flightsel_refresh"),
|
---|
| 537 | sensitive = True,
|
---|
| 538 | clicked = self._refreshClicked,
|
---|
| 539 | tooltip = xstr("flightsel_refresh_tooltip"))
|
---|
| 540 |
|
---|
[184] | 541 | self._loadButton = self.addButton(xstr("flightsel_load"),
|
---|
| 542 | sensitive = True,
|
---|
| 543 | tooltip = xstr("flightsel_load_tooltip"))
|
---|
| 544 | self._loadButton.connect("clicked", self._loadButtonClicked)
|
---|
| 545 | self._loadDialog = None
|
---|
[347] | 546 |
|
---|
[107] | 547 | self._button = self.addNextButton(sensitive = False,
|
---|
| 548 | clicked = self._forwardClicked)
|
---|
[48] | 549 |
|
---|
[184] | 550 | self._flights = []
|
---|
| 551 |
|
---|
[819] | 552 | self._pendingFlightsWindow = PendingFlightsWindow(self._wizard)
|
---|
| 553 | self._pendingFlightsWindowShown = False
|
---|
| 554 | self._pendingFlightsWindow.connect("delete-event",
|
---|
| 555 | self._deletePendingFlightsWindow)
|
---|
| 556 |
|
---|
[863] | 557 | self._printSettings = None
|
---|
| 558 |
|
---|
[48] | 559 | def activate(self):
|
---|
| 560 | """Fill the flight list."""
|
---|
[810] | 561 | self._setupHelp()
|
---|
[70] | 562 | self._flightList.set_sensitive(True)
|
---|
[208] | 563 | self._loadButton.set_sensitive(True)
|
---|
[216] | 564 | self._refreshButton.set_sensitive(self._wizard.loggedIn)
|
---|
[208] | 565 | self._buildFlights()
|
---|
[347] | 566 |
|
---|
[208] | 567 | def finalize(self):
|
---|
| 568 | """Finalize the page."""
|
---|
| 569 | self._flightList.set_sensitive(False)
|
---|
| 570 | self._loadButton.set_sensitive(False)
|
---|
| 571 | self._refreshButton.set_sensitive(False)
|
---|
| 572 |
|
---|
[810] | 573 | def _setupHelp(self):
|
---|
| 574 | """Setup the help string"""
|
---|
| 575 | help = ""
|
---|
| 576 |
|
---|
| 577 | if self._wizard.loggedIn:
|
---|
| 578 | numReported = len(self._wizard.loginResult.reportedFlights)
|
---|
| 579 | numRejected = len(self._wizard.loginResult.rejectedFlights)
|
---|
| 580 | if numReported==0 and numRejected==0:
|
---|
| 581 | help = xstr("flightsel_prehelp_nopending")
|
---|
| 582 | elif numReported>0 and numRejected==0:
|
---|
| 583 | help = xstr("flightsel_prehelp_rep_0rej") % (numReported,)
|
---|
| 584 | elif numReported==0 and numRejected>0:
|
---|
| 585 | help = xstr("flightsel_prehelp_0rep_rej") % (numRejected,)
|
---|
| 586 | else:
|
---|
| 587 | help = xstr("flightsel_prehelp_rep_rej") % \
|
---|
| 588 | (numReported, numRejected)
|
---|
| 589 |
|
---|
| 590 | help += xstr("flightsel_help")
|
---|
| 591 |
|
---|
| 592 | self.setHelp(help)
|
---|
| 593 |
|
---|
[208] | 594 | def _buildFlights(self):
|
---|
| 595 | """Rebuild the flights from the login result."""
|
---|
[184] | 596 | self._flights = []
|
---|
[811] | 597 | self._flightList.clear()
|
---|
[819] | 598 | self._pendingFlightsWindow.clear()
|
---|
| 599 | loginResult = self._wizard.loginResult
|
---|
[215] | 600 | if self._wizard.loggedIn:
|
---|
[819] | 601 | for flight in loginResult.flights:
|
---|
[859] | 602 | self.addFlight(flight)
|
---|
[819] | 603 | for flight in loginResult.reportedFlights:
|
---|
| 604 | self._pendingFlightsWindow.addReportedFlight(flight)
|
---|
| 605 | for flight in loginResult.rejectedFlights:
|
---|
| 606 | self._pendingFlightsWindow.addRejectedFlight(flight)
|
---|
| 607 |
|
---|
| 608 | self._updatePendingButton()
|
---|
[48] | 609 |
|
---|
[859] | 610 | def addFlight(self, flight):
|
---|
[184] | 611 | """Add the given file to the list of flights."""
|
---|
| 612 | self._flights.append(flight)
|
---|
[811] | 613 | self._flightList.addFlight(flight)
|
---|
[184] | 614 |
|
---|
[821] | 615 | def _reflyFlight(self, flight):
|
---|
| 616 | """Refly the given flight."""
|
---|
[859] | 617 | self.addFlight(flight)
|
---|
[824] | 618 | self._updatePending()
|
---|
| 619 |
|
---|
| 620 | def _updatePending(self):
|
---|
| 621 | """Update the stuff depending on the set of pending flights."""
|
---|
[821] | 622 | self._setupHelp()
|
---|
| 623 | self._updatePendingButton()
|
---|
| 624 |
|
---|
[869] | 625 | def _bookClicked(self, button):
|
---|
| 626 | """Called when the Book flights button is clicked."""
|
---|
| 627 | self._wizard.gui.showTimetable()
|
---|
| 628 |
|
---|
[819] | 629 | def _pendingClicked(self, button):
|
---|
| 630 | """Called when the Pending flights button is clicked."""
|
---|
| 631 | self._pendingFlightsWindow.show_all()
|
---|
| 632 | self._pendingFlightsWindowShown = True
|
---|
| 633 | self._updateNextButton()
|
---|
| 634 |
|
---|
| 635 | def _deletePendingFlightsWindow(self, window, event):
|
---|
| 636 | """Called when the pending flights window is closed."""
|
---|
| 637 | self._pendingFlightsWindow.hide()
|
---|
| 638 | self._pendingFlightsWindowShown = False
|
---|
| 639 | self._updateNextButton()
|
---|
| 640 | return True
|
---|
| 641 |
|
---|
[214] | 642 | def _saveClicked(self, button):
|
---|
| 643 | """Called when the Save flight button is clicked."""
|
---|
[277] | 644 | self._saveSelected()
|
---|
| 645 |
|
---|
| 646 | def _saveSelected(self):
|
---|
| 647 | """Save the selected flight."""
|
---|
[214] | 648 | flight = self._getSelectedFlight()
|
---|
| 649 | date = flight.departureTime.date()
|
---|
| 650 | name = "%04d-%02d-%02d %s %s-%s.vaflight" % \
|
---|
| 651 | (date.year, date.month, date.day, flight.callsign,
|
---|
| 652 | flight.departureICAO, flight.arrivalICAO)
|
---|
| 653 |
|
---|
| 654 | dialog = self._getSaveDialog()
|
---|
| 655 | dialog.set_current_name(name)
|
---|
| 656 | dialog.show_all()
|
---|
| 657 | response = dialog.run()
|
---|
| 658 | dialog.hide()
|
---|
| 659 |
|
---|
[999] | 660 | if response==Gtk.ResponseType.OK:
|
---|
[954] | 661 | fileName = dialog.get_filename()
|
---|
[919] | 662 | print("Saving", fileName)
|
---|
[214] | 663 | try:
|
---|
| 664 | with open(fileName, "wt") as f:
|
---|
| 665 | flight.writeIntoFile(f)
|
---|
[919] | 666 | except Exception as e:
|
---|
| 667 | print("Failed to save flight:", util.utf2unicode(str(e)))
|
---|
[996] | 668 | dialog = Gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
[999] | 669 | type = Gtk.MessageType.ERROR,
|
---|
[214] | 670 | message_format =
|
---|
| 671 | xstr("flightsel_save_failed"))
|
---|
[999] | 672 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
[214] | 673 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 674 | secondary = xstr("flightsel_save_failed_sec")
|
---|
| 675 | dialog.format_secondary_markup(secondary)
|
---|
| 676 | dialog.run()
|
---|
| 677 | dialog.hide()
|
---|
[347] | 678 |
|
---|
[863] | 679 | def _printClicked(self, button):
|
---|
| 680 | """Called when the Print briefing button is clicked."""
|
---|
[864] | 681 | self._printSelected()
|
---|
| 682 |
|
---|
| 683 | def _printSelected(self):
|
---|
| 684 | """Print the briefing for the selected flight."""
|
---|
[863] | 685 | wizard = self._wizard
|
---|
| 686 | flight = self._getSelectedFlight()
|
---|
| 687 |
|
---|
[996] | 688 | printOperation = Gtk.PrintOperation()
|
---|
[863] | 689 | if self._printSettings is not None:
|
---|
| 690 | printOperation.set_print_settings(self._printSettings)
|
---|
| 691 |
|
---|
| 692 | printOperation.set_n_pages(1)
|
---|
| 693 | printOperation.set_show_progress(True)
|
---|
| 694 | printOperation.connect("draw_page", self._drawBriefing)
|
---|
| 695 |
|
---|
| 696 | name = "MAVA Briefing %s %s %s" % (wizard.loginResult.pilotID,
|
---|
| 697 | flight.callsign,
|
---|
| 698 | flight.departureTime.strftime("%Y-%m-%d %H:%M"))
|
---|
| 699 | printOperation.set_job_name(name)
|
---|
| 700 | printOperation.set_export_filename(name)
|
---|
| 701 | printOperation.set_use_full_page(False)
|
---|
| 702 |
|
---|
[1002] | 703 | result = printOperation.run(Gtk.PrintOperationAction.PRINT_DIALOG,
|
---|
[863] | 704 | wizard.gui.mainWindow)
|
---|
| 705 |
|
---|
[1002] | 706 | if result == Gtk.PrintOperationResult.APPLY:
|
---|
[863] | 707 | self._printSettings = printOperation.get_print_settings()
|
---|
[1002] | 708 | elif result == Gtk.PrintOperationResult.ERROR:
|
---|
[863] | 709 | errorDialog(xstr("flightsel_print_failed",
|
---|
| 710 | wizard.gui.mainWindow,
|
---|
| 711 | secondary = printOperation.get_error()))
|
---|
| 712 |
|
---|
| 713 | def _drawBriefing(self, printOperation, context, pageNumber):
|
---|
| 714 | """Draw the briefing."""
|
---|
| 715 | wizard = self._wizard
|
---|
| 716 | loginResult = wizard.loginResult
|
---|
| 717 | flight=self._getSelectedFlight()
|
---|
| 718 |
|
---|
[919] | 719 | print("DPI", context.get_dpi_x(), context.get_dpi_y())
|
---|
[863] | 720 |
|
---|
[1046] | 721 | logoSurface = cairo.ImageSurface.create_from_png(
|
---|
| 722 | os.path.join(wizard.gui.programDirectory, "mavalogo.png"))
|
---|
| 723 |
|
---|
[863] | 724 | scale = context.get_dpi_x() / 72.0
|
---|
| 725 |
|
---|
| 726 | cr = context.get_cairo_context()
|
---|
[1002] | 727 |
|
---|
[863] | 728 | cr.set_antialias(cairo.ANTIALIAS_GRAY)
|
---|
| 729 |
|
---|
[1002] | 730 | pcr = context.create_pango_context()
|
---|
| 731 |
|
---|
[1046] | 732 | delimiter = "*" * 70
|
---|
| 733 |
|
---|
[1006] | 734 | layout = Pango.Layout(pcr)
|
---|
[1046] | 735 |
|
---|
| 736 | font = Pango.FontDescription("Courier")
|
---|
| 737 | font.set_size(int(12 * Pango.SCALE))
|
---|
| 738 | font.set_weight(Pango.Weight.THIN)
|
---|
[863] | 739 | layout.set_font_description(font)
|
---|
| 740 |
|
---|
[1046] | 741 | fontBold = Pango.FontDescription("Courier")
|
---|
| 742 | fontBold.set_size(int(12 * Pango.SCALE))
|
---|
| 743 | fontBold.set_weight(Pango.Weight.BOLD)
|
---|
| 744 |
|
---|
| 745 | layout.set_text(delimiter)
|
---|
[1002] | 746 | (_ink, logical) = layout.get_extents()
|
---|
| 747 | width = logical.width / Pango.SCALE
|
---|
[863] | 748 |
|
---|
[1046] | 749 | x0 = (context.get_width() - width)/2.0
|
---|
| 750 |
|
---|
| 751 | logoWidth = width / 3
|
---|
| 752 | logoScale = logoSurface.get_width() / logoWidth
|
---|
| 753 |
|
---|
[863] | 754 | y = 25 * scale
|
---|
| 755 |
|
---|
[1046] | 756 | source = cr.get_source()
|
---|
| 757 | logoSurface.set_device_scale(logoScale, logoScale)
|
---|
| 758 | cr.set_source_surface(logoSurface, x0, y)
|
---|
| 759 | cr.rectangle(x0, y, logoSurface.get_width() / logoScale,
|
---|
| 760 | logoSurface.get_height() / logoScale)
|
---|
| 761 | cr.fill()
|
---|
| 762 | cr.set_source(source)
|
---|
| 763 |
|
---|
| 764 | y += logoSurface.get_height() / logoScale
|
---|
| 765 | y += 12 * scale
|
---|
| 766 |
|
---|
| 767 | cr.move_to(x0, y)
|
---|
[863] | 768 | cr.set_line_width(0.1 * scale)
|
---|
[1002] | 769 | PangoCairo.layout_path(cr, layout)
|
---|
[863] | 770 | cr.stroke_preserve()
|
---|
| 771 | cr.fill()
|
---|
| 772 |
|
---|
[1002] | 773 | y += logical.height / Pango.SCALE
|
---|
[1046] | 774 | y += 4 * scale
|
---|
| 775 |
|
---|
| 776 | layout.set_text("F L I G H T B R I E F I N G S H E E T")
|
---|
[1002] | 777 | (_ink, logical) = layout.get_extents()
|
---|
| 778 | width = logical.width / Pango.SCALE
|
---|
[863] | 779 |
|
---|
| 780 | cr.move_to((context.get_width() - width)/2.0, y)
|
---|
| 781 | cr.set_line_width(0.1 * scale)
|
---|
[1002] | 782 | PangoCairo.layout_path(cr, layout)
|
---|
[863] | 783 | cr.stroke_preserve()
|
---|
| 784 | cr.fill()
|
---|
| 785 |
|
---|
[1002] | 786 | y += logical.height / Pango.SCALE
|
---|
[863] | 787 | y += 4 * scale
|
---|
| 788 |
|
---|
[1046] | 789 | layout.set_text(delimiter)
|
---|
| 790 | (_ink, logical) = layout.get_extents()
|
---|
| 791 | width = logical.width / Pango.SCALE
|
---|
| 792 |
|
---|
| 793 | x2 = x0 + width * 0.4
|
---|
| 794 |
|
---|
| 795 | cr.move_to(x0, y)
|
---|
| 796 | cr.set_line_width(0.1 * scale)
|
---|
| 797 | PangoCairo.layout_path(cr, layout)
|
---|
| 798 | cr.stroke_preserve()
|
---|
| 799 | cr.fill()
|
---|
| 800 |
|
---|
| 801 | y += logical.height / Pango.SCALE
|
---|
| 802 | y += 5 * scale
|
---|
| 803 |
|
---|
| 804 | layout.set_text("AIRCRAFT: ")
|
---|
| 805 | layout.set_font_description(fontBold)
|
---|
| 806 | (_ink, logical) = layout.get_extents()
|
---|
| 807 | x1 = x0 + logical.width / Pango.SCALE
|
---|
| 808 |
|
---|
| 809 | layout.set_text("FLIGHT:")
|
---|
| 810 | layout.set_font_description(fontBold)
|
---|
| 811 |
|
---|
| 812 | cr.move_to(x0, y)
|
---|
| 813 | cr.set_line_width(0.1 * scale)
|
---|
| 814 | PangoCairo.layout_path(cr, layout)
|
---|
| 815 | cr.stroke_preserve()
|
---|
| 816 | cr.fill()
|
---|
| 817 |
|
---|
| 818 | layout.set_text("%s %s-%s" % (flight.callsign,
|
---|
| 819 | flight.departureICAO,
|
---|
| 820 | flight.arrivalICAO))
|
---|
| 821 |
|
---|
| 822 | layout.set_font_description(font)
|
---|
| 823 |
|
---|
| 824 | cr.move_to(x1, y)
|
---|
| 825 | cr.set_line_width(0.1 * scale)
|
---|
| 826 | PangoCairo.layout_path(cr, layout)
|
---|
| 827 | cr.stroke_preserve()
|
---|
| 828 | cr.fill()
|
---|
| 829 |
|
---|
| 830 | layout.set_text("DATE:")
|
---|
| 831 | layout.set_font_description(fontBold)
|
---|
| 832 | (_ink, logical) = layout.get_extents()
|
---|
| 833 | x3 = x2 + logical.width / Pango.SCALE
|
---|
| 834 |
|
---|
| 835 | cr.move_to(x2, y)
|
---|
| 836 | cr.set_line_width(0.1 * scale)
|
---|
| 837 | PangoCairo.layout_path(cr, layout)
|
---|
| 838 | cr.stroke_preserve()
|
---|
| 839 | cr.fill()
|
---|
| 840 |
|
---|
| 841 | layout.set_text(" %s" % (flight.date,))
|
---|
| 842 | layout.set_font_description(font)
|
---|
| 843 |
|
---|
| 844 | cr.move_to(x3, y)
|
---|
| 845 | cr.set_line_width(0.1 * scale)
|
---|
| 846 | PangoCairo.layout_path(cr, layout)
|
---|
| 847 | cr.stroke_preserve()
|
---|
| 848 | cr.fill()
|
---|
| 849 |
|
---|
| 850 | layout.set_text(" %02d:%02d" % (flight.departureTime.hour,
|
---|
| 851 | flight.departureTime.minute))
|
---|
| 852 | (_ink, logical) = layout.get_extents()
|
---|
| 853 | x5 = x0 + width - logical.width / Pango.SCALE
|
---|
| 854 | cr.move_to(x5, y)
|
---|
| 855 | cr.set_line_width(0.1 * scale)
|
---|
| 856 | PangoCairo.layout_path(cr, layout)
|
---|
| 857 | cr.stroke_preserve()
|
---|
| 858 | cr.fill()
|
---|
| 859 |
|
---|
| 860 | layout.set_text("ETD (UTC):")
|
---|
| 861 | layout.set_font_description(fontBold)
|
---|
| 862 | (_ink, logical) = layout.get_extents()
|
---|
| 863 | x4 = x5 - logical.width / Pango.SCALE
|
---|
| 864 | cr.move_to(x4, y)
|
---|
| 865 | cr.set_line_width(0.1 * scale)
|
---|
| 866 | PangoCairo.layout_path(cr, layout)
|
---|
| 867 | cr.stroke_preserve()
|
---|
| 868 | cr.fill()
|
---|
| 869 |
|
---|
| 870 | y += logical.height / Pango.SCALE
|
---|
| 871 | y += 4 * scale
|
---|
| 872 |
|
---|
| 873 | layout.set_text("AIRCRAFT:")
|
---|
| 874 | layout.set_font_description(fontBold)
|
---|
| 875 | cr.move_to(x0, y)
|
---|
| 876 | cr.set_line_width(0.1 * scale)
|
---|
| 877 | PangoCairo.layout_path(cr, layout)
|
---|
| 878 | cr.stroke_preserve()
|
---|
| 879 | cr.fill()
|
---|
| 880 |
|
---|
| 881 | layout.set_text(aircraftNames[flight.aircraftType].upper())
|
---|
| 882 | layout.set_font_description(font)
|
---|
| 883 | cr.move_to(x1, y)
|
---|
| 884 | cr.set_line_width(0.1 * scale)
|
---|
| 885 | PangoCairo.layout_path(cr, layout)
|
---|
| 886 | cr.stroke_preserve()
|
---|
| 887 | cr.fill()
|
---|
| 888 |
|
---|
| 889 | layout.set_text(" %02d:%02d" % (flight.arrivalTime.hour,
|
---|
| 890 | flight.arrivalTime.minute))
|
---|
| 891 | cr.move_to(x5, y)
|
---|
| 892 | cr.set_line_width(0.1 * scale)
|
---|
| 893 | PangoCairo.layout_path(cr, layout)
|
---|
| 894 | cr.stroke_preserve()
|
---|
| 895 | cr.fill()
|
---|
| 896 |
|
---|
| 897 | layout.set_text("ETA (UTC):")
|
---|
| 898 | layout.set_font_description(fontBold)
|
---|
| 899 | cr.move_to(x4, y)
|
---|
| 900 | cr.set_line_width(0.1 * scale)
|
---|
| 901 | PangoCairo.layout_path(cr, layout)
|
---|
| 902 | cr.stroke_preserve()
|
---|
| 903 | cr.fill()
|
---|
| 904 |
|
---|
| 905 | y += logical.height / Pango.SCALE
|
---|
| 906 | y += 4 * scale
|
---|
| 907 |
|
---|
| 908 | layout.set_text("CREW:")
|
---|
| 909 | layout.set_font_description(fontBold)
|
---|
| 910 | cr.move_to(x0, y)
|
---|
| 911 | cr.set_line_width(0.1 * scale)
|
---|
| 912 | PangoCairo.layout_path(cr, layout)
|
---|
| 913 | cr.stroke_preserve()
|
---|
| 914 | cr.fill()
|
---|
| 915 |
|
---|
| 916 | layout.set_text("%d + %d" % (flight.numCockpitCrew,
|
---|
| 917 | flight.numCabinCrew))
|
---|
| 918 | layout.set_font_description(font)
|
---|
| 919 | cr.move_to(x1, y)
|
---|
| 920 | cr.set_line_width(0.1 * scale)
|
---|
| 921 | PangoCairo.layout_path(cr, layout)
|
---|
| 922 | cr.stroke_preserve()
|
---|
| 923 | cr.fill()
|
---|
| 924 |
|
---|
| 925 | layout.set_text("DOW:")
|
---|
| 926 | layout.set_font_description(fontBold)
|
---|
| 927 | cr.move_to(x4, y)
|
---|
| 928 | cr.set_line_width(0.1 * scale)
|
---|
| 929 | PangoCairo.layout_path(cr, layout)
|
---|
| 930 | cr.stroke_preserve()
|
---|
| 931 | cr.fill()
|
---|
| 932 |
|
---|
| 933 | layout.set_text("%d KG" % (flight.dow,))
|
---|
| 934 | layout.set_font_description(font)
|
---|
| 935 | (_ink, logical) = layout.get_extents()
|
---|
| 936 | x5 = x0 + width - logical.width / Pango.SCALE
|
---|
| 937 | cr.move_to(x5, y)
|
---|
| 938 | cr.set_line_width(0.1 * scale)
|
---|
| 939 | PangoCairo.layout_path(cr, layout)
|
---|
| 940 | cr.stroke_preserve()
|
---|
| 941 | cr.fill()
|
---|
| 942 |
|
---|
| 943 | y += logical.height / Pango.SCALE
|
---|
| 944 | y += logical.height / Pango.SCALE
|
---|
| 945 | y += 4 * scale
|
---|
| 946 |
|
---|
| 947 | layout.set_text("PASSENGERS")
|
---|
| 948 | layout.set_font_description(fontBold)
|
---|
| 949 | cr.move_to(x0, y)
|
---|
| 950 | cr.set_line_width(0.1 * scale)
|
---|
| 951 | PangoCairo.layout_path(cr, layout)
|
---|
| 952 | cr.stroke_preserve()
|
---|
| 953 | cr.fill()
|
---|
| 954 |
|
---|
| 955 | layout.set_text("CARGO HOLDS")
|
---|
| 956 | layout.set_font_description(fontBold)
|
---|
| 957 | cr.move_to(x2, y)
|
---|
| 958 | cr.set_line_width(0.1 * scale)
|
---|
| 959 | PangoCairo.layout_path(cr, layout)
|
---|
| 960 | cr.stroke_preserve()
|
---|
| 961 | cr.fill()
|
---|
| 962 |
|
---|
| 963 | layout.set_text("TOTAL")
|
---|
| 964 | layout.set_font_description(fontBold)
|
---|
| 965 | cr.move_to(x4, y)
|
---|
| 966 | cr.set_line_width(0.1 * scale)
|
---|
| 967 | PangoCairo.layout_path(cr, layout)
|
---|
| 968 | cr.stroke_preserve()
|
---|
| 969 | cr.fill()
|
---|
| 970 |
|
---|
| 971 | y += logical.height / Pango.SCALE
|
---|
| 972 | y += 4 * scale
|
---|
| 973 |
|
---|
| 974 | layout.set_text("CHILDREN:")
|
---|
| 975 | layout.set_font_description(font)
|
---|
| 976 | (_ink, logical) = layout.get_extents()
|
---|
| 977 | x1 = x0 + logical.width / Pango.SCALE
|
---|
| 978 |
|
---|
| 979 | layout.set_text("CARGO:")
|
---|
| 980 | layout.set_font_description(font)
|
---|
| 981 | (_ink, logical) = layout.get_extents()
|
---|
| 982 | x3 = x2 + logical.width / Pango.SCALE
|
---|
| 983 |
|
---|
| 984 | layout.set_text("ADULTS:")
|
---|
| 985 | layout.set_font_description(font)
|
---|
| 986 | cr.move_to(x0, y)
|
---|
| 987 | cr.set_line_width(0.1 * scale)
|
---|
| 988 | PangoCairo.layout_path(cr, layout)
|
---|
| 989 | cr.stroke_preserve()
|
---|
| 990 | cr.fill()
|
---|
| 991 |
|
---|
| 992 | layout.set_text(" %3d" % (flight.numPassengers,))
|
---|
| 993 | layout.set_font_description(font)
|
---|
| 994 | cr.move_to(x1, y)
|
---|
| 995 | cr.set_line_width(0.1 * scale)
|
---|
| 996 | PangoCairo.layout_path(cr, layout)
|
---|
| 997 | cr.stroke_preserve()
|
---|
| 998 | cr.fill()
|
---|
| 999 |
|
---|
| 1000 | layout.set_text("BAGS:")
|
---|
| 1001 | layout.set_font_description(font)
|
---|
| 1002 | cr.move_to(x2, y)
|
---|
| 1003 | cr.set_line_width(0.1 * scale)
|
---|
| 1004 | PangoCairo.layout_path(cr, layout)
|
---|
| 1005 | cr.stroke_preserve()
|
---|
| 1006 | cr.fill()
|
---|
| 1007 |
|
---|
| 1008 | layout.set_text(" %5d KG" % (flight.bagWeight,))
|
---|
| 1009 | layout.set_font_description(font)
|
---|
| 1010 | cr.move_to(x3, y)
|
---|
| 1011 | cr.set_line_width(0.1 * scale)
|
---|
| 1012 | PangoCairo.layout_path(cr, layout)
|
---|
| 1013 | cr.stroke_preserve()
|
---|
| 1014 | cr.fill()
|
---|
| 1015 |
|
---|
| 1016 | y += logical.height / Pango.SCALE
|
---|
| 1017 | y += 4 * scale
|
---|
| 1018 |
|
---|
| 1019 | layout.set_text("CHILDREN:")
|
---|
| 1020 | layout.set_font_description(font)
|
---|
| 1021 | cr.move_to(x0, y)
|
---|
| 1022 | cr.set_line_width(0.1 * scale)
|
---|
| 1023 | PangoCairo.layout_path(cr, layout)
|
---|
| 1024 | cr.stroke_preserve()
|
---|
| 1025 | cr.fill()
|
---|
| 1026 |
|
---|
| 1027 | layout.set_text(" %3d" % (flight.numChildren,))
|
---|
| 1028 | layout.set_font_description(font)
|
---|
| 1029 | cr.move_to(x1, y)
|
---|
| 1030 | cr.set_line_width(0.1 * scale)
|
---|
| 1031 | PangoCairo.layout_path(cr, layout)
|
---|
| 1032 | cr.stroke_preserve()
|
---|
| 1033 | cr.fill()
|
---|
| 1034 |
|
---|
| 1035 | layout.set_text("MAIL:")
|
---|
| 1036 | layout.set_font_description(font)
|
---|
| 1037 | cr.move_to(x2, y)
|
---|
| 1038 | cr.set_line_width(0.1 * scale)
|
---|
| 1039 | PangoCairo.layout_path(cr, layout)
|
---|
| 1040 | cr.stroke_preserve()
|
---|
| 1041 | cr.fill()
|
---|
| 1042 |
|
---|
| 1043 | layout.set_text(" %5d KG" % (flight.mailWeight,))
|
---|
| 1044 | layout.set_font_description(font)
|
---|
| 1045 | cr.move_to(x3, y)
|
---|
| 1046 | cr.set_line_width(0.1 * scale)
|
---|
| 1047 | PangoCairo.layout_path(cr, layout)
|
---|
| 1048 | cr.stroke_preserve()
|
---|
| 1049 | cr.fill()
|
---|
| 1050 |
|
---|
| 1051 | layout.set_text("PAYLOAD:")
|
---|
| 1052 | layout.set_font_description(font)
|
---|
| 1053 | cr.move_to(x4, y)
|
---|
| 1054 | cr.set_line_width(0.1 * scale)
|
---|
| 1055 | PangoCairo.layout_path(cr, layout)
|
---|
| 1056 | cr.stroke_preserve()
|
---|
| 1057 | cr.fill()
|
---|
| 1058 |
|
---|
| 1059 | layout.set_text("%5d KG" % (flight.payload,))
|
---|
| 1060 | layout.set_font_description(font)
|
---|
| 1061 | (_ink, logical) = layout.get_extents()
|
---|
| 1062 | x5 = x0 + width - logical.width / Pango.SCALE
|
---|
| 1063 | cr.move_to(x5, y)
|
---|
| 1064 | cr.set_line_width(0.1 * scale)
|
---|
| 1065 | PangoCairo.layout_path(cr, layout)
|
---|
| 1066 | cr.stroke_preserve()
|
---|
| 1067 | cr.fill()
|
---|
| 1068 |
|
---|
| 1069 | y += logical.height / Pango.SCALE
|
---|
| 1070 | y += 4 * scale
|
---|
| 1071 |
|
---|
| 1072 | layout.set_text("INFANTS:")
|
---|
| 1073 | layout.set_font_description(font)
|
---|
| 1074 | cr.move_to(x0, y)
|
---|
| 1075 | cr.set_line_width(0.1 * scale)
|
---|
| 1076 | PangoCairo.layout_path(cr, layout)
|
---|
| 1077 | cr.stroke_preserve()
|
---|
| 1078 | cr.fill()
|
---|
| 1079 |
|
---|
| 1080 | layout.set_text(" %3d" % (flight.numInfants,))
|
---|
| 1081 | layout.set_font_description(font)
|
---|
| 1082 | cr.move_to(x1, y)
|
---|
| 1083 | cr.set_line_width(0.1 * scale)
|
---|
| 1084 | PangoCairo.layout_path(cr, layout)
|
---|
| 1085 | cr.stroke_preserve()
|
---|
| 1086 | cr.fill()
|
---|
| 1087 |
|
---|
| 1088 | layout.set_text("CARGO:")
|
---|
| 1089 | layout.set_font_description(font)
|
---|
| 1090 | cr.move_to(x2, y)
|
---|
| 1091 | cr.set_line_width(0.1 * scale)
|
---|
| 1092 | PangoCairo.layout_path(cr, layout)
|
---|
| 1093 | cr.stroke_preserve()
|
---|
| 1094 | cr.fill()
|
---|
| 1095 |
|
---|
| 1096 | layout.set_text(" %5d KG" % (flight.cargoWeight,))
|
---|
| 1097 | layout.set_font_description(font)
|
---|
| 1098 | cr.move_to(x3, y)
|
---|
| 1099 | cr.set_line_width(0.1 * scale)
|
---|
| 1100 | PangoCairo.layout_path(cr, layout)
|
---|
| 1101 | cr.stroke_preserve()
|
---|
| 1102 | cr.fill()
|
---|
| 1103 |
|
---|
| 1104 | layout.set_text("ZFW:")
|
---|
| 1105 | layout.set_font_description(font)
|
---|
| 1106 | cr.move_to(x4, y)
|
---|
| 1107 | cr.set_line_width(0.1 * scale)
|
---|
| 1108 | PangoCairo.layout_path(cr, layout)
|
---|
| 1109 | cr.stroke_preserve()
|
---|
| 1110 | cr.fill()
|
---|
| 1111 |
|
---|
| 1112 | layout.set_text("%5d KG" % (flight.dow + flight.payload,))
|
---|
| 1113 | layout.set_font_description(font)
|
---|
| 1114 | (_ink, logical) = layout.get_extents()
|
---|
| 1115 | x5 = x0 + width - logical.width / Pango.SCALE
|
---|
| 1116 | cr.move_to(x5, y)
|
---|
| 1117 | cr.set_line_width(0.1 * scale)
|
---|
| 1118 | PangoCairo.layout_path(cr, layout)
|
---|
| 1119 | cr.stroke_preserve()
|
---|
| 1120 | cr.fill()
|
---|
| 1121 |
|
---|
| 1122 | y += logical.height / Pango.SCALE
|
---|
| 1123 | y += logical.height / Pango.SCALE
|
---|
| 1124 | y += 4 * scale
|
---|
| 1125 |
|
---|
| 1126 | layout.set_text("ROUTE:")
|
---|
| 1127 | layout.set_font_description(fontBold)
|
---|
| 1128 | (_ink, logical) = layout.get_extents()
|
---|
| 1129 | x1 = x0 + logical.width / Pango.SCALE
|
---|
| 1130 | cr.move_to(x0, y)
|
---|
| 1131 | cr.set_line_width(0.1 * scale)
|
---|
| 1132 | PangoCairo.layout_path(cr, layout)
|
---|
| 1133 | cr.stroke_preserve()
|
---|
| 1134 | cr.fill()
|
---|
| 1135 |
|
---|
| 1136 | routeWords = flight.route.split(" ")
|
---|
| 1137 | layout.set_font_description(font)
|
---|
| 1138 |
|
---|
| 1139 | startWord = 0
|
---|
| 1140 | textWidth = width - (x1 - x0)
|
---|
| 1141 | while startWord<len(routeWords):
|
---|
| 1142 | endWord = startWord + 1
|
---|
| 1143 | while endWord<=len(routeWords):
|
---|
| 1144 | layout.set_text(" %s" % (" ".join(routeWords[startWord:endWord]),))
|
---|
| 1145 | (_ink, logical) = layout.get_extents()
|
---|
| 1146 | if textWidth<logical.width / Pango.SCALE:
|
---|
| 1147 | endWord -= 1
|
---|
| 1148 | if endWord<=startWord:
|
---|
| 1149 | endWord = startWord + 1
|
---|
| 1150 | break
|
---|
| 1151 | endWord += 1
|
---|
| 1152 |
|
---|
| 1153 | layout.set_text(" %s" % (" ".join(routeWords[startWord:endWord]),))
|
---|
| 1154 | cr.move_to(x1, y)
|
---|
| 1155 | cr.set_line_width(0.1 * scale)
|
---|
| 1156 | PangoCairo.layout_path(cr, layout)
|
---|
[863] | 1157 | cr.stroke_preserve()
|
---|
| 1158 | cr.fill()
|
---|
| 1159 |
|
---|
[1046] | 1160 | startWord = endWord
|
---|
| 1161 |
|
---|
| 1162 | y += logical.height / Pango.SCALE
|
---|
[863] | 1163 | y += 4 * scale
|
---|
| 1164 |
|
---|
[1046] | 1165 | y += logical.height / Pango.SCALE
|
---|
| 1166 |
|
---|
| 1167 | layout.set_text(delimiter)
|
---|
| 1168 | layout.set_font_description(font)
|
---|
| 1169 | cr.move_to(x0, y)
|
---|
| 1170 | cr.set_line_width(0.1 * scale)
|
---|
| 1171 | PangoCairo.layout_path(cr, layout)
|
---|
| 1172 | cr.stroke_preserve()
|
---|
| 1173 | cr.fill()
|
---|
[863] | 1174 |
|
---|
[864] | 1175 | def _deleteClicked(self, button):
|
---|
| 1176 | """Called when the Delete flight button is clicked."""
|
---|
| 1177 | self._deleteSelected()
|
---|
| 1178 |
|
---|
| 1179 | def _deleteSelected(self):
|
---|
| 1180 | """Delete the selected flight."""
|
---|
| 1181 | if askYesNo(xstr("flightsel_delete_confirm"),
|
---|
| 1182 | parent = self._wizard.gui.mainWindow):
|
---|
| 1183 | flight = self._getSelectedFlight()
|
---|
| 1184 | gui = self._wizard.gui
|
---|
| 1185 | gui.beginBusy(xstr("flightsel_delete_busy"))
|
---|
| 1186 |
|
---|
| 1187 | gui.webHandler.deleteFlights(self._deleteResultCallback,
|
---|
| 1188 | [flight.id])
|
---|
| 1189 |
|
---|
| 1190 | def _deleteResultCallback(self, returned, result):
|
---|
| 1191 | """Called when the deletion result is available."""
|
---|
[995] | 1192 | GObject.idle_add(self._handleDeleteResult, returned, result)
|
---|
[864] | 1193 |
|
---|
| 1194 | def _handleDeleteResult(self, returned, result):
|
---|
| 1195 | """Handle the delete result."""
|
---|
| 1196 | gui = self._wizard.gui
|
---|
| 1197 | gui.endBusy()
|
---|
| 1198 |
|
---|
| 1199 | if returned:
|
---|
| 1200 | indexes = self._flightList.selectedIndexes
|
---|
| 1201 |
|
---|
| 1202 | flights = [self._flights[index] for index in indexes]
|
---|
| 1203 |
|
---|
| 1204 | self._flightList.removeFlights(indexes)
|
---|
| 1205 | for index in indexes[::-1]:
|
---|
| 1206 | del self._flights[index]
|
---|
| 1207 | else:
|
---|
| 1208 | communicationErrorDialog()
|
---|
| 1209 |
|
---|
| 1210 |
|
---|
[208] | 1211 | def _refreshClicked(self, button):
|
---|
| 1212 | """Called when the refresh button is clicked."""
|
---|
| 1213 | self._wizard.reloadFlights(self._refreshCallback)
|
---|
| 1214 |
|
---|
| 1215 | def _refreshCallback(self, returned, result):
|
---|
| 1216 | """Callback for the refresh."""
|
---|
[810] | 1217 | if returned:
|
---|
| 1218 | self._setupHelp()
|
---|
| 1219 | if result.loggedIn:
|
---|
| 1220 | self._buildFlights()
|
---|
[208] | 1221 |
|
---|
[823] | 1222 | def _selectionChanged(self, flightList, indexes):
|
---|
[48] | 1223 | """Called when the selection is changed."""
|
---|
[823] | 1224 | self._saveButton.set_sensitive(len(indexes)==1)
|
---|
[863] | 1225 | self._printButton.set_sensitive(len(indexes)==1)
|
---|
[864] | 1226 | self._deleteButton.set_sensitive(len(indexes)==1)
|
---|
[819] | 1227 | self._updateNextButton()
|
---|
| 1228 |
|
---|
| 1229 | def _updatePendingButton(self):
|
---|
| 1230 | """Update the senstivity of the Pending button."""
|
---|
| 1231 | self._pendingButton.set_sensitive(self._pendingFlightsWindow.hasFlights)
|
---|
| 1232 |
|
---|
| 1233 | def _updateNextButton(self):
|
---|
| 1234 | """Update the sensitivity of the Next button."""
|
---|
[823] | 1235 | sensitive = len(self._flightList.selectedIndexes)==1 and \
|
---|
[1071] | 1236 | len(self._flights)>0 and \
|
---|
| 1237 | not self._pendingFlightsWindowShown
|
---|
[1055] | 1238 | if sensitive:
|
---|
| 1239 | flight = self._getSelectedFlight()
|
---|
| 1240 | flightDate = datetime.datetime.strptime(flight.date, "%Y-%m-%d").date()
|
---|
| 1241 | tomorrow = datetime.date.today() + datetime.timedelta(days=1)
|
---|
| 1242 | print(flightDate, tomorrow)
|
---|
| 1243 | sensitive = flightDate <= tomorrow
|
---|
[819] | 1244 | self._button.set_sensitive(sensitive)
|
---|
[42] | 1245 |
|
---|
[184] | 1246 | def _loadButtonClicked(self, loadButton):
|
---|
| 1247 | """Called when the load a flight button is clicked."""
|
---|
| 1248 | dialog = self._getLoadDialog()
|
---|
| 1249 | dialog.show_all()
|
---|
| 1250 | response = dialog.run()
|
---|
| 1251 | dialog.hide()
|
---|
| 1252 |
|
---|
[999] | 1253 | if response==Gtk.ResponseType.OK:
|
---|
[954] | 1254 | fileName = dialog.get_filename()
|
---|
[919] | 1255 | print("Loading", fileName)
|
---|
[184] | 1256 | bookedFlight = web.BookedFlight()
|
---|
| 1257 | try:
|
---|
| 1258 | with open(fileName, "rt") as f:
|
---|
[1044] | 1259 | bookedFlight.readFromFile(f, self._wizard._loginResult.fleet)
|
---|
[859] | 1260 | self.addFlight(bookedFlight)
|
---|
[919] | 1261 | except Exception as e:
|
---|
| 1262 | print("Failed to load flight:", util.utf2unicode(str(e)))
|
---|
[996] | 1263 | dialog = Gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
[999] | 1264 | type = Gtk.MessageType.ERROR,
|
---|
[184] | 1265 | message_format =
|
---|
| 1266 | xstr("flightsel_load_failed"))
|
---|
[999] | 1267 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
[184] | 1268 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 1269 | secondary = xstr("flightsel_load_failed_sec")
|
---|
| 1270 | dialog.format_secondary_markup(secondary)
|
---|
| 1271 | dialog.run()
|
---|
[347] | 1272 | dialog.hide()
|
---|
| 1273 |
|
---|
[51] | 1274 | def _forwardClicked(self, button):
|
---|
| 1275 | """Called when the forward button was clicked."""
|
---|
[94] | 1276 | if self._completed:
|
---|
[754] | 1277 | self._wizard.jumpPage(self._nextID, finalize = False)
|
---|
[70] | 1278 | else:
|
---|
[277] | 1279 | self._flightSelected()
|
---|
| 1280 |
|
---|
[811] | 1281 | def _rowActivated(self, flightList, index):
|
---|
[277] | 1282 | """Called when a row is activated."""
|
---|
| 1283 | if not self._completed:
|
---|
| 1284 | self._flightSelected()
|
---|
| 1285 |
|
---|
| 1286 | def _flightSelected(self):
|
---|
| 1287 | """Called when a flight has been selected."""
|
---|
| 1288 | flight = self._getSelectedFlight()
|
---|
| 1289 | self._wizard._bookedFlight = flight
|
---|
[436] | 1290 | self._wizard.gui.enableFlightInfo(flight.aircraftType)
|
---|
[347] | 1291 |
|
---|
[277] | 1292 | self._updateDepartureGate()
|
---|
[214] | 1293 |
|
---|
| 1294 | def _getSelectedFlight(self):
|
---|
| 1295 | """Get the currently selected flight."""
|
---|
[823] | 1296 | indexes = self._flightList.selectedIndexes
|
---|
| 1297 | assert(len(indexes)==1)
|
---|
| 1298 | return self._flights[indexes[0]]
|
---|
[277] | 1299 |
|
---|
[51] | 1300 | def _updateDepartureGate(self):
|
---|
| 1301 | """Update the departure gate for the booked flight."""
|
---|
| 1302 | flight = self._wizard._bookedFlight
|
---|
[184] | 1303 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 1304 | self._wizard.loggedIn and not self._wizard.entranceExam:
|
---|
[136] | 1305 | if flight.departureICAO=="LHBP":
|
---|
| 1306 | self._wizard.getFleet(self._fleetRetrieved)
|
---|
| 1307 | else:
|
---|
| 1308 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 1309 | flight.tailNumber,
|
---|
| 1310 | const.PLANE_AWAY)
|
---|
[51] | 1311 | else:
|
---|
[754] | 1312 | self._nextID = "connect"
|
---|
| 1313 | self._wizard.jumpPage("connect")
|
---|
[347] | 1314 |
|
---|
[51] | 1315 | def _fleetRetrieved(self, fleet):
|
---|
| 1316 | """Called when the fleet has been retrieved."""
|
---|
| 1317 | if fleet is None:
|
---|
[754] | 1318 | self._nextID = "connect"
|
---|
| 1319 | self._wizard.jumpPage("connect")
|
---|
[51] | 1320 | else:
|
---|
| 1321 | plane = fleet[self._wizard._bookedFlight.tailNumber]
|
---|
| 1322 | if plane is None:
|
---|
[754] | 1323 | self._nextID = "connect"
|
---|
| 1324 | self._wizard.jumpPage("connect")
|
---|
[70] | 1325 | elif plane.gateNumber is not None and \
|
---|
| 1326 | not fleet.isGateConflicting(plane):
|
---|
[51] | 1327 | self._wizard._departureGate = plane.gateNumber
|
---|
[754] | 1328 | self._nextID = "connect"
|
---|
| 1329 | self._wizard.jumpPage("connect")
|
---|
[51] | 1330 | else:
|
---|
[754] | 1331 | self._nextID = "gatesel"
|
---|
| 1332 | self._wizard.jumpPage("gatesel")
|
---|
[130] | 1333 |
|
---|
| 1334 | def _planeUpdated(self, success):
|
---|
| 1335 | """Callback for the plane updating."""
|
---|
[754] | 1336 | self._nextID = "connect"
|
---|
| 1337 | self._wizard.jumpPage("connect")
|
---|
[184] | 1338 |
|
---|
[214] | 1339 | def _getSaveDialog(self):
|
---|
| 1340 | """Get the dialog to load a flight file."""
|
---|
| 1341 | if self._saveDialog is not None:
|
---|
| 1342 | return self._saveDialog
|
---|
[347] | 1343 |
|
---|
[214] | 1344 | gui = self._wizard.gui
|
---|
[996] | 1345 | dialog = Gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
[214] | 1346 | xstr("flightsel_save_title"),
|
---|
[999] | 1347 | action = Gtk.FileChooserAction.SAVE,
|
---|
[996] | 1348 | buttons = (Gtk.STOCK_CANCEL,
|
---|
[999] | 1349 | Gtk.ResponseType.CANCEL,
|
---|
| 1350 | Gtk.STOCK_OK, Gtk.ResponseType.OK),
|
---|
[214] | 1351 | parent = gui.mainWindow)
|
---|
[347] | 1352 | dialog.set_modal(True)
|
---|
[214] | 1353 | dialog.set_do_overwrite_confirmation(True)
|
---|
| 1354 |
|
---|
[996] | 1355 | filter = Gtk.FileFilter()
|
---|
[214] | 1356 | filter.set_name(xstr("flightsel_filter_flights"))
|
---|
| 1357 | filter.add_pattern("*.vaflight")
|
---|
| 1358 | dialog.add_filter(filter)
|
---|
[347] | 1359 |
|
---|
[996] | 1360 | filter = Gtk.FileFilter()
|
---|
[214] | 1361 | filter.set_name(xstr("file_filter_all"))
|
---|
| 1362 | filter.add_pattern("*.*")
|
---|
| 1363 | dialog.add_filter(filter)
|
---|
| 1364 |
|
---|
| 1365 | self._saveDialog = dialog
|
---|
[347] | 1366 |
|
---|
| 1367 | return dialog
|
---|
| 1368 |
|
---|
[184] | 1369 | def _getLoadDialog(self):
|
---|
| 1370 | """Get the dialog to load a flight file."""
|
---|
| 1371 | if self._loadDialog is not None:
|
---|
| 1372 | return self._loadDialog
|
---|
[347] | 1373 |
|
---|
[184] | 1374 | gui = self._wizard.gui
|
---|
[996] | 1375 | dialog = Gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
[184] | 1376 | xstr("flightsel_load_title"),
|
---|
[999] | 1377 | action = Gtk.FileChooserAction.OPEN,
|
---|
[996] | 1378 | buttons = (Gtk.STOCK_CANCEL,
|
---|
[999] | 1379 | Gtk.ResponseType.CANCEL,
|
---|
| 1380 | Gtk.STOCK_OK, Gtk.ResponseType.OK),
|
---|
[184] | 1381 | parent = gui.mainWindow)
|
---|
[347] | 1382 | dialog.set_modal(True)
|
---|
[184] | 1383 |
|
---|
[996] | 1384 | filter = Gtk.FileFilter()
|
---|
[184] | 1385 | filter.set_name(xstr("flightsel_filter_flights"))
|
---|
| 1386 | filter.add_pattern("*.vaflight")
|
---|
| 1387 | dialog.add_filter(filter)
|
---|
[347] | 1388 |
|
---|
[996] | 1389 | filter = Gtk.FileFilter()
|
---|
[184] | 1390 | filter.set_name(xstr("file_filter_all"))
|
---|
| 1391 | filter.add_pattern("*.*")
|
---|
| 1392 | dialog.add_filter(filter)
|
---|
| 1393 |
|
---|
| 1394 | self._loadDialog = dialog
|
---|
[347] | 1395 |
|
---|
| 1396 | return dialog
|
---|
[277] | 1397 |
|
---|
[811] | 1398 | def _createListPopupMenu(self):
|
---|
[277] | 1399 | """Get the flight list popup menu."""
|
---|
[996] | 1400 | menu = Gtk.Menu()
|
---|
| 1401 |
|
---|
| 1402 | menuItem = Gtk.MenuItem()
|
---|
[811] | 1403 | menuItem.set_label(xstr("flightsel_popup_select"))
|
---|
| 1404 | menuItem.set_use_underline(True)
|
---|
| 1405 | menuItem.connect("activate", self._popupSelect)
|
---|
| 1406 | menuItem.show()
|
---|
| 1407 |
|
---|
| 1408 | menu.append(menuItem)
|
---|
| 1409 |
|
---|
[996] | 1410 | menuItem = Gtk.MenuItem()
|
---|
[811] | 1411 | menuItem.set_label(xstr("flightsel_popup_save"))
|
---|
| 1412 | menuItem.set_use_underline(True)
|
---|
| 1413 | menuItem.connect("activate", self._popupSave)
|
---|
| 1414 | menuItem.show()
|
---|
| 1415 |
|
---|
| 1416 | menu.append(menuItem)
|
---|
| 1417 |
|
---|
[996] | 1418 | menuItem = Gtk.MenuItem()
|
---|
[865] | 1419 | menuItem.set_label(xstr("flightsel_popup_print"))
|
---|
| 1420 | menuItem.set_use_underline(True)
|
---|
| 1421 | menuItem.connect("activate", self._popupPrint)
|
---|
| 1422 | menuItem.show()
|
---|
| 1423 |
|
---|
| 1424 | menu.append(menuItem)
|
---|
| 1425 |
|
---|
[996] | 1426 | menuItem = Gtk.MenuItem()
|
---|
[864] | 1427 | menuItem.set_label(xstr("flightsel_popup_delete"))
|
---|
| 1428 | menuItem.set_use_underline(True)
|
---|
| 1429 | menuItem.connect("activate", self._popupDelete)
|
---|
| 1430 | menuItem.show()
|
---|
| 1431 |
|
---|
| 1432 | menu.append(menuItem)
|
---|
| 1433 |
|
---|
[811] | 1434 | return menu
|
---|
[277] | 1435 |
|
---|
| 1436 | def _popupSelect(self, menuItem):
|
---|
| 1437 | """Called when the Select menu item is activated in the popup menu."""
|
---|
| 1438 | if not self._completed:
|
---|
| 1439 | self._flightSelected()
|
---|
[347] | 1440 |
|
---|
[277] | 1441 | def _popupSave(self, menuItem):
|
---|
| 1442 | """Called when the Save menu item is activated in the popup menu."""
|
---|
| 1443 | if not self._completed:
|
---|
| 1444 | self._saveSelected()
|
---|
[347] | 1445 |
|
---|
[865] | 1446 | def _popupPrint(self, menuItem):
|
---|
| 1447 | """Called when the Print briefing menu item is activated in the popup menu."""
|
---|
| 1448 | if not self._completed:
|
---|
| 1449 | self._printSelected()
|
---|
| 1450 |
|
---|
[864] | 1451 | def _popupDelete(self, menuItem):
|
---|
| 1452 | """Called when the Delete menu item is activated in the popup menu."""
|
---|
| 1453 | if not self._completed:
|
---|
| 1454 | self._deleteSelected()
|
---|
| 1455 |
|
---|
[51] | 1456 | #-----------------------------------------------------------------------------
|
---|
| 1457 |
|
---|
| 1458 | class GateSelectionPage(Page):
|
---|
| 1459 | """Page to select a free gate at LHBP.
|
---|
| 1460 | This page should be displayed only if we have fleet information!."""
|
---|
| 1461 | def __init__(self, wizard):
|
---|
| 1462 | """Construct the gate selection page."""
|
---|
[754] | 1463 | super(GateSelectionPage, self).__init__(wizard, "gatesel",
|
---|
| 1464 | xstr("gatesel_title"),
|
---|
[107] | 1465 | xstr("gatesel_help"))
|
---|
[347] | 1466 |
|
---|
[996] | 1467 | self._listStore = Gtk.ListStore(str)
|
---|
| 1468 | self._gateList = Gtk.TreeView(self._listStore)
|
---|
| 1469 | column = Gtk.TreeViewColumn(None, Gtk.CellRendererText(),
|
---|
[51] | 1470 | text = 0)
|
---|
| 1471 | column.set_expand(True)
|
---|
| 1472 | self._gateList.append_column(column)
|
---|
| 1473 | self._gateList.set_headers_visible(False)
|
---|
[278] | 1474 | self._gateList.connect("row-activated", self._rowActivated)
|
---|
[51] | 1475 |
|
---|
| 1476 | gateSelection = self._gateList.get_selection()
|
---|
| 1477 | gateSelection.connect("changed", self._selectionChanged)
|
---|
| 1478 |
|
---|
[996] | 1479 | scrolledWindow = Gtk.ScrolledWindow()
|
---|
[51] | 1480 | scrolledWindow.add(self._gateList)
|
---|
| 1481 | scrolledWindow.set_size_request(50, -1)
|
---|
[996] | 1482 | scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC,
|
---|
| 1483 | Gtk.PolicyType.AUTOMATIC)
|
---|
| 1484 | scrolledWindow.set_shadow_type(Gtk.ShadowType.IN)
|
---|
| 1485 |
|
---|
| 1486 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
[51] | 1487 | alignment.add(scrolledWindow)
|
---|
| 1488 |
|
---|
[347] | 1489 | self.setMainWidget(alignment)
|
---|
[51] | 1490 |
|
---|
[208] | 1491 | self.addCancelFlightButton()
|
---|
| 1492 |
|
---|
[107] | 1493 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[347] | 1494 |
|
---|
[107] | 1495 | self._button = self.addNextButton(sensitive = False,
|
---|
| 1496 | clicked = self._forwardClicked)
|
---|
[51] | 1497 |
|
---|
| 1498 | def activate(self):
|
---|
| 1499 | """Fill the gate list."""
|
---|
| 1500 | self._listStore.clear()
|
---|
[70] | 1501 | self._gateList.set_sensitive(True)
|
---|
[51] | 1502 | occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
[629] | 1503 | for gate in lhbpGates.gates:
|
---|
[619] | 1504 | if gate.isAvailable(lhbpGates, occupiedGateNumbers):
|
---|
| 1505 | self._listStore.append([gate.number])
|
---|
[51] | 1506 |
|
---|
[70] | 1507 | def finalize(self):
|
---|
| 1508 | """Finalize the page."""
|
---|
| 1509 | self._gateList.set_sensitive(False)
|
---|
| 1510 |
|
---|
[51] | 1511 | def _selectionChanged(self, selection):
|
---|
| 1512 | """Called when the selection is changed."""
|
---|
| 1513 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
| 1514 |
|
---|
[73] | 1515 | def _backClicked(self, button):
|
---|
| 1516 | """Called when the Back button is pressed."""
|
---|
| 1517 | self.goBack()
|
---|
| 1518 |
|
---|
[51] | 1519 | def _forwardClicked(self, button):
|
---|
| 1520 | """Called when the forward button is clicked."""
|
---|
[94] | 1521 | if not self._completed:
|
---|
[278] | 1522 | self._gateSelected()
|
---|
[130] | 1523 | else:
|
---|
[754] | 1524 | self._wizard.jumpPage("connect")
|
---|
[51] | 1525 |
|
---|
[278] | 1526 | def _rowActivated(self, flightList, path, column):
|
---|
| 1527 | """Called when a row is activated."""
|
---|
| 1528 | if not self._completed:
|
---|
| 1529 | self._gateSelected()
|
---|
| 1530 |
|
---|
| 1531 | def _gateSelected(self):
|
---|
| 1532 | """Called when a gate has been selected."""
|
---|
| 1533 | selection = self._gateList.get_selection()
|
---|
| 1534 | (listStore, iter) = selection.get_selected()
|
---|
| 1535 | (gateNumber,) = listStore.get(iter, 0)
|
---|
| 1536 |
|
---|
| 1537 | self._wizard._departureGate = gateNumber
|
---|
| 1538 |
|
---|
| 1539 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 1540 | self._wizard._bookedFlight.tailNumber,
|
---|
[347] | 1541 | const.PLANE_HOME, gateNumber)
|
---|
[278] | 1542 |
|
---|
[51] | 1543 | def _planeUpdated(self, success):
|
---|
| 1544 | """Callback for the plane updating call."""
|
---|
| 1545 | if success is None or success:
|
---|
[754] | 1546 | self._wizard.jumpPage("connect")
|
---|
[51] | 1547 | else:
|
---|
[996] | 1548 | dialog = Gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
[999] | 1549 | type = Gtk.MessageType.ERROR,
|
---|
[107] | 1550 | message_format = xstr("gatesel_conflict"))
|
---|
[999] | 1551 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
[105] | 1552 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
[107] | 1553 | dialog.format_secondary_markup(xstr("gatesel_conflict_sec"))
|
---|
[51] | 1554 | dialog.run()
|
---|
| 1555 | dialog.hide()
|
---|
| 1556 |
|
---|
[126] | 1557 | self._wizard.getFleet(self._fleetRetrieved)
|
---|
[51] | 1558 |
|
---|
| 1559 | def _fleetRetrieved(self, fleet):
|
---|
| 1560 | """Called when the fleet has been retrieved."""
|
---|
| 1561 | if fleet is None:
|
---|
[754] | 1562 | self._wizard.jumpPage("connect")
|
---|
[51] | 1563 | else:
|
---|
| 1564 | self.activate()
|
---|
[347] | 1565 |
|
---|
[51] | 1566 | #-----------------------------------------------------------------------------
|
---|
| 1567 |
|
---|
[753] | 1568 | class RegisterPage(Page):
|
---|
| 1569 | """A page to enter the registration data."""
|
---|
| 1570 |
|
---|
| 1571 | # The minimal year of birth
|
---|
| 1572 | _minYearOfBirth = 1900
|
---|
| 1573 |
|
---|
| 1574 | # The maximal year of birth
|
---|
| 1575 | _maxYearOfBirth = datetime.date.today().year
|
---|
| 1576 |
|
---|
| 1577 | # The regular expression to check the e-mail address with
|
---|
| 1578 | _emailAddressRE = re.compile("[^@]+@[^@]+\.[^@]+")
|
---|
| 1579 |
|
---|
| 1580 | def __init__(self, wizard):
|
---|
| 1581 | """Construct the registration page."""
|
---|
[754] | 1582 | super(RegisterPage, self).__init__(wizard, "register",
|
---|
| 1583 | xstr("register_title"),
|
---|
[753] | 1584 | xstr("register_help"))
|
---|
| 1585 |
|
---|
[996] | 1586 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[753] | 1587 | xscale = 0.0, yscale = 0.0)
|
---|
| 1588 |
|
---|
[996] | 1589 | table = Gtk.Table(12, 4)
|
---|
[753] | 1590 | table.set_row_spacings(4)
|
---|
[990] | 1591 | table.set_col_spacings(24)
|
---|
[753] | 1592 | alignment.add(table)
|
---|
| 1593 | self.setMainWidget(alignment)
|
---|
| 1594 |
|
---|
[759] | 1595 | row = 0
|
---|
| 1596 |
|
---|
[996] | 1597 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[753] | 1598 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1599 | label = Gtk.Label(xstr("register_name1"))
|
---|
[753] | 1600 | label.set_use_underline(True)
|
---|
| 1601 | labelAlignment.add(label)
|
---|
[759] | 1602 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
| 1603 |
|
---|
[996] | 1604 | self._name1 = Gtk.Entry()
|
---|
[759] | 1605 | self._name1.connect("changed", self._updateButtons)
|
---|
| 1606 | self._name1.set_tooltip_text(xstr("register_name1_tooltip"))
|
---|
| 1607 | self._name1.set_width_chars(15)
|
---|
| 1608 | table.attach(self._name1, 1, 2, row, row+1)
|
---|
| 1609 | label.set_mnemonic_widget(self._name1)
|
---|
| 1610 |
|
---|
[996] | 1611 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[759] | 1612 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1613 | label = Gtk.Label(xstr("register_name2"))
|
---|
[759] | 1614 | label.set_use_underline(True)
|
---|
| 1615 | labelAlignment.add(label)
|
---|
[990] | 1616 | table.attach(labelAlignment, 2, 3, row, row+1)
|
---|
[759] | 1617 |
|
---|
[996] | 1618 | self._name2 = Gtk.Entry()
|
---|
[759] | 1619 | self._name2.connect("changed", self._updateButtons)
|
---|
| 1620 | self._name2.set_tooltip_text(xstr("register_name2_tooltip"))
|
---|
| 1621 | self._name2.set_width_chars(15)
|
---|
[990] | 1622 | table.attach(self._name2, 3, 4, row, row+1)
|
---|
[759] | 1623 | label.set_mnemonic_widget(self._name2)
|
---|
| 1624 |
|
---|
| 1625 | row += 1
|
---|
[753] | 1626 |
|
---|
[996] | 1627 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[753] | 1628 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1629 | label = Gtk.Label(xstr("register_year_of_birth"))
|
---|
[753] | 1630 | label.set_use_underline(True)
|
---|
| 1631 | labelAlignment.add(label)
|
---|
[759] | 1632 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1633 |
|
---|
[996] | 1634 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[753] | 1635 | xscale = 0.0, yscale = 0.0)
|
---|
| 1636 |
|
---|
[996] | 1637 | self._yearOfBirth = Gtk.SpinButton()
|
---|
[753] | 1638 | self._yearOfBirth.set_increments(step = 1, page = 10)
|
---|
| 1639 | self._yearOfBirth.set_range(min = RegisterPage._minYearOfBirth,
|
---|
| 1640 | max = RegisterPage._maxYearOfBirth)
|
---|
| 1641 | self._yearOfBirth.set_numeric(True)
|
---|
| 1642 | self._yearOfBirth.set_tooltip_text(xstr("register_year_of_birth_tooltip"))
|
---|
| 1643 | self._yearOfBirth.set_width_chars(5)
|
---|
| 1644 | self._yearOfBirth.connect("changed", self._updateButtons)
|
---|
| 1645 | self._yearOfBirth.connect("value-changed", self._updateButtons)
|
---|
| 1646 | alignment.add(self._yearOfBirth)
|
---|
[759] | 1647 | table.attach(alignment, 1, 2, row, row+1)
|
---|
[753] | 1648 | label.set_mnemonic_widget(self._yearOfBirth)
|
---|
| 1649 |
|
---|
[759] | 1650 | row += 1
|
---|
| 1651 |
|
---|
[996] | 1652 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[753] | 1653 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1654 | label = Gtk.Label(xstr("register_email"))
|
---|
[753] | 1655 | label.set_use_underline(True)
|
---|
| 1656 | labelAlignment.add(label)
|
---|
[759] | 1657 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1658 |
|
---|
[996] | 1659 | self._emailAddress = Gtk.Entry()
|
---|
[753] | 1660 | self._emailAddress.connect("changed", self._updateButtons)
|
---|
| 1661 | self._emailAddress.set_tooltip_text(xstr("register_email_tooltip"))
|
---|
[759] | 1662 | table.attach(self._emailAddress, 1, 2, row, row+1)
|
---|
[753] | 1663 | label.set_mnemonic_widget(self._emailAddress)
|
---|
| 1664 |
|
---|
[996] | 1665 | self._emailAddressPublic = Gtk.CheckButton(xstr("register_email_public"))
|
---|
[753] | 1666 | self._emailAddressPublic.set_use_underline(True)
|
---|
| 1667 | self._emailAddressPublic.set_tooltip_text(xstr("register_email_public_tooltip"))
|
---|
[990] | 1668 | table.attach(self._emailAddressPublic, 2, 4, row, row+1)
|
---|
[759] | 1669 |
|
---|
| 1670 | row += 1
|
---|
[753] | 1671 |
|
---|
[996] | 1672 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[753] | 1673 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1674 | label = Gtk.Label(xstr("register_vatsim_id"))
|
---|
[753] | 1675 | label.set_use_underline(True)
|
---|
| 1676 | labelAlignment.add(label)
|
---|
[759] | 1677 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1678 |
|
---|
[996] | 1679 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[753] | 1680 | xscale = 0.0, yscale = 0.0)
|
---|
| 1681 | self._vatsimID = IntegerEntry()
|
---|
| 1682 | self._vatsimID.connect("changed", self._updateButtons)
|
---|
| 1683 | self._vatsimID.set_tooltip_text(xstr("register_vatsim_id_tooltip"))
|
---|
| 1684 | self._vatsimID.set_width_chars(7)
|
---|
| 1685 | alignment.add(self._vatsimID)
|
---|
[759] | 1686 | table.attach(alignment, 1, 2, row, row+1)
|
---|
[753] | 1687 | label.set_mnemonic_widget(self._vatsimID)
|
---|
| 1688 |
|
---|
[996] | 1689 | labelAlignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
[753] | 1690 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1691 | label = Gtk.Label(xstr("register_ivao_id"))
|
---|
[753] | 1692 | label.set_use_underline(True)
|
---|
| 1693 | labelAlignment.add(label)
|
---|
[990] | 1694 | table.attach(labelAlignment, 2, 3, row, row+1)
|
---|
[753] | 1695 |
|
---|
[996] | 1696 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[753] | 1697 | xscale = 0.0, yscale = 0.0)
|
---|
| 1698 | self._ivaoID = IntegerEntry()
|
---|
| 1699 | self._ivaoID.connect("changed", self._updateButtons)
|
---|
| 1700 | self._ivaoID.set_tooltip_text(xstr("register_ivao_id_tooltip"))
|
---|
| 1701 | self._ivaoID.set_width_chars(7)
|
---|
| 1702 | alignment.add(self._ivaoID)
|
---|
[990] | 1703 | table.attach(alignment, 3, 4, row, row+1)
|
---|
[753] | 1704 | label.set_mnemonic_widget(self._ivaoID)
|
---|
| 1705 |
|
---|
[759] | 1706 | row += 1
|
---|
| 1707 |
|
---|
[996] | 1708 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[753] | 1709 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1710 | label = Gtk.Label(xstr("register_phone_num"))
|
---|
[753] | 1711 | label.set_use_underline(True)
|
---|
| 1712 | label.set_use_markup(True)
|
---|
| 1713 | labelAlignment.add(label)
|
---|
[759] | 1714 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1715 |
|
---|
[996] | 1716 | self._phoneNumber = Gtk.Entry()
|
---|
[753] | 1717 | self._phoneNumber.set_tooltip_text(xstr("register_phone_num_tooltip"))
|
---|
[759] | 1718 | table.attach(self._phoneNumber, 1, 2, row, row+1)
|
---|
[753] | 1719 | label.set_mnemonic_widget(self._phoneNumber)
|
---|
| 1720 |
|
---|
[759] | 1721 | row += 1
|
---|
| 1722 |
|
---|
[996] | 1723 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[753] | 1724 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1725 | label = Gtk.Label(xstr("register_nationality"))
|
---|
[753] | 1726 | label.set_use_underline(True)
|
---|
| 1727 | label.set_use_markup(True)
|
---|
| 1728 | labelAlignment.add(label)
|
---|
[759] | 1729 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1730 |
|
---|
| 1731 |
|
---|
[996] | 1732 | self._nationality = Gtk.Entry()
|
---|
[753] | 1733 | self._nationality.set_tooltip_text(xstr("register_nationality_tooltip"))
|
---|
[759] | 1734 | table.attach(self._nationality, 1, 2, row, row+1)
|
---|
[753] | 1735 | label.set_mnemonic_widget(self._nationality)
|
---|
| 1736 |
|
---|
[996] | 1737 | placeholder = Gtk.Label()
|
---|
[753] | 1738 | placeholder.set_text(xstr("register_password_mismatch"))
|
---|
| 1739 | placeholder.set_use_markup(True)
|
---|
| 1740 | placeholder.set_child_visible(False)
|
---|
| 1741 | placeholder.hide()
|
---|
[990] | 1742 | table.attach(placeholder, 2, 4, row, row+1)
|
---|
[759] | 1743 |
|
---|
| 1744 | row += 1
|
---|
[753] | 1745 |
|
---|
[996] | 1746 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[753] | 1747 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1748 | label = Gtk.Label(xstr("register_password"))
|
---|
[753] | 1749 | label.set_use_underline(True)
|
---|
| 1750 | labelAlignment.add(label)
|
---|
[759] | 1751 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1752 |
|
---|
[996] | 1753 | self._password = Gtk.Entry()
|
---|
[753] | 1754 | self._password.set_visibility(False)
|
---|
| 1755 | self._password.connect("changed", self._updateButtons)
|
---|
| 1756 | self._password.set_tooltip_text(xstr("register_password_tooltip"))
|
---|
[759] | 1757 | table.attach(self._password, 1, 2, row, row+1)
|
---|
[753] | 1758 | label.set_mnemonic_widget(self._password)
|
---|
| 1759 |
|
---|
[996] | 1760 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
[753] | 1761 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1762 | self._passwordStatus = Gtk.Label()
|
---|
[753] | 1763 | alignment.add(self._passwordStatus)
|
---|
[990] | 1764 | table.attach(alignment, 2, 4, row, row+1)
|
---|
[759] | 1765 |
|
---|
| 1766 | row += 1
|
---|
[753] | 1767 |
|
---|
[996] | 1768 | labelAlignment = Gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
[753] | 1769 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1770 | label = Gtk.Label(xstr("register_password2"))
|
---|
[753] | 1771 | label.set_use_underline(True)
|
---|
| 1772 | labelAlignment.add(label)
|
---|
[759] | 1773 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[753] | 1774 |
|
---|
[996] | 1775 | self._password2 = Gtk.Entry()
|
---|
[753] | 1776 | self._password2.set_visibility(False)
|
---|
| 1777 | self._password2.connect("changed", self._updateButtons)
|
---|
| 1778 | self._password2.set_tooltip_text(xstr("register_password2_tooltip"))
|
---|
[759] | 1779 | table.attach(self._password2, 1, 2, row, row+1)
|
---|
[753] | 1780 | label.set_mnemonic_widget(self._password2)
|
---|
| 1781 |
|
---|
[996] | 1782 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
[753] | 1783 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 1784 | self._password2Status = Gtk.Label()
|
---|
[753] | 1785 | alignment.add(self._password2Status)
|
---|
[990] | 1786 | table.attach(alignment, 2, 4, row, row+1)
|
---|
[759] | 1787 |
|
---|
| 1788 | row += 1
|
---|
[753] | 1789 |
|
---|
[996] | 1790 | self._rememberButton = Gtk.CheckButton(xstr("remember_password"))
|
---|
[753] | 1791 | self._rememberButton.set_use_underline(True)
|
---|
| 1792 | self._rememberButton.set_tooltip_text(xstr("login_remember_tooltip"))
|
---|
[990] | 1793 | table.attach(self._rememberButton, 1, 3, row, row+1)
|
---|
[753] | 1794 |
|
---|
| 1795 | cancelButton = \
|
---|
| 1796 | self.addButton(xstr("button_cancel"))
|
---|
| 1797 | cancelButton.connect("clicked", self._cancelClicked)
|
---|
| 1798 |
|
---|
| 1799 | self._registerButton = \
|
---|
| 1800 | self.addButton(xstr("button_register"), default = True,
|
---|
| 1801 | tooltip = xstr("button_register_tooltip"))
|
---|
| 1802 | self._registerButton.connect("clicked", self._registerClicked)
|
---|
| 1803 |
|
---|
| 1804 | self._updateButtons()
|
---|
| 1805 |
|
---|
[756] | 1806 | @property
|
---|
[759] | 1807 | def name1(self):
|
---|
| 1808 | """Get the first name component entered."""
|
---|
| 1809 | return self._name1.get_text()
|
---|
| 1810 |
|
---|
| 1811 | @property
|
---|
| 1812 | def name2(self):
|
---|
| 1813 | """Get the second name component entered."""
|
---|
| 1814 | return self._name2.get_text()
|
---|
[756] | 1815 |
|
---|
| 1816 | @property
|
---|
| 1817 | def yearOfBirth(self):
|
---|
| 1818 | """Get the year of birth."""
|
---|
| 1819 | yearOfBirthText = self._yearOfBirth.get_text()
|
---|
| 1820 | return int(yearOfBirthText) if yearOfBirthText else 0
|
---|
| 1821 |
|
---|
| 1822 | @property
|
---|
| 1823 | def emailAddress(self):
|
---|
| 1824 | """Get the e-mail address."""
|
---|
| 1825 | return self._emailAddress.get_text()
|
---|
| 1826 |
|
---|
| 1827 | @property
|
---|
| 1828 | def emailAddressPublic(self):
|
---|
| 1829 | """Get the whether the e-mail address is public."""
|
---|
| 1830 | return self._emailAddressPublic.get_active()
|
---|
| 1831 |
|
---|
| 1832 | @property
|
---|
| 1833 | def vatsimID(self):
|
---|
| 1834 | """Get the VATSIM ID."""
|
---|
| 1835 | return self._vatsimID.get_int()
|
---|
| 1836 |
|
---|
| 1837 | @property
|
---|
| 1838 | def ivaoID(self):
|
---|
| 1839 | """Get the IVAO ID."""
|
---|
| 1840 | return self._ivaoID.get_int()
|
---|
| 1841 |
|
---|
| 1842 | @property
|
---|
| 1843 | def phoneNumber(self):
|
---|
| 1844 | """Get the phone number."""
|
---|
| 1845 | return self._phoneNumber.get_text()
|
---|
| 1846 |
|
---|
| 1847 | @property
|
---|
| 1848 | def nationality(self):
|
---|
| 1849 | """Get the nationality."""
|
---|
| 1850 | return self._nationality.get_text()
|
---|
| 1851 |
|
---|
| 1852 | @property
|
---|
| 1853 | def password(self):
|
---|
| 1854 | """Get the password."""
|
---|
| 1855 | return self._password.get_text()
|
---|
| 1856 |
|
---|
| 1857 | @property
|
---|
| 1858 | def rememberPassword(self):
|
---|
| 1859 | """Get whether the password should be remembered."""
|
---|
| 1860 | return self._rememberButton.get_active()
|
---|
| 1861 |
|
---|
[753] | 1862 | def activate(self):
|
---|
| 1863 | """Setup the route from the booked flight."""
|
---|
| 1864 | self._yearOfBirth.set_value(0)
|
---|
| 1865 | self._yearOfBirth.set_text("")
|
---|
| 1866 | self._updateButtons()
|
---|
| 1867 |
|
---|
| 1868 | def _updateButtons(self, widget = None):
|
---|
| 1869 | """Update the sensitive state of the buttons"""
|
---|
[756] | 1870 | yearOfBirth = self.yearOfBirth
|
---|
| 1871 |
|
---|
| 1872 | emailAddress = self.emailAddress
|
---|
| 1873 | emailAddressMatch = RegisterPage._emailAddressRE.match(emailAddress)
|
---|
| 1874 |
|
---|
| 1875 | vatsimID = self.vatsimID
|
---|
| 1876 | ivaoID = self.ivaoID
|
---|
| 1877 |
|
---|
| 1878 | password = self.password
|
---|
[753] | 1879 | password2 = self._password2.get_text()
|
---|
| 1880 | if not password:
|
---|
| 1881 | self._passwordStatus.set_text("")
|
---|
| 1882 | elif len(password)<5:
|
---|
| 1883 | self._passwordStatus.set_text(xstr("register_password_too_short"))
|
---|
| 1884 | else:
|
---|
| 1885 | self._passwordStatus.set_text(xstr("register_password_ok"))
|
---|
| 1886 | self._passwordStatus.set_use_markup(True)
|
---|
| 1887 |
|
---|
| 1888 | if len(password)<5 or not password2:
|
---|
| 1889 | self._password2Status.set_text("")
|
---|
| 1890 | elif password!=password2:
|
---|
| 1891 | self._password2Status.set_text(xstr("register_password_mismatch"))
|
---|
| 1892 | else:
|
---|
| 1893 | self._password2Status.set_text(xstr("register_password_ok"))
|
---|
| 1894 | self._password2Status.set_use_markup(True)
|
---|
| 1895 |
|
---|
| 1896 | sensitive = \
|
---|
[759] | 1897 | len(self.name1)>0 and len(self.name2)>0 and \
|
---|
[753] | 1898 | yearOfBirth>=RegisterPage._minYearOfBirth and \
|
---|
| 1899 | yearOfBirth<=RegisterPage._maxYearOfBirth and \
|
---|
| 1900 | emailAddressMatch is not None and \
|
---|
| 1901 | (vatsimID>=800000 or ivaoID>=100000) and \
|
---|
| 1902 | len(password)>=5 and password==password2
|
---|
| 1903 |
|
---|
| 1904 | self._registerButton.set_sensitive(sensitive)
|
---|
| 1905 |
|
---|
| 1906 | def _cancelClicked(self, button):
|
---|
| 1907 | """Called when the Cancel button is clicked."""
|
---|
| 1908 | self.goBack()
|
---|
| 1909 |
|
---|
| 1910 | def _registerClicked(self, button):
|
---|
| 1911 | """Called when the Register button is clicked."""
|
---|
[759] | 1912 | nameOrder = xstr("register_nameorder")
|
---|
| 1913 |
|
---|
| 1914 | if nameOrder=="eastern":
|
---|
| 1915 | surName = self.name1
|
---|
| 1916 | firstName = self.name2
|
---|
| 1917 | else:
|
---|
| 1918 | surName = self.name2
|
---|
| 1919 | firstName = self.name1
|
---|
| 1920 |
|
---|
| 1921 | nationality = self.nationality.lower()
|
---|
| 1922 |
|
---|
| 1923 | if getLanguage().lower()=="hu" or nationality.find("hung")!=-1 or \
|
---|
| 1924 | nationality.find("magyar")!=-1:
|
---|
| 1925 | requestedNameOrder = "eastern"
|
---|
| 1926 | else:
|
---|
| 1927 | requestedNameOrder = "western"
|
---|
| 1928 |
|
---|
| 1929 | registrationData = web.Registration(surName, firstName,
|
---|
| 1930 | requestedNameOrder,
|
---|
| 1931 | self.yearOfBirth,
|
---|
[756] | 1932 | self.emailAddress,
|
---|
| 1933 | self.emailAddressPublic,
|
---|
| 1934 | self.vatsimID, self.ivaoID,
|
---|
| 1935 | self.phoneNumber, self.nationality,
|
---|
| 1936 | self.password)
|
---|
[919] | 1937 | print("Registering with data:")
|
---|
| 1938 | print(" name:", self.name1, self.name2, registrationData.firstName, registrationData.surName, requestedNameOrder)
|
---|
| 1939 | print(" yearOfBirth:", self.yearOfBirth, registrationData.yearOfBirth)
|
---|
| 1940 | print(" emailAddress:", self.emailAddress, registrationData.emailAddress)
|
---|
| 1941 | print(" emailAddressPublic:", self.emailAddressPublic, registrationData.emailAddressPublic)
|
---|
| 1942 | print(" vatsimID:", self.vatsimID, registrationData.vatsimID)
|
---|
| 1943 | print(" ivaoID:", self.ivaoID, registrationData.ivaoID)
|
---|
| 1944 | print(" phoneNumber:", self.phoneNumber, registrationData.phoneNumber)
|
---|
| 1945 | print(" nationality:", self.nationality, registrationData.nationality)
|
---|
[756] | 1946 |
|
---|
| 1947 | gui = self._wizard.gui
|
---|
| 1948 | gui.beginBusy(xstr("register_busy"))
|
---|
| 1949 | gui.webHandler.register(self._registerResultCallback, registrationData)
|
---|
| 1950 |
|
---|
| 1951 | def _registerResultCallback(self, returned, result):
|
---|
| 1952 | """Called when the registration result is available."""
|
---|
[995] | 1953 | GObject.idle_add(self._handleRegisterResult, returned, result)
|
---|
[756] | 1954 |
|
---|
| 1955 | def _handleRegisterResult(self, returned, result):
|
---|
| 1956 | """Handle the registration result."""
|
---|
| 1957 | gui = self._wizard.gui
|
---|
| 1958 |
|
---|
| 1959 | gui.endBusy()
|
---|
| 1960 |
|
---|
[919] | 1961 | print("Registration result:")
|
---|
| 1962 | print(" returned:", returned)
|
---|
[756] | 1963 | if returned:
|
---|
[919] | 1964 | print(" registered:", result.registered)
|
---|
[756] | 1965 | if result.registered:
|
---|
[919] | 1966 | print(" pilotID", result.pilotID)
|
---|
| 1967 | print(" loggedIn", result.loggedIn)
|
---|
| 1968 | print(" emailAlreadyRegistered:", result.emailAlreadyRegistered)
|
---|
| 1969 | print(" invalidData:", result.invalidData)
|
---|
[756] | 1970 |
|
---|
| 1971 | registrationOK = returned and result.registered
|
---|
| 1972 |
|
---|
| 1973 | message = xstr("register_ok") if registrationOK \
|
---|
| 1974 | else xstr("register_failed")
|
---|
| 1975 | secondaryMessage = None
|
---|
| 1976 | if registrationOK:
|
---|
| 1977 | if result.loggedIn:
|
---|
| 1978 | secondaryMessage = xstr("register_info") % (result.pilotID,)
|
---|
| 1979 | else:
|
---|
| 1980 | secondaryMessage = xstr("register_nologin") % (result.pilotID,)
|
---|
[999] | 1981 | messageType = Gtk.MessageType.INFO
|
---|
[756] | 1982 |
|
---|
| 1983 | config = gui.config
|
---|
| 1984 | config.pilotID = result.pilotID
|
---|
| 1985 | config.rememberPassword = self.rememberPassword
|
---|
| 1986 | if config.rememberPassword:
|
---|
| 1987 | config.password = self.password
|
---|
| 1988 | else:
|
---|
| 1989 | config.password = ""
|
---|
| 1990 |
|
---|
| 1991 | config.save()
|
---|
| 1992 | elif returned and result.emailAlreadyRegistered:
|
---|
| 1993 | secondaryMessage = xstr("register_email_already")
|
---|
[999] | 1994 | messageType = Gtk.MessageType.ERROR
|
---|
[756] | 1995 | elif returned and result.invalidData:
|
---|
| 1996 | secondaryMessage = xstr("register_invalid_data")
|
---|
[999] | 1997 | messageType = Gtk.MessageType.ERROR
|
---|
[756] | 1998 | else:
|
---|
| 1999 | secondaryMessage = xstr("register_error")
|
---|
[999] | 2000 | messageType = Gtk.MessageType.ERROR
|
---|
[756] | 2001 |
|
---|
[996] | 2002 | dialog = Gtk.MessageDialog(parent = gui.mainWindow,
|
---|
[756] | 2003 | type = messageType,
|
---|
| 2004 | message_format = message)
|
---|
| 2005 | dialog.set_title(WINDOW_TITLE_BASE + " - " +
|
---|
| 2006 | xstr("register_result_title"))
|
---|
| 2007 | dialog.format_secondary_markup(secondaryMessage)
|
---|
| 2008 |
|
---|
| 2009 | dialog.add_button(xstr("button_ok"), 0)
|
---|
| 2010 |
|
---|
| 2011 | dialog.run()
|
---|
| 2012 | dialog.hide()
|
---|
| 2013 |
|
---|
| 2014 | if registrationOK:
|
---|
| 2015 | if result.loggedIn:
|
---|
[771] | 2016 | self._wizard._loginResult = result
|
---|
[756] | 2017 | self._wizard.nextPage()
|
---|
| 2018 | else:
|
---|
| 2019 | self._wizard.jumpPage("login")
|
---|
[753] | 2020 |
|
---|
| 2021 | #-----------------------------------------------------------------------------
|
---|
| 2022 |
|
---|
| 2023 | class StudentPage(Page):
|
---|
| 2024 | """A page displayed to students after logging in."""
|
---|
[762] | 2025 | _entryExamStatusQueryInterval = 60*1000
|
---|
| 2026 |
|
---|
[753] | 2027 | def __init__(self, wizard):
|
---|
| 2028 | """Construct the student page."""
|
---|
[754] | 2029 | super(StudentPage, self).__init__(wizard, "student",
|
---|
| 2030 | xstr("student_title"),
|
---|
[753] | 2031 | xstr("student_help"))
|
---|
| 2032 |
|
---|
[769] | 2033 |
|
---|
| 2034 | self._getEntryExamStatusCancelled = False
|
---|
| 2035 |
|
---|
[996] | 2036 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[762] | 2037 | xscale = 0.5, yscale = 0.0)
|
---|
| 2038 |
|
---|
[996] | 2039 | table = Gtk.Table(6, 4)
|
---|
[762] | 2040 | table.set_row_spacings(4)
|
---|
[769] | 2041 | table.set_col_spacings(0)
|
---|
[764] | 2042 | table.set_homogeneous(False)
|
---|
[762] | 2043 | alignment.add(table)
|
---|
| 2044 | self.setMainWidget(alignment)
|
---|
| 2045 |
|
---|
| 2046 | row = 0
|
---|
| 2047 |
|
---|
[996] | 2048 | labelAlignment = Gtk.Alignment(xalign=0.0, yalign = 0.5,
|
---|
[764] | 2049 | xscale=0.0, yscale = 0.0)
|
---|
[996] | 2050 | label = Gtk.Label(xstr("student_entry_exam_status"))
|
---|
[769] | 2051 | label.set_alignment(0.0, 0.5)
|
---|
[764] | 2052 | labelAlignment.add(label)
|
---|
[769] | 2053 | labelAlignment.resize_children()
|
---|
[999] | 2054 | table.attach(labelAlignment, 0, 1, row, row + 1,
|
---|
| 2055 | xoptions = Gtk.AttachOptions.FILL)
|
---|
[764] | 2056 |
|
---|
[996] | 2057 | alignment = Gtk.Alignment(xalign=0.0, yalign = 0.5,
|
---|
[764] | 2058 | xscale=1.0, yscale = 0.0)
|
---|
[996] | 2059 | self._entryExamStatus = Gtk.Label()
|
---|
[764] | 2060 | self._entryExamStatus.set_use_markup(True)
|
---|
| 2061 | self._entryExamStatus.set_alignment(0.0, 0.5)
|
---|
| 2062 | alignment.add(self._entryExamStatus)
|
---|
[769] | 2063 | alignment.resize_children()
|
---|
| 2064 | table.attach(alignment, 1, 4, row, row + 1)
|
---|
[764] | 2065 |
|
---|
| 2066 | row += 1
|
---|
| 2067 |
|
---|
[996] | 2068 | buttonAlignment = Gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 2069 | button = self._entryExamButton = Gtk.Button(xstr("student_entry_exam"))
|
---|
[762] | 2070 | button.set_use_underline(True)
|
---|
| 2071 | button.connect("clicked", self._entryExamClicked)
|
---|
| 2072 | button.set_tooltip_text(xstr("student_entry_exam_tooltip"))
|
---|
| 2073 |
|
---|
| 2074 | buttonAlignment.add(button)
|
---|
[999] | 2075 | table.attach(buttonAlignment, 0, 4, row, row + 1,
|
---|
| 2076 | xoptions = Gtk.AttachOptions.FILL,
|
---|
[764] | 2077 | ypadding = 4)
|
---|
[762] | 2078 |
|
---|
[769] | 2079 | row += 3
|
---|
| 2080 |
|
---|
[996] | 2081 | labelAlignment = Gtk.Alignment(xalign=0.0, yalign = 0.5,
|
---|
[769] | 2082 | xscale=0.0, yscale = 0.0)
|
---|
[996] | 2083 | label = Gtk.Label(xstr("student_check_flight_status"))
|
---|
[769] | 2084 | labelAlignment.add(label)
|
---|
[999] | 2085 | table.attach(labelAlignment, 0, 1, row, row + 1,
|
---|
| 2086 | xoptions = Gtk.AttachOptions.FILL)
|
---|
[769] | 2087 |
|
---|
[996] | 2088 | alignment = Gtk.Alignment(xalign=0.0, yalign = 0.5,
|
---|
[769] | 2089 | xscale=1.0, yscale = 0.0)
|
---|
[996] | 2090 | self._checkFlightStatus = Gtk.Label()
|
---|
[769] | 2091 | self._checkFlightStatus.set_use_markup(True)
|
---|
| 2092 | self._checkFlightStatus.set_alignment(0.0, 0.5)
|
---|
| 2093 | alignment.add(self._checkFlightStatus)
|
---|
| 2094 | table.attach(alignment, 1, 4, row, row + 1)
|
---|
| 2095 |
|
---|
| 2096 | row += 1
|
---|
| 2097 |
|
---|
[996] | 2098 | alignment = Gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 2099 |
|
---|
| 2100 | hbox = Gtk.HBox()
|
---|
[769] | 2101 | hbox.set_homogeneous(False)
|
---|
| 2102 | hbox.set_spacing(0)
|
---|
| 2103 |
|
---|
[996] | 2104 | aircraftTypesModel = Gtk.ListStore(str, int)
|
---|
[769] | 2105 | for aircraftType in web.BookedFlight.checkFlightTypes:
|
---|
| 2106 | aircraftTypesModel.append([aircraftNames[aircraftType],
|
---|
| 2107 | aircraftType])
|
---|
| 2108 |
|
---|
[996] | 2109 | aircraftTypeAlignment = Gtk.Alignment(xalign = 0.0, xscale = 1.0)
|
---|
| 2110 |
|
---|
| 2111 | self._aircraftType = Gtk.ComboBox(model = aircraftTypesModel)
|
---|
| 2112 | renderer = Gtk.CellRendererText()
|
---|
[769] | 2113 | self._aircraftType.pack_start(renderer, True)
|
---|
| 2114 | self._aircraftType.add_attribute(renderer, "text", 0)
|
---|
| 2115 | self._aircraftType.set_tooltip_text(xstr("student_check_flight_type_tooltip"))
|
---|
| 2116 | self._aircraftType.set_active(0)
|
---|
| 2117 |
|
---|
| 2118 | aircraftTypeAlignment.add(self._aircraftType)
|
---|
| 2119 |
|
---|
| 2120 | hbox.pack_start(aircraftTypeAlignment, False, False, 0)
|
---|
| 2121 |
|
---|
[996] | 2122 | buttonAlignment = Gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 2123 | button = self._checkFlightButton = Gtk.Button(xstr("student_check_flight"))
|
---|
[769] | 2124 | button.set_use_underline(True)
|
---|
| 2125 | button.connect("clicked", self._checkFlightClicked)
|
---|
| 2126 | button.set_tooltip_text(xstr("student_check_flight_tooltip"))
|
---|
| 2127 |
|
---|
| 2128 | hbox.pack_start(button, True, True, 0)
|
---|
| 2129 |
|
---|
| 2130 | alignment.add(hbox)
|
---|
[999] | 2131 | table.attach(alignment, 0, 4, row, row + 1,
|
---|
| 2132 | xoptions = Gtk.AttachOptions.FILL)
|
---|
[769] | 2133 |
|
---|
| 2134 | @property
|
---|
| 2135 | def aircraftType(self):
|
---|
| 2136 | """Get the type of the aircraft used to perform the check flight."""
|
---|
| 2137 | index = self._aircraftType.get_active()
|
---|
| 2138 | return self._aircraftType.get_model()[index][1]
|
---|
| 2139 |
|
---|
[762] | 2140 | def activate(self):
|
---|
| 2141 | """Activate the student page."""
|
---|
[919] | 2142 | print("StudentPage.activate")
|
---|
[769] | 2143 | self._getEntryExamStatusCancelled = False
|
---|
| 2144 |
|
---|
[762] | 2145 | loginResult = self._wizard.loginResult
|
---|
[764] | 2146 | self._entryExamLink = loginResult.entryExamLink
|
---|
| 2147 |
|
---|
| 2148 | self._updateEntryExamStatus(loginResult.entryExamPassed)
|
---|
[762] | 2149 | self._getEntryExamStatus()
|
---|
| 2150 |
|
---|
[769] | 2151 | # FIXME: call with real value
|
---|
| 2152 | self._updateCheckFlightStatus(self._wizard.loginResult.checkFlightStatus)
|
---|
| 2153 |
|
---|
| 2154 | def finalize(self):
|
---|
| 2155 | """Finalize the page."""
|
---|
[919] | 2156 | print("StudentPage.finalize")
|
---|
[769] | 2157 | self._getEntryExamStatusCancelled = True
|
---|
| 2158 |
|
---|
[762] | 2159 | def _entryExamClicked(self, button):
|
---|
| 2160 | """Called when the entry exam button is clicked."""
|
---|
[764] | 2161 | webbrowser.open(self._entryExamLink)
|
---|
[762] | 2162 |
|
---|
| 2163 | def _getEntryExamStatus(self):
|
---|
| 2164 | """Initiate the query of the entry exam status after the interval."""
|
---|
[769] | 2165 | if not self._getEntryExamStatusCancelled:
|
---|
[995] | 2166 | GObject.timeout_add(StudentPage._entryExamStatusQueryInterval,
|
---|
[769] | 2167 | lambda: self._wizard.gui.webHandler. \
|
---|
| 2168 | getEntryExamStatus(self._entryExamStatusCallback))
|
---|
[762] | 2169 |
|
---|
| 2170 | def _entryExamStatusCallback(self, returned, result):
|
---|
| 2171 | """Called when the entry exam status is available."""
|
---|
[995] | 2172 | GObject.idle_add(self._handleEntryExamStatus, returned, result)
|
---|
[762] | 2173 |
|
---|
| 2174 | def _handleEntryExamStatus(self, returned, result):
|
---|
| 2175 | """Called when the entry exam status is availabe."""
|
---|
[919] | 2176 | print("_handleEntryExamStatus", returned, result)
|
---|
[769] | 2177 | if returned and not self._getEntryExamStatusCancelled:
|
---|
[764] | 2178 | self._entryExamLink = result.entryExamLink
|
---|
| 2179 | self._updateEntryExamStatus(result.entryExamPassed)
|
---|
[769] | 2180 | if result.madeFO:
|
---|
| 2181 | self._madeFO()
|
---|
| 2182 | else:
|
---|
| 2183 | self._getEntryExamStatus()
|
---|
[762] | 2184 |
|
---|
[764] | 2185 | def _updateEntryExamStatus(self, passed):
|
---|
| 2186 | """Update the entry exam status display and button."""
|
---|
| 2187 | self._entryExamStatus.set_text(xstr("student_entry_exam_passed")
|
---|
| 2188 | if passed else
|
---|
| 2189 | xstr("student_entry_exam_not_passed"))
|
---|
| 2190 | self._entryExamStatus.set_use_markup(True)
|
---|
| 2191 | self._entryExamButton.set_sensitive(not passed)
|
---|
[772] | 2192 | self._wizard._loginResult.entryExamPassed = passed
|
---|
[764] | 2193 |
|
---|
[769] | 2194 | def _checkFlightClicked(self, button):
|
---|
| 2195 | """Called when the check flight button is clicked."""
|
---|
| 2196 | aircraftType = self.aircraftType
|
---|
| 2197 | self._wizard._bookedFlight = \
|
---|
| 2198 | web.BookedFlight.forCheckFlight(aircraftType)
|
---|
| 2199 | self._wizard.gui.enableFlightInfo(aircraftType)
|
---|
| 2200 | self._wizard.jumpPage("connect")
|
---|
| 2201 |
|
---|
| 2202 | def _updateCheckFlightStatus(self, passed):
|
---|
| 2203 | """Update the status of the check flight."""
|
---|
| 2204 | self._aircraftType.set_sensitive(not passed)
|
---|
| 2205 | self._checkFlightStatus.set_text(xstr("student_check_flight_passed")
|
---|
| 2206 | if passed else
|
---|
| 2207 | xstr("student_check_flight_not_passed"))
|
---|
| 2208 | self._checkFlightStatus.set_use_markup(True)
|
---|
| 2209 | self._checkFlightButton.set_sensitive(not passed)
|
---|
| 2210 |
|
---|
| 2211 | def _madeFO(self):
|
---|
| 2212 | """Handle the event when the pilot has become a first officer."""
|
---|
| 2213 | wizard = self._wizard
|
---|
| 2214 | loginResult = wizard.loginResult
|
---|
| 2215 | loginResult.rank = "FO"
|
---|
| 2216 |
|
---|
| 2217 | gui = wizard.gui
|
---|
| 2218 |
|
---|
[996] | 2219 | dialog = Gtk.MessageDialog(parent = gui.mainWindow,
|
---|
[999] | 2220 | type = Gtk.MessageType.INFO,
|
---|
[769] | 2221 | message_format = xstr("student_fo"))
|
---|
| 2222 |
|
---|
[999] | 2223 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
[769] | 2224 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 2225 | secondary = xstr("student_fo_secondary")
|
---|
| 2226 | dialog.format_secondary_markup(secondary)
|
---|
| 2227 | dialog.run()
|
---|
| 2228 | dialog.hide()
|
---|
| 2229 |
|
---|
| 2230 | gui.reset()
|
---|
| 2231 |
|
---|
[753] | 2232 | #-----------------------------------------------------------------------------
|
---|
| 2233 |
|
---|
[51] | 2234 | class ConnectPage(Page):
|
---|
| 2235 | """Page which displays the departure airport and gate (if at LHBP)."""
|
---|
| 2236 | def __init__(self, wizard):
|
---|
| 2237 | """Construct the connect page."""
|
---|
[78] | 2238 | help = "Load the aircraft below into the simulator and park it\n" \
|
---|
| 2239 | "at the given airport, at the gate below, if present.\n\n" \
|
---|
[51] | 2240 | "Then press the Connect button to connect to the simulator."
|
---|
[94] | 2241 | completedHelp = "The basic data of your flight can be read below."
|
---|
[754] | 2242 | super(ConnectPage, self).__init__(wizard, "connect",
|
---|
| 2243 | xstr("connect_title"),
|
---|
[107] | 2244 | xstr("connect_help"),
|
---|
| 2245 | completedHelp = xstr("connect_chelp"))
|
---|
[347] | 2246 |
|
---|
[501] | 2247 | self._selectSimulator = os.name=="nt" or "FORCE_SELECT_SIM" in os.environ
|
---|
| 2248 |
|
---|
[996] | 2249 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[51] | 2250 | xscale = 0.0, yscale = 0.0)
|
---|
| 2251 |
|
---|
[996] | 2252 | table = Gtk.Table(7 if self._selectSimulator else 5, 2)
|
---|
[51] | 2253 | table.set_row_spacings(4)
|
---|
| 2254 | table.set_col_spacings(16)
|
---|
| 2255 | table.set_homogeneous(True)
|
---|
| 2256 | alignment.add(table)
|
---|
| 2257 | self.setMainWidget(alignment)
|
---|
| 2258 |
|
---|
[996] | 2259 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 2260 | label = Gtk.Label(xstr("connect_flightno"))
|
---|
[51] | 2261 | labelAlignment.add(label)
|
---|
| 2262 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 2263 |
|
---|
[996] | 2264 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2265 | self._flightNumber = Gtk.Label()
|
---|
[191] | 2266 | self._flightNumber.set_width_chars(9)
|
---|
[78] | 2267 | self._flightNumber.set_alignment(0.0, 0.5)
|
---|
| 2268 | labelAlignment.add(self._flightNumber)
|
---|
| 2269 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
| 2270 |
|
---|
[996] | 2271 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 2272 | label = Gtk.Label(xstr("connect_acft"))
|
---|
[78] | 2273 | labelAlignment.add(label)
|
---|
| 2274 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 2275 |
|
---|
[996] | 2276 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2277 | self._aircraft = Gtk.Label()
|
---|
[78] | 2278 | self._aircraft.set_width_chars(25)
|
---|
| 2279 | self._aircraft.set_alignment(0.0, 0.5)
|
---|
| 2280 | labelAlignment.add(self._aircraft)
|
---|
| 2281 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
| 2282 |
|
---|
[996] | 2283 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 2284 | label = Gtk.Label(xstr("connect_tailno"))
|
---|
[78] | 2285 | labelAlignment.add(label)
|
---|
| 2286 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
| 2287 |
|
---|
[996] | 2288 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2289 | self._tailNumber = Gtk.Label()
|
---|
[80] | 2290 | self._tailNumber.set_width_chars(10)
|
---|
[78] | 2291 | self._tailNumber.set_alignment(0.0, 0.5)
|
---|
| 2292 | labelAlignment.add(self._tailNumber)
|
---|
| 2293 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
| 2294 |
|
---|
[996] | 2295 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 2296 | label = Gtk.Label(xstr("connect_airport"))
|
---|
[78] | 2297 | labelAlignment.add(label)
|
---|
| 2298 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
| 2299 |
|
---|
[996] | 2300 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2301 | self._departureICAO = Gtk.Label()
|
---|
[80] | 2302 | self._departureICAO.set_width_chars(6)
|
---|
[51] | 2303 | self._departureICAO.set_alignment(0.0, 0.5)
|
---|
| 2304 | labelAlignment.add(self._departureICAO)
|
---|
[78] | 2305 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
[51] | 2306 |
|
---|
[996] | 2307 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 2308 | label = Gtk.Label(xstr("connect_gate"))
|
---|
[51] | 2309 | labelAlignment.add(label)
|
---|
[78] | 2310 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
[51] | 2311 |
|
---|
[996] | 2312 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2313 | self._departureGate = Gtk.Label()
|
---|
[51] | 2314 | self._departureGate.set_width_chars(5)
|
---|
| 2315 | self._departureGate.set_alignment(0.0, 0.5)
|
---|
| 2316 | labelAlignment.add(self._departureGate)
|
---|
[78] | 2317 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
[51] | 2318 |
|
---|
[501] | 2319 | if self._selectSimulator:
|
---|
[996] | 2320 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0, yalign=0.5)
|
---|
| 2321 | label = Gtk.Label(xstr("connect_sim"))
|
---|
[501] | 2322 | labelAlignment.add(label)
|
---|
| 2323 | table.attach(labelAlignment, 0, 1, 5, 7)
|
---|
| 2324 |
|
---|
[996] | 2325 | selectAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0, yalign=0.5)
|
---|
| 2326 |
|
---|
| 2327 | selectBox = Gtk.HBox()
|
---|
[994] | 2328 | self._selectMSFS = \
|
---|
[996] | 2329 | Gtk.RadioButton.new_with_mnemonic_from_widget(None,
|
---|
[994] | 2330 | xstr("connect_sim_msfs"))
|
---|
[501] | 2331 |
|
---|
| 2332 | selectBox.pack_start(self._selectMSFS, False, False, 0);
|
---|
| 2333 |
|
---|
[994] | 2334 | self._selectXPlane = \
|
---|
[996] | 2335 | Gtk.RadioButton.new_with_mnemonic_from_widget(self._selectMSFS,
|
---|
[994] | 2336 | xstr("connect_sim_xplane"))
|
---|
[501] | 2337 |
|
---|
| 2338 | selectBox.pack_start(self._selectXPlane, False, False, 8);
|
---|
| 2339 |
|
---|
| 2340 | selectAlignment.add(selectBox)
|
---|
| 2341 | table.attach(selectAlignment, 1, 2, 5, 7)
|
---|
| 2342 |
|
---|
| 2343 |
|
---|
[208] | 2344 | self.addCancelFlightButton()
|
---|
| 2345 |
|
---|
[769] | 2346 | self._previousButton = \
|
---|
| 2347 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[70] | 2348 |
|
---|
[107] | 2349 | self._button = self.addButton(xstr("button_connect"), default = True,
|
---|
| 2350 | tooltip = xstr("button_connect_tooltip"))
|
---|
[70] | 2351 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[51] | 2352 |
|
---|
| 2353 | def activate(self):
|
---|
[60] | 2354 | """Setup the departure information."""
|
---|
[107] | 2355 | self._button.set_label(xstr("button_connect"))
|
---|
[70] | 2356 | self._button.set_use_underline(True)
|
---|
[107] | 2357 | self._button.set_tooltip_text(xstr("button_connect_tooltip"))
|
---|
[70] | 2358 | self._button.disconnect(self._clickedID)
|
---|
| 2359 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[78] | 2360 |
|
---|
| 2361 | bookedFlight = self._wizard._bookedFlight
|
---|
| 2362 |
|
---|
| 2363 | self._flightNumber.set_markup("<b>" + bookedFlight.callsign + "</b>")
|
---|
| 2364 |
|
---|
[191] | 2365 | aircraftType = aircraftNames[bookedFlight.aircraftType]
|
---|
[78] | 2366 | self._aircraft.set_markup("<b>" + aircraftType + "</b>")
|
---|
[347] | 2367 |
|
---|
[78] | 2368 | self._tailNumber.set_markup("<b>" + bookedFlight.tailNumber + "</b>")
|
---|
| 2369 |
|
---|
| 2370 | icao = bookedFlight.departureICAO
|
---|
[51] | 2371 | self._departureICAO.set_markup("<b>" + icao + "</b>")
|
---|
| 2372 | gate = self._wizard._departureGate
|
---|
| 2373 | if gate!="-":
|
---|
| 2374 | gate = "<b>" + gate + "</b>"
|
---|
| 2375 | self._departureGate.set_markup(gate)
|
---|
| 2376 |
|
---|
[501] | 2377 | if self._selectSimulator:
|
---|
[503] | 2378 | config = self._wizard.gui.config
|
---|
| 2379 | self._selectMSFS.set_active(config.defaultMSFS)
|
---|
| 2380 | self._selectXPlane.set_active(not config.defaultMSFS)
|
---|
[501] | 2381 |
|
---|
[769] | 2382 | self._previousButton.set_sensitive(not self._wizard.entranceExam)
|
---|
| 2383 |
|
---|
[70] | 2384 | def finalize(self):
|
---|
| 2385 | """Finalize the page."""
|
---|
[107] | 2386 | self._button.set_label(xstr("button_next"))
|
---|
| 2387 | self._button.set_use_underline(True)
|
---|
| 2388 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
[70] | 2389 | self._button.disconnect(self._clickedID)
|
---|
| 2390 | self._clickedID = self._button.connect("clicked", self._forwardClicked)
|
---|
| 2391 |
|
---|
| 2392 | def _backClicked(self, button):
|
---|
| 2393 | """Called when the Back button is pressed."""
|
---|
| 2394 | self.goBack()
|
---|
| 2395 |
|
---|
[51] | 2396 | def _connectClicked(self, button):
|
---|
| 2397 | """Called when the Connect button is pressed."""
|
---|
[501] | 2398 | if self._selectSimulator:
|
---|
| 2399 | simulatorType = const.SIM_MSFS9 if self._selectMSFS.get_active() \
|
---|
| 2400 | else const.SIM_XPLANE10
|
---|
| 2401 | else:
|
---|
| 2402 | simulatorType = const.SIM_MSFS9 if os.name=="nt" \
|
---|
[503] | 2403 | else const.SIM_XPLANE10
|
---|
| 2404 |
|
---|
| 2405 | config = self._wizard.gui.config
|
---|
| 2406 | config.defaultMSFS = simulatorType == const.SIM_MSFS9
|
---|
| 2407 | config.save()
|
---|
| 2408 |
|
---|
[501] | 2409 | self._wizard._connectSimulator(simulatorType)
|
---|
[51] | 2410 |
|
---|
[70] | 2411 | def _forwardClicked(self, button):
|
---|
| 2412 | """Called when the Forward button is pressed."""
|
---|
| 2413 | self._wizard.nextPage()
|
---|
| 2414 |
|
---|
[42] | 2415 | #-----------------------------------------------------------------------------
|
---|
| 2416 |
|
---|
[59] | 2417 | class PayloadPage(Page):
|
---|
| 2418 | """Page to allow setting up the payload."""
|
---|
| 2419 | def __init__(self, wizard):
|
---|
| 2420 | """Construct the page."""
|
---|
[754] | 2421 | super(PayloadPage, self).__init__(wizard, "payload",
|
---|
| 2422 | xstr("payload_title"),
|
---|
[1033] | 2423 | xstr("payload_help") + "\n\n \n \n",
|
---|
[107] | 2424 | completedHelp = xstr("payload_chelp"))
|
---|
[59] | 2425 |
|
---|
[996] | 2426 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[60] | 2427 | xscale = 0.0, yscale = 0.0)
|
---|
| 2428 |
|
---|
[996] | 2429 | table = Gtk.Table(7, 3)
|
---|
[60] | 2430 | table.set_row_spacings(4)
|
---|
| 2431 | table.set_col_spacings(16)
|
---|
| 2432 | table.set_homogeneous(False)
|
---|
| 2433 | alignment.add(table)
|
---|
| 2434 | self.setMainWidget(alignment)
|
---|
| 2435 |
|
---|
[1033] | 2436 | self._crewLabel = label = Gtk.Label(xstr("payload_crew"))
|
---|
[309] | 2437 | label.set_use_underline(True)
|
---|
[60] | 2438 | label.set_alignment(0.0, 0.5)
|
---|
| 2439 | table.attach(label, 0, 1, 0, 1)
|
---|
| 2440 |
|
---|
[1033] | 2441 | self._numCockpitCrew = Gtk.Label()
|
---|
| 2442 |
|
---|
| 2443 | self._numCabinCrew = IntegerEntry(defaultValue = 0)
|
---|
| 2444 | self._numCabinCrew.set_width_chars(6)
|
---|
| 2445 | self._numCabinCrew.connect("integer-changed", self._weightChanged)
|
---|
| 2446 | self._numCabinCrew.set_tooltip_text(xstr("payload_crew_tooltip"))
|
---|
| 2447 |
|
---|
| 2448 | crewBox = Gtk.HBox()
|
---|
| 2449 | crewBox.pack_start(self._numCockpitCrew, False, False, 0)
|
---|
| 2450 | crewBox.pack_start(Gtk.Label("+"), False, False, 4)
|
---|
| 2451 | crewBox.pack_start(self._numCabinCrew, False, False, 0)
|
---|
| 2452 | crewBox.set_halign(Gtk.Align.END)
|
---|
| 2453 |
|
---|
| 2454 | table.attach(crewBox, 1, 2, 0, 1)
|
---|
| 2455 | label.set_mnemonic_widget(self._numCabinCrew)
|
---|
| 2456 |
|
---|
| 2457 | label = Gtk.Label(xstr("payload_crew_info"))
|
---|
| 2458 | label.set_halign(Gtk.Align.START)
|
---|
| 2459 | table.attach(label, 2, 3, 0, 1)
|
---|
| 2460 |
|
---|
| 2461 | self._paxLabel = label = Gtk.Label(xstr("payload_pax"))
|
---|
[309] | 2462 | label.set_use_underline(True)
|
---|
[60] | 2463 | label.set_alignment(0.0, 0.5)
|
---|
| 2464 | table.attach(label, 0, 1, 1, 2)
|
---|
| 2465 |
|
---|
[347] | 2466 | self._numPassengers = IntegerEntry(defaultValue = 0)
|
---|
[60] | 2467 | self._numPassengers.set_width_chars(6)
|
---|
[303] | 2468 | self._numPassengers.connect("integer-changed", self._weightChanged)
|
---|
| 2469 | self._numPassengers.set_tooltip_text(xstr("payload_pax_tooltip"))
|
---|
[1033] | 2470 |
|
---|
| 2471 | self._numChildren = IntegerEntry(defaultValue = 0)
|
---|
| 2472 | self._numChildren.set_width_chars(6)
|
---|
| 2473 | self._numChildren.connect("integer-changed", self._weightChanged)
|
---|
| 2474 | self._numChildren.set_tooltip_text(xstr("payload_pax_children_tooltip"))
|
---|
| 2475 |
|
---|
| 2476 | self._numInfants = IntegerEntry(defaultValue = 0)
|
---|
| 2477 | self._numInfants.set_width_chars(6)
|
---|
| 2478 | self._numInfants.connect("integer-changed", self._weightChanged)
|
---|
| 2479 | self._numInfants.set_tooltip_text(xstr("payload_pax_infants_tooltip"))
|
---|
| 2480 |
|
---|
| 2481 | paxBox = Gtk.HBox()
|
---|
| 2482 | paxBox.pack_start(self._numPassengers, False, False, 0)
|
---|
| 2483 | paxBox.pack_start(Gtk.Label("+"), False, False, 4)
|
---|
| 2484 | paxBox.pack_start(self._numChildren, False, False, 0)
|
---|
| 2485 | paxBox.pack_start(Gtk.Label("+"), False, False, 4)
|
---|
| 2486 | paxBox.pack_start(self._numInfants, False, False, 0)
|
---|
| 2487 |
|
---|
| 2488 | table.attach(paxBox, 1, 2, 1, 2)
|
---|
[303] | 2489 | label.set_mnemonic_widget(self._numPassengers)
|
---|
[347] | 2490 |
|
---|
[1033] | 2491 | label = Gtk.Label(xstr("payload_pax_info"))
|
---|
| 2492 | label.set_halign(Gtk.Align.START)
|
---|
| 2493 | table.attach(label, 2, 3, 1, 2)
|
---|
| 2494 |
|
---|
[996] | 2495 | label = Gtk.Label(xstr("payload_bag"))
|
---|
[309] | 2496 | label.set_use_underline(True)
|
---|
[60] | 2497 | label.set_alignment(0.0, 0.5)
|
---|
| 2498 | table.attach(label, 0, 1, 2, 3)
|
---|
| 2499 |
|
---|
[303] | 2500 | self._bagWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 2501 | self._bagWeight.set_width_chars(6)
|
---|
[303] | 2502 | self._bagWeight.connect("integer-changed", self._weightChanged)
|
---|
| 2503 | self._bagWeight.set_tooltip_text(xstr("payload_bag_tooltip"))
|
---|
[1033] | 2504 | self._bagWeight.set_hexpand(False)
|
---|
| 2505 | self._bagWeight.set_halign(Gtk.Align.END)
|
---|
[60] | 2506 | table.attach(self._bagWeight, 1, 2, 2, 3)
|
---|
[303] | 2507 | label.set_mnemonic_widget(self._bagWeight)
|
---|
[60] | 2508 |
|
---|
[1033] | 2509 | label = Gtk.Label("kg")
|
---|
| 2510 | label.set_halign(Gtk.Align.START)
|
---|
| 2511 | table.attach(label, 2, 3, 2, 3)
|
---|
[996] | 2512 |
|
---|
| 2513 | label = Gtk.Label(xstr("payload_cargo"))
|
---|
[60] | 2514 | label.set_use_underline(True)
|
---|
| 2515 | label.set_alignment(0.0, 0.5)
|
---|
| 2516 | table.attach(label, 0, 1, 3, 4)
|
---|
| 2517 |
|
---|
[84] | 2518 | self._cargoWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 2519 | self._cargoWeight.set_width_chars(6)
|
---|
[303] | 2520 | self._cargoWeight.connect("integer-changed", self._weightChanged)
|
---|
[107] | 2521 | self._cargoWeight.set_tooltip_text(xstr("payload_cargo_tooltip"))
|
---|
[1033] | 2522 | self._cargoWeight.set_hexpand(False)
|
---|
| 2523 | self._cargoWeight.set_halign(Gtk.Align.END)
|
---|
[60] | 2524 | table.attach(self._cargoWeight, 1, 2, 3, 4)
|
---|
| 2525 | label.set_mnemonic_widget(self._cargoWeight)
|
---|
| 2526 |
|
---|
[1033] | 2527 | label = Gtk.Label("kg")
|
---|
| 2528 | label.set_halign(Gtk.Align.START)
|
---|
| 2529 | table.attach(label, 2, 3, 3, 4)
|
---|
[996] | 2530 |
|
---|
| 2531 | label = Gtk.Label(xstr("payload_mail"))
|
---|
[309] | 2532 | label.set_use_underline(True)
|
---|
[60] | 2533 | label.set_alignment(0.0, 0.5)
|
---|
| 2534 | table.attach(label, 0, 1, 4, 5)
|
---|
| 2535 |
|
---|
[303] | 2536 | self._mailWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 2537 | self._mailWeight.set_width_chars(6)
|
---|
[303] | 2538 | self._mailWeight.connect("integer-changed", self._weightChanged)
|
---|
| 2539 | self._mailWeight.set_tooltip_text(xstr("payload_mail_tooltip"))
|
---|
[1033] | 2540 | self._mailWeight.set_hexpand(False)
|
---|
| 2541 | self._mailWeight.set_halign(Gtk.Align.END)
|
---|
[60] | 2542 | table.attach(self._mailWeight, 1, 2, 4, 5)
|
---|
[303] | 2543 | label.set_mnemonic_widget(self._mailWeight)
|
---|
[60] | 2544 |
|
---|
[1033] | 2545 | label = Gtk.Label("kg")
|
---|
| 2546 | label.set_halign(Gtk.Align.START)
|
---|
| 2547 | table.attach(label, 2, 3, 4, 5)
|
---|
[996] | 2548 |
|
---|
| 2549 | label = Gtk.Label("<b>" + xstr("payload_zfw") + "</b>")
|
---|
[60] | 2550 | label.set_alignment(0.0, 0.5)
|
---|
| 2551 | label.set_use_markup(True)
|
---|
| 2552 | table.attach(label, 0, 1, 5, 6)
|
---|
| 2553 |
|
---|
[996] | 2554 | self._calculatedZFW = Gtk.Label()
|
---|
[60] | 2555 | self._calculatedZFW.set_width_chars(6)
|
---|
| 2556 | self._calculatedZFW.set_alignment(1.0, 0.5)
|
---|
| 2557 | table.attach(self._calculatedZFW, 1, 2, 5, 6)
|
---|
| 2558 |
|
---|
[1033] | 2559 | label = Gtk.Label("kg")
|
---|
| 2560 | label.set_halign(Gtk.Align.START)
|
---|
| 2561 | table.attach(label, 2, 3, 5, 6)
|
---|
[996] | 2562 |
|
---|
| 2563 | self._zfwButton = Gtk.Button(xstr("payload_fszfw"))
|
---|
[70] | 2564 | self._zfwButton.set_use_underline(True)
|
---|
| 2565 | self._zfwButton.connect("clicked", self._zfwRequested)
|
---|
[107] | 2566 | self._zfwButton.set_tooltip_text(xstr("payload_fszfw_tooltip"))
|
---|
[70] | 2567 | table.attach(self._zfwButton, 0, 1, 6, 7)
|
---|
[60] | 2568 |
|
---|
[996] | 2569 | self._simulatorZFW = Gtk.Label("-")
|
---|
[60] | 2570 | self._simulatorZFW.set_width_chars(6)
|
---|
| 2571 | self._simulatorZFW.set_alignment(1.0, 0.5)
|
---|
| 2572 | table.attach(self._simulatorZFW, 1, 2, 6, 7)
|
---|
| 2573 | self._simulatorZFWValue = None
|
---|
| 2574 |
|
---|
[1033] | 2575 | label = Gtk.Label("kg")
|
---|
| 2576 | label.set_halign(Gtk.Align.START)
|
---|
| 2577 | table.attach(label, 2, 3, 6, 7)
|
---|
[60] | 2578 |
|
---|
[208] | 2579 | self.addCancelFlightButton()
|
---|
[107] | 2580 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2581 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[60] | 2582 |
|
---|
[97] | 2583 | @property
|
---|
[1033] | 2584 | def numCockpitCrew(self):
|
---|
| 2585 | """The number of the cockpit crew members on the flight."""
|
---|
| 2586 | return self._wizard._bookedFlight.numCockpitCrew
|
---|
| 2587 |
|
---|
| 2588 | @property
|
---|
| 2589 | def numCabinCrew(self):
|
---|
| 2590 | """The number of the cabin members on the flight."""
|
---|
| 2591 | return self._numCabinCrew.get_int()
|
---|
[347] | 2592 |
|
---|
[303] | 2593 | @property
|
---|
| 2594 | def numPassengers(self):
|
---|
[1033] | 2595 | """The number of the adult passengers on the flight."""
|
---|
[303] | 2596 | return self._numPassengers.get_int()
|
---|
[347] | 2597 |
|
---|
[303] | 2598 | @property
|
---|
[1033] | 2599 | def numChildren(self):
|
---|
| 2600 | """The number of the child passengers on the flight."""
|
---|
| 2601 | return self._numChildren.get_int()
|
---|
| 2602 |
|
---|
| 2603 | @property
|
---|
| 2604 | def numInfants(self):
|
---|
| 2605 | """The number of the infant passengers on the flight."""
|
---|
| 2606 | return self._numInfants.get_int()
|
---|
| 2607 |
|
---|
| 2608 | @property
|
---|
[303] | 2609 | def bagWeight(self):
|
---|
| 2610 | """Get the bag weight entered."""
|
---|
| 2611 | return self._bagWeight.get_int()
|
---|
| 2612 |
|
---|
| 2613 | @property
|
---|
[97] | 2614 | def cargoWeight(self):
|
---|
| 2615 | """Get the cargo weight entered."""
|
---|
| 2616 | return self._cargoWeight.get_int()
|
---|
| 2617 |
|
---|
[303] | 2618 | @property
|
---|
| 2619 | def mailWeight(self):
|
---|
| 2620 | """Get the bag weight entered."""
|
---|
| 2621 | return self._mailWeight.get_int()
|
---|
| 2622 |
|
---|
[60] | 2623 | def activate(self):
|
---|
| 2624 | """Setup the information."""
|
---|
| 2625 | bookedFlight = self._wizard._bookedFlight
|
---|
[303] | 2626 |
|
---|
[1033] | 2627 | self._numCockpitCrew.set_markup("<b>" +
|
---|
| 2628 | str(bookedFlight.numCockpitCrew) +
|
---|
| 2629 | "</b>")
|
---|
| 2630 | self._numCabinCrew.set_int(bookedFlight.numCabinCrew)
|
---|
| 2631 | self._numCabinCrew.set_sensitive(True)
|
---|
| 2632 |
|
---|
| 2633 |
|
---|
[303] | 2634 | self._numPassengers.set_int(bookedFlight.numPassengers)
|
---|
| 2635 | self._numPassengers.set_sensitive(True)
|
---|
| 2636 |
|
---|
[1033] | 2637 | self._numChildren.set_int(bookedFlight.numChildren)
|
---|
| 2638 | self._numChildren.set_sensitive(True)
|
---|
| 2639 |
|
---|
| 2640 | self._numInfants.set_int(bookedFlight.numInfants)
|
---|
| 2641 | self._numInfants.set_sensitive(True)
|
---|
| 2642 |
|
---|
[303] | 2643 | self._bagWeight.set_int(bookedFlight.bagWeight)
|
---|
| 2644 | self._bagWeight.set_sensitive(True)
|
---|
[1033] | 2645 |
|
---|
[1034] | 2646 | if bookedFlight.flightType==const.FLIGHTTYPE_CHARTER:
|
---|
[1033] | 2647 | self._cargoWeight.set_int(0)
|
---|
| 2648 | self._cargoWeight.set_sensitive(False)
|
---|
| 2649 | self._mailWeight.set_int(0)
|
---|
| 2650 | self._mailWeight.set_sensitive(False)
|
---|
| 2651 | else:
|
---|
| 2652 | self._cargoWeight.set_int(bookedFlight.cargoWeight)
|
---|
| 2653 | self._cargoWeight.set_sensitive(True)
|
---|
| 2654 | self._mailWeight.set_int(bookedFlight.mailWeight)
|
---|
| 2655 | self._mailWeight.set_sensitive(True)
|
---|
[347] | 2656 |
|
---|
[92] | 2657 | self._simulatorZFW.set_text("-")
|
---|
| 2658 | self._simulatorZFWValue = None
|
---|
[70] | 2659 | self._zfwButton.set_sensitive(True)
|
---|
[60] | 2660 | self._updateCalculatedZFW()
|
---|
[59] | 2661 |
|
---|
[70] | 2662 | def finalize(self):
|
---|
| 2663 | """Finalize the payload page."""
|
---|
[1033] | 2664 | self._numCabinCrew.set_sensitive(False)
|
---|
[303] | 2665 | self._numPassengers.set_sensitive(False)
|
---|
[1033] | 2666 | self._numChildren.set_sensitive(False)
|
---|
| 2667 | self._numInfants.set_sensitive(False)
|
---|
[303] | 2668 | self._bagWeight.set_sensitive(False)
|
---|
[70] | 2669 | self._cargoWeight.set_sensitive(False)
|
---|
[303] | 2670 | self._mailWeight.set_sensitive(False)
|
---|
[117] | 2671 | self._wizard.gui.initializeWeightHelp()
|
---|
[70] | 2672 |
|
---|
[84] | 2673 | def calculateZFW(self):
|
---|
[60] | 2674 | """Calculate the ZFW value."""
|
---|
[1033] | 2675 | bookedFlight = self._wizard._bookedFlight
|
---|
| 2676 |
|
---|
| 2677 | zfw = bookedFlight.dow
|
---|
| 2678 | zfw += (self._numCabinCrew.get_int() - bookedFlight.dowNumCabinCrew) * \
|
---|
| 2679 | const.WEIGHT_CABIN_CREW
|
---|
| 2680 | zfw += self._numPassengers.get_int() * \
|
---|
| 2681 | (const.WEIGHT_PASSENGER_CHARTER
|
---|
[1034] | 2682 | if bookedFlight.flightType==const.FLIGHTTYPE_CHARTER
|
---|
[1033] | 2683 | else const.WEIGHT_PASSENGER)
|
---|
| 2684 | zfw += self._numChildren.get_int() * const.WEIGHT_CHILD
|
---|
| 2685 | zfw += self._numInfants.get_int() * const.WEIGHT_INFANT
|
---|
[303] | 2686 | zfw += self._bagWeight.get_int()
|
---|
[84] | 2687 | zfw += self._cargoWeight.get_int()
|
---|
[303] | 2688 | zfw += self._mailWeight.get_int()
|
---|
[60] | 2689 | return zfw
|
---|
[347] | 2690 |
|
---|
[60] | 2691 | def _updateCalculatedZFW(self):
|
---|
| 2692 | """Update the calculated ZFW"""
|
---|
[84] | 2693 | zfw = self.calculateZFW()
|
---|
[60] | 2694 |
|
---|
| 2695 | markupBegin = "<b>"
|
---|
| 2696 | markupEnd = "</b>"
|
---|
| 2697 | if self._simulatorZFWValue is not None and \
|
---|
| 2698 | PayloadChecker.isZFWFaulty(self._simulatorZFWValue, zfw):
|
---|
| 2699 | markupBegin += '<span foreground="red">'
|
---|
| 2700 | markupEnd = "</span>" + markupEnd
|
---|
| 2701 | self._calculatedZFW.set_markup(markupBegin + str(zfw) + markupEnd)
|
---|
| 2702 |
|
---|
[303] | 2703 | def _weightChanged(self, entry, weight):
|
---|
[1033] | 2704 | """Called when one of the weight values or humanm counts has
|
---|
| 2705 | changed."""
|
---|
| 2706 | bookedFlight = self._wizard._bookedFlight
|
---|
| 2707 | numPassengers = \
|
---|
| 2708 | self._numPassengers.get_int() + \
|
---|
| 2709 | self._numChildren.get_int() + \
|
---|
| 2710 | self._numInfants.get_int()
|
---|
| 2711 | minCabinCrew = 0 if numPassengers==0 else \
|
---|
| 2712 | (bookedFlight.maxPassengers // 50) + 1
|
---|
| 2713 |
|
---|
| 2714 | extraHelp = []
|
---|
| 2715 | enoughCrew = self._numCabinCrew.get_int() >= minCabinCrew
|
---|
| 2716 | if enoughCrew:
|
---|
| 2717 | self._crewLabel.set_text(xstr("payload_crew"))
|
---|
| 2718 | self.setHelp(xstr("payload_help"))
|
---|
| 2719 | else:
|
---|
| 2720 | self._crewLabel.set_markup("<b><span foreground=\"red\">" +
|
---|
| 2721 | xstr("payload_crew") +
|
---|
| 2722 | "</span></b>")
|
---|
| 2723 | extraHelp.append(xstr("payload_help_few_crew") % (minCabinCrew,))
|
---|
| 2724 | self._crewLabel.set_use_underline(True)
|
---|
| 2725 |
|
---|
| 2726 | tooManyPassengers = numPassengers>bookedFlight.maxPassengers
|
---|
| 2727 | if tooManyPassengers:
|
---|
| 2728 | self._paxLabel.set_markup("<b><span foreground=\"red\">" +
|
---|
| 2729 | xstr("payload_pax") +
|
---|
| 2730 | "</span></b>")
|
---|
| 2731 | extraHelp.append(xstr("payload_help_many_pax") % (bookedFlight.maxPassengers,))
|
---|
| 2732 | else:
|
---|
| 2733 | self._paxLabel.set_text(xstr("payload_pax"))
|
---|
| 2734 | self._paxLabel.set_use_underline(True)
|
---|
| 2735 |
|
---|
| 2736 | hlp = xstr("payload_help") + "\n\n"
|
---|
| 2737 | for eh in extraHelp:
|
---|
| 2738 | hlp += "<b><span foreground=\"red\">" + eh + "</span></b>\n"
|
---|
| 2739 | hlp += " \n" * (2-len(extraHelp))
|
---|
| 2740 | self.setHelp(hlp)
|
---|
| 2741 |
|
---|
| 2742 | self._button.set_sensitive(enoughCrew and not tooManyPassengers)
|
---|
| 2743 |
|
---|
| 2744 |
|
---|
[60] | 2745 | self._updateCalculatedZFW()
|
---|
[347] | 2746 |
|
---|
[59] | 2747 | def _zfwRequested(self, button):
|
---|
| 2748 | """Called when the ZFW is requested from the simulator."""
|
---|
[70] | 2749 | self._zfwButton.set_sensitive(False)
|
---|
| 2750 | self._backButton.set_sensitive(False)
|
---|
| 2751 | self._button.set_sensitive(False)
|
---|
| 2752 | gui = self._wizard.gui
|
---|
[107] | 2753 | gui.beginBusy(xstr("payload_zfw_busy"))
|
---|
[70] | 2754 | gui.simulator.requestZFW(self._handleZFW)
|
---|
[59] | 2755 |
|
---|
| 2756 | def _handleZFW(self, zfw):
|
---|
| 2757 | """Called when the ZFW value is retrieved."""
|
---|
[995] | 2758 | GObject.idle_add(self._processZFW, zfw)
|
---|
[59] | 2759 |
|
---|
[60] | 2760 | def _processZFW(self, zfw):
|
---|
| 2761 | """Process the given ZFW value received from the simulator."""
|
---|
[61] | 2762 | self._wizard.gui.endBusy()
|
---|
[70] | 2763 | self._zfwButton.set_sensitive(True)
|
---|
| 2764 | self._backButton.set_sensitive(True)
|
---|
| 2765 | self._button.set_sensitive(True)
|
---|
[60] | 2766 | self._simulatorZFWValue = zfw
|
---|
| 2767 | self._simulatorZFW.set_text("%.0f" % (zfw,))
|
---|
| 2768 | self._updateCalculatedZFW()
|
---|
| 2769 |
|
---|
| 2770 | def _forwardClicked(self, button):
|
---|
| 2771 | """Called when the forward button is clicked."""
|
---|
| 2772 | self._wizard.nextPage()
|
---|
[70] | 2773 |
|
---|
| 2774 | def _backClicked(self, button):
|
---|
| 2775 | """Called when the Back button is pressed."""
|
---|
| 2776 | self.goBack()
|
---|
[347] | 2777 |
|
---|
[59] | 2778 | #-----------------------------------------------------------------------------
|
---|
| 2779 |
|
---|
[61] | 2780 | class TimePage(Page):
|
---|
| 2781 | """Page displaying the departure and arrival times and allows querying the
|
---|
| 2782 | current time from the flight simulator."""
|
---|
| 2783 | def __init__(self, wizard):
|
---|
[754] | 2784 | super(TimePage, self).__init__(wizard, "time",
|
---|
| 2785 | xstr("time_title"),
|
---|
[107] | 2786 | xstr("time_help"),
|
---|
| 2787 | completedHelp = xstr("time_chelp"))
|
---|
[61] | 2788 |
|
---|
[996] | 2789 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[61] | 2790 | xscale = 0.0, yscale = 0.0)
|
---|
| 2791 |
|
---|
[996] | 2792 | table = Gtk.Table(3, 2)
|
---|
[61] | 2793 | table.set_row_spacings(4)
|
---|
| 2794 | table.set_col_spacings(16)
|
---|
| 2795 | table.set_homogeneous(False)
|
---|
| 2796 | alignment.add(table)
|
---|
| 2797 | self.setMainWidget(alignment)
|
---|
| 2798 |
|
---|
[996] | 2799 | label = Gtk.Label(xstr("time_departure"))
|
---|
[61] | 2800 | label.set_alignment(0.0, 0.5)
|
---|
| 2801 | table.attach(label, 0, 1, 0, 1)
|
---|
| 2802 |
|
---|
[996] | 2803 | self._departure = Gtk.Label()
|
---|
[61] | 2804 | self._departure.set_alignment(0.0, 0.5)
|
---|
| 2805 | table.attach(self._departure, 1, 2, 0, 1)
|
---|
[347] | 2806 |
|
---|
[996] | 2807 | label = Gtk.Label(xstr("time_arrival"))
|
---|
[61] | 2808 | label.set_alignment(0.0, 0.5)
|
---|
| 2809 | table.attach(label, 0, 1, 1, 2)
|
---|
| 2810 |
|
---|
[996] | 2811 | self._arrival = Gtk.Label()
|
---|
[61] | 2812 | self._arrival.set_alignment(0.0, 0.5)
|
---|
| 2813 | table.attach(self._arrival, 1, 2, 1, 2)
|
---|
| 2814 |
|
---|
[996] | 2815 | self._timeButton = Gtk.Button(xstr("time_fs"))
|
---|
[70] | 2816 | self._timeButton.set_use_underline(True)
|
---|
[107] | 2817 | self._timeButton.set_tooltip_text(xstr("time_fs_tooltip"))
|
---|
[70] | 2818 | self._timeButton.connect("clicked", self._timeRequested)
|
---|
| 2819 | table.attach(self._timeButton, 0, 1, 2, 3)
|
---|
[61] | 2820 |
|
---|
[996] | 2821 | self._simulatorTime = Gtk.Label("-")
|
---|
[61] | 2822 | self._simulatorTime.set_alignment(0.0, 0.5)
|
---|
| 2823 | table.attach(self._simulatorTime, 1, 2, 2, 3)
|
---|
| 2824 |
|
---|
[208] | 2825 | self.addCancelFlightButton()
|
---|
| 2826 |
|
---|
[107] | 2827 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2828 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[61] | 2829 |
|
---|
| 2830 | def activate(self):
|
---|
| 2831 | """Activate the page."""
|
---|
[70] | 2832 | self._timeButton.set_sensitive(True)
|
---|
[61] | 2833 | bookedFlight = self._wizard._bookedFlight
|
---|
| 2834 | self._departure.set_text(str(bookedFlight.departureTime.time()))
|
---|
| 2835 | self._arrival.set_text(str(bookedFlight.arrivalTime.time()))
|
---|
[92] | 2836 | self._simulatorTime.set_text("-")
|
---|
[61] | 2837 |
|
---|
| 2838 | def _timeRequested(self, button):
|
---|
| 2839 | """Request the time from the simulator."""
|
---|
[70] | 2840 | self._timeButton.set_sensitive(False)
|
---|
| 2841 | self._backButton.set_sensitive(False)
|
---|
| 2842 | self._button.set_sensitive(False)
|
---|
[107] | 2843 | self._wizard.gui.beginBusy(xstr("time_busy"))
|
---|
[61] | 2844 | self._wizard.gui.simulator.requestTime(self._handleTime)
|
---|
| 2845 |
|
---|
| 2846 | def _handleTime(self, timestamp):
|
---|
| 2847 | """Handle the result of a time retrieval."""
|
---|
[995] | 2848 | GObject.idle_add(self._processTime, timestamp)
|
---|
[61] | 2849 |
|
---|
| 2850 | def _processTime(self, timestamp):
|
---|
| 2851 | """Process the given time."""
|
---|
| 2852 | self._wizard.gui.endBusy()
|
---|
[70] | 2853 | self._timeButton.set_sensitive(True)
|
---|
| 2854 | self._backButton.set_sensitive(True)
|
---|
| 2855 | self._button.set_sensitive(True)
|
---|
[61] | 2856 | tm = time.gmtime(timestamp)
|
---|
| 2857 | t = datetime.time(tm.tm_hour, tm.tm_min, tm.tm_sec)
|
---|
| 2858 | self._simulatorTime.set_text(str(t))
|
---|
| 2859 |
|
---|
| 2860 | ts = tm.tm_hour * 3600 + tm.tm_min * 60 + tm.tm_sec
|
---|
| 2861 | dt = self._wizard._bookedFlight.departureTime.time()
|
---|
| 2862 | dts = dt.hour * 3600 + dt.minute * 60 + dt.second
|
---|
| 2863 | diff = dts-ts
|
---|
| 2864 |
|
---|
| 2865 | markupBegin = ""
|
---|
| 2866 | markupEnd = ""
|
---|
| 2867 | if diff < 0:
|
---|
| 2868 | markupBegin = '<b><span foreground="red">'
|
---|
| 2869 | markupEnd = '</span></b>'
|
---|
| 2870 | elif diff < 3*60 or diff > 30*60:
|
---|
| 2871 | markupBegin = '<b><span foreground="orange">'
|
---|
| 2872 | markupEnd = '</span></b>'
|
---|
| 2873 |
|
---|
| 2874 | self._departure.set_markup(markupBegin + str(dt) + markupEnd)
|
---|
| 2875 |
|
---|
[70] | 2876 | def _backClicked(self, button):
|
---|
| 2877 | """Called when the Back button is pressed."""
|
---|
| 2878 | self.goBack()
|
---|
[347] | 2879 |
|
---|
[61] | 2880 | def _forwardClicked(self, button):
|
---|
| 2881 | """Called when the forward button is clicked."""
|
---|
[141] | 2882 | if not self._completed:
|
---|
| 2883 | gui = self._wizard.gui
|
---|
| 2884 | gui.beginBusy(xstr("fuel_get_busy"))
|
---|
[347] | 2885 |
|
---|
[274] | 2886 | gui.simulator.getFuel(self._handleFuel)
|
---|
[141] | 2887 | else:
|
---|
| 2888 | self._wizard.nextPage()
|
---|
| 2889 |
|
---|
| 2890 | def _handleFuel(self, fuelData):
|
---|
| 2891 | """Callback for the fuel query operation."""
|
---|
[995] | 2892 | GObject.idle_add(self._processFuel, fuelData)
|
---|
[141] | 2893 |
|
---|
| 2894 | def _processFuel(self, fuelData):
|
---|
| 2895 | """Process the given fuel data."""
|
---|
| 2896 | self._wizard.gui.endBusy()
|
---|
| 2897 | self._wizard._fuelData = fuelData
|
---|
[61] | 2898 | self._wizard.nextPage()
|
---|
[347] | 2899 |
|
---|
[61] | 2900 | #-----------------------------------------------------------------------------
|
---|
| 2901 |
|
---|
[687] | 2902 | class RoutePage(Page):
|
---|
| 2903 | """The page containing the route and the flight level."""
|
---|
| 2904 | def __init__(self, wizard):
|
---|
| 2905 | """Construct the page."""
|
---|
[754] | 2906 | super(RoutePage, self).__init__(wizard, "route",
|
---|
| 2907 | xstr("route_title"),
|
---|
[687] | 2908 | xstr("route_help"),
|
---|
| 2909 | completedHelp = xstr("route_chelp"))
|
---|
| 2910 |
|
---|
[996] | 2911 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[687] | 2912 | xscale = 0.0, yscale = 0.0)
|
---|
| 2913 |
|
---|
[996] | 2914 | mainBox = Gtk.VBox()
|
---|
[687] | 2915 | alignment.add(mainBox)
|
---|
| 2916 | self.setMainWidget(alignment)
|
---|
| 2917 |
|
---|
[996] | 2918 | levelBox = Gtk.HBox()
|
---|
| 2919 |
|
---|
| 2920 | label = Gtk.Label(xstr("route_level"))
|
---|
[687] | 2921 | label.set_use_underline(True)
|
---|
| 2922 | levelBox.pack_start(label, True, True, 0)
|
---|
| 2923 |
|
---|
[996] | 2924 | self._cruiseLevel = Gtk.SpinButton()
|
---|
[687] | 2925 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
| 2926 | self._cruiseLevel.set_range(min = 0, max = 500)
|
---|
| 2927 | self._cruiseLevel.set_tooltip_text(xstr("route_level_tooltip"))
|
---|
| 2928 | self._cruiseLevel.set_numeric(True)
|
---|
| 2929 | self._cruiseLevel.connect("changed", self._cruiseLevelChanged)
|
---|
| 2930 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
| 2931 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
| 2932 |
|
---|
| 2933 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
| 2934 |
|
---|
[996] | 2935 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
[687] | 2936 | xscale = 0.0, yscale = 0.0)
|
---|
| 2937 | alignment.add(levelBox)
|
---|
| 2938 |
|
---|
| 2939 | mainBox.pack_start(alignment, False, False, 0)
|
---|
| 2940 |
|
---|
| 2941 |
|
---|
[996] | 2942 | routeBox = Gtk.VBox()
|
---|
| 2943 |
|
---|
| 2944 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
[687] | 2945 | xscale = 0.0, yscale = 0.0)
|
---|
[996] | 2946 | label = Gtk.Label(xstr("route_route"))
|
---|
[687] | 2947 | label.set_use_underline(True)
|
---|
| 2948 | alignment.add(label)
|
---|
| 2949 | routeBox.pack_start(alignment, True, True, 0)
|
---|
| 2950 |
|
---|
[996] | 2951 | routeWindow = Gtk.ScrolledWindow()
|
---|
[687] | 2952 | routeWindow.set_size_request(400, 80)
|
---|
[996] | 2953 | routeWindow.set_shadow_type(Gtk.ShadowType.IN)
|
---|
| 2954 | routeWindow.set_policy(Gtk.PolicyType.AUTOMATIC,
|
---|
| 2955 | Gtk.PolicyType.AUTOMATIC)
|
---|
[687] | 2956 |
|
---|
| 2957 | self._uppercasingRoute = False
|
---|
| 2958 |
|
---|
[996] | 2959 | self._route = Gtk.TextView()
|
---|
[687] | 2960 | self._route.set_tooltip_text(xstr("route_route_tooltip"))
|
---|
[999] | 2961 | self._route.set_wrap_mode(Gtk.WrapMode.WORD)
|
---|
[687] | 2962 | self._route.get_buffer().connect("changed", self._routeChanged)
|
---|
| 2963 | self._route.get_buffer().connect_after("insert-text", self._routeInserted)
|
---|
| 2964 | routeWindow.add(self._route)
|
---|
| 2965 |
|
---|
| 2966 | label.set_mnemonic_widget(self._route)
|
---|
| 2967 | routeBox.pack_start(routeWindow, True, True, 0)
|
---|
| 2968 |
|
---|
| 2969 | mainBox.pack_start(routeBox, True, True, 8)
|
---|
| 2970 |
|
---|
[996] | 2971 | alternateBox = Gtk.HBox()
|
---|
| 2972 |
|
---|
| 2973 | label = Gtk.Label(xstr("route_altn"))
|
---|
[687] | 2974 | label.set_use_underline(True)
|
---|
| 2975 | alternateBox.pack_start(label, True, True, 0)
|
---|
| 2976 |
|
---|
[996] | 2977 | self._alternate = Gtk.Entry()
|
---|
[687] | 2978 | self._alternate.set_width_chars(6)
|
---|
| 2979 | self._alternate.connect("changed", self._alternateChanged)
|
---|
| 2980 | self._alternate.set_tooltip_text(xstr("route_altn_tooltip"))
|
---|
| 2981 | label.set_mnemonic_widget(self._alternate)
|
---|
| 2982 |
|
---|
| 2983 | alternateBox.pack_start(self._alternate, False, False, 8)
|
---|
| 2984 |
|
---|
[996] | 2985 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
[687] | 2986 | xscale = 0.0, yscale = 0.0)
|
---|
| 2987 | alignment.add(alternateBox)
|
---|
| 2988 |
|
---|
| 2989 | mainBox.pack_start(alignment, False, False, 0)
|
---|
| 2990 |
|
---|
| 2991 | self.addCancelFlightButton()
|
---|
| 2992 |
|
---|
| 2993 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2994 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 2995 |
|
---|
| 2996 | @property
|
---|
| 2997 | def filedCruiseLevel(self):
|
---|
| 2998 | """Get the filed cruise level."""
|
---|
| 2999 | return self._cruiseLevel.get_value_as_int()
|
---|
| 3000 |
|
---|
| 3001 | @property
|
---|
| 3002 | def route(self):
|
---|
| 3003 | """Get the route."""
|
---|
| 3004 | return self._getRoute()
|
---|
| 3005 |
|
---|
| 3006 | @property
|
---|
| 3007 | def alternate(self):
|
---|
| 3008 | """Get the ICAO code of the alternate airport."""
|
---|
| 3009 | return self._alternate.get_text()
|
---|
| 3010 |
|
---|
| 3011 | def activate(self):
|
---|
| 3012 | """Setup the route from the booked flight."""
|
---|
| 3013 | self._cruiseLevel.set_value(0)
|
---|
| 3014 | self._cruiseLevel.set_text("")
|
---|
| 3015 | self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
|
---|
[692] | 3016 | self._alternate.set_text("")
|
---|
[687] | 3017 | self._updateForwardButton()
|
---|
| 3018 |
|
---|
| 3019 | def _getRoute(self):
|
---|
| 3020 | """Get the text of the route."""
|
---|
| 3021 | buffer = self._route.get_buffer()
|
---|
| 3022 | return buffer.get_text(buffer.get_start_iter(),
|
---|
| 3023 | buffer.get_end_iter(), True)
|
---|
| 3024 |
|
---|
| 3025 | def _updateForwardButton(self):
|
---|
| 3026 | """Update the sensitivity of the forward button."""
|
---|
| 3027 | cruiseLevelText = self._cruiseLevel.get_text()
|
---|
| 3028 | cruiseLevel = int(cruiseLevelText) if cruiseLevelText else 0
|
---|
| 3029 | alternate = self._alternate.get_text()
|
---|
| 3030 | self._button.set_sensitive(cruiseLevel>=50 and self._getRoute()!="" and
|
---|
[769] | 3031 | (len(alternate)==4 or self._wizard.entranceExam))
|
---|
[687] | 3032 |
|
---|
| 3033 | def _cruiseLevelChanged(self, *arg):
|
---|
| 3034 | """Called when the cruise level has changed."""
|
---|
| 3035 | self._updateForwardButton()
|
---|
| 3036 |
|
---|
| 3037 | def _routeChanged(self, textBuffer):
|
---|
| 3038 | """Called when the route has changed."""
|
---|
| 3039 | if not self._uppercasingRoute:
|
---|
| 3040 | self._updateForwardButton()
|
---|
| 3041 |
|
---|
| 3042 | def _routeInserted(self, textBuffer, iter, text, length):
|
---|
| 3043 | """Called when new characters are inserted into the route.
|
---|
| 3044 |
|
---|
| 3045 | It uppercases all characters."""
|
---|
| 3046 | if not self._uppercasingRoute:
|
---|
| 3047 | self._uppercasingRoute = True
|
---|
| 3048 |
|
---|
| 3049 | iter1 = iter.copy()
|
---|
| 3050 | iter1.backward_chars(length)
|
---|
| 3051 | textBuffer.delete(iter, iter1)
|
---|
| 3052 |
|
---|
| 3053 | textBuffer.insert(iter, text.upper())
|
---|
| 3054 |
|
---|
| 3055 | self._uppercasingRoute = False
|
---|
| 3056 |
|
---|
| 3057 | def _alternateChanged(self, entry):
|
---|
| 3058 | """Called when the alternate airport has changed."""
|
---|
| 3059 | entry.set_text(entry.get_text().upper())
|
---|
| 3060 | self._updateForwardButton()
|
---|
| 3061 |
|
---|
| 3062 | def _backClicked(self, button):
|
---|
| 3063 | """Called when the Back button is pressed."""
|
---|
| 3064 | self.goBack()
|
---|
| 3065 |
|
---|
| 3066 | def _forwardClicked(self, button):
|
---|
| 3067 | """Called when the Forward button is clicked."""
|
---|
[710] | 3068 | if self._wizard.gui.flight.aircraft.simBriefData is None:
|
---|
| 3069 | self._wizard.usingSimBrief = False
|
---|
[692] | 3070 | if self._wizard.gui.config.useSimBrief and \
|
---|
| 3071 | self._wizard.usingSimBrief is not False:
|
---|
[754] | 3072 | self._wizard.jumpPage("simbrief_setup")
|
---|
[687] | 3073 | else:
|
---|
[719] | 3074 | self._wizard.usingSimBrief = False
|
---|
[754] | 3075 | self._wizard.jumpPage("fuel")
|
---|
[687] | 3076 |
|
---|
| 3077 | #-----------------------------------------------------------------------------
|
---|
| 3078 |
|
---|
[996] | 3079 | class SimBriefCredentialsDialog(Gtk.Dialog):
|
---|
[700] | 3080 | """A dialog window to ask for SimBrief credentials."""
|
---|
| 3081 | def __init__(self, gui, userName, password, rememberPassword):
|
---|
| 3082 | """Construct the dialog."""
|
---|
| 3083 | super(SimBriefCredentialsDialog, self).__init__(WINDOW_TITLE_BASE + " - " +
|
---|
| 3084 | xstr("simbrief_credentials_title"),
|
---|
| 3085 | gui.mainWindow,
|
---|
[999] | 3086 | Gtk.DialogFlags.MODAL)
|
---|
| 3087 | self.add_button(xstr("button_cancel"), Gtk.ResponseType.CANCEL)
|
---|
| 3088 | self.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
[700] | 3089 |
|
---|
| 3090 | contentArea = self.get_content_area()
|
---|
| 3091 |
|
---|
[996] | 3092 | contentAlignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[700] | 3093 | xscale = 0.0, yscale = 0.0)
|
---|
| 3094 | contentAlignment.set_padding(padding_top = 4, padding_bottom = 16,
|
---|
| 3095 | padding_left = 8, padding_right = 8)
|
---|
| 3096 |
|
---|
| 3097 | contentArea.pack_start(contentAlignment, False, False, 0)
|
---|
| 3098 |
|
---|
[996] | 3099 | contentVBox = Gtk.VBox()
|
---|
[700] | 3100 | contentAlignment.add(contentVBox)
|
---|
| 3101 |
|
---|
[996] | 3102 | label = Gtk.Label(xstr("simbrief_login_failed"))
|
---|
[700] | 3103 | label.set_alignment(0.0, 0.0)
|
---|
| 3104 |
|
---|
| 3105 | contentVBox.pack_start(label, False, False, 0)
|
---|
| 3106 |
|
---|
[996] | 3107 | tableAlignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[700] | 3108 | xscale = 0.0, yscale = 0.0)
|
---|
| 3109 | tableAlignment.set_padding(padding_top = 24, padding_bottom = 0,
|
---|
| 3110 | padding_left = 0, padding_right = 0)
|
---|
| 3111 |
|
---|
[996] | 3112 | table = Gtk.Table(3, 2)
|
---|
[700] | 3113 | table.set_row_spacings(4)
|
---|
| 3114 | table.set_col_spacings(16)
|
---|
| 3115 | table.set_homogeneous(False)
|
---|
| 3116 |
|
---|
| 3117 | tableAlignment.add(table)
|
---|
| 3118 | contentVBox.pack_start(tableAlignment, True, True, 0)
|
---|
| 3119 |
|
---|
[996] | 3120 | label = Gtk.Label(xstr("simbrief_username"))
|
---|
[700] | 3121 | label.set_use_underline(True)
|
---|
| 3122 | label.set_alignment(0.0, 0.5)
|
---|
| 3123 | table.attach(label, 0, 1, 0, 1)
|
---|
| 3124 |
|
---|
[996] | 3125 | self._userName = Gtk.Entry()
|
---|
[700] | 3126 | self._userName.set_width_chars(16)
|
---|
| 3127 | #self._userName.connect("changed",
|
---|
| 3128 | # lambda button: self._updateForwardButton())
|
---|
| 3129 | self._userName.set_tooltip_text(xstr("simbrief_username_tooltip"))
|
---|
| 3130 | self._userName.set_text(userName)
|
---|
| 3131 | table.attach(self._userName, 1, 2, 0, 1)
|
---|
| 3132 | label.set_mnemonic_widget(self._userName)
|
---|
| 3133 |
|
---|
[996] | 3134 | label = Gtk.Label(xstr("simbrief_password"))
|
---|
[700] | 3135 | label.set_use_underline(True)
|
---|
| 3136 | label.set_alignment(0.0, 0.5)
|
---|
| 3137 | table.attach(label, 0, 1, 1, 2)
|
---|
| 3138 |
|
---|
[996] | 3139 | self._password = Gtk.Entry()
|
---|
[700] | 3140 | self._password.set_visibility(False)
|
---|
| 3141 | #self._password.connect("changed",
|
---|
| 3142 | # lambda button: self._updateForwardButton())
|
---|
| 3143 | self._password.set_tooltip_text(xstr("simbrief_password_tooltip"))
|
---|
| 3144 | self._password.set_text(password)
|
---|
| 3145 | table.attach(self._password, 1, 2, 1, 2)
|
---|
| 3146 | label.set_mnemonic_widget(self._password)
|
---|
| 3147 |
|
---|
[996] | 3148 | self._rememberButton = Gtk.CheckButton(xstr("simbrief_remember_password"))
|
---|
[700] | 3149 | self._rememberButton.set_use_underline(True)
|
---|
| 3150 | self._rememberButton.set_tooltip_text(xstr("simbrief_remember_tooltip"))
|
---|
| 3151 | self._rememberButton.set_active(rememberPassword)
|
---|
| 3152 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
| 3153 |
|
---|
| 3154 | @property
|
---|
| 3155 | def userName(self):
|
---|
| 3156 | """Get the user name entered."""
|
---|
| 3157 | return self._userName.get_text()
|
---|
| 3158 |
|
---|
| 3159 | @property
|
---|
| 3160 | def password(self):
|
---|
| 3161 | """Get the password entered."""
|
---|
| 3162 | return self._password.get_text()
|
---|
| 3163 |
|
---|
| 3164 | @property
|
---|
| 3165 | def rememberPassword(self):
|
---|
| 3166 | """Get whether the password is to be remembered."""
|
---|
| 3167 | return self._rememberButton.get_active()
|
---|
| 3168 |
|
---|
| 3169 | def run(self):
|
---|
| 3170 | """Run the dialog."""
|
---|
| 3171 | self.show_all()
|
---|
| 3172 |
|
---|
| 3173 | response = super(SimBriefCredentialsDialog, self).run()
|
---|
| 3174 |
|
---|
| 3175 | self.hide()
|
---|
| 3176 |
|
---|
| 3177 | return response
|
---|
| 3178 |
|
---|
| 3179 | #-----------------------------------------------------------------------------
|
---|
| 3180 |
|
---|
[687] | 3181 | class SimBriefSetupPage(Page):
|
---|
| 3182 | """Page for setting up some parameters for SimBrief."""
|
---|
| 3183 | monthNum2Name = [
|
---|
| 3184 | "JAN",
|
---|
| 3185 | "FEB",
|
---|
| 3186 | "MAR",
|
---|
| 3187 | "APR",
|
---|
| 3188 | "MAY",
|
---|
| 3189 | "JUN",
|
---|
| 3190 | "JUL",
|
---|
| 3191 | "AUG",
|
---|
| 3192 | "SEP",
|
---|
| 3193 | "OCT",
|
---|
| 3194 | "NOV",
|
---|
| 3195 | "DEC"
|
---|
| 3196 | ]
|
---|
| 3197 |
|
---|
[692] | 3198 | progress2Message = {
|
---|
| 3199 | cef.SIMBRIEF_PROGRESS_SEARCHING_BROWSER: "simbrief_progress_searching_browser",
|
---|
| 3200 | cef.SIMBRIEF_PROGRESS_LOADING_FORM: "simbrief_progress_loading_form",
|
---|
| 3201 | cef.SIMBRIEF_PROGRESS_FILLING_FORM: "simbrief_progress_filling_form",
|
---|
| 3202 | cef.SIMBRIEF_PROGRESS_WAITING_LOGIN: "simbrief_progress_waiting_login",
|
---|
| 3203 | cef.SIMBRIEF_PROGRESS_LOGGING_IN: "simbrief_progress_logging_in",
|
---|
| 3204 | cef.SIMBRIEF_PROGRESS_WAITING_RESULT: "simbrief_progress_waiting_result",
|
---|
| 3205 | cef.SIMBRIEF_PROGRESS_RETRIEVING_BRIEFING: "simbrief_progress_retrieving_briefing"
|
---|
| 3206 | }
|
---|
| 3207 |
|
---|
| 3208 | result2Message = {
|
---|
| 3209 | cef.SIMBRIEF_RESULT_ERROR_OTHER: "simbrief_result_error_other",
|
---|
| 3210 | cef.SIMBRIEF_RESULT_ERROR_NO_FORM: "simbrief_result_error_no_form",
|
---|
| 3211 | cef.SIMBRIEF_RESULT_ERROR_NO_POPUP: "simbrief_result_error_no_popup",
|
---|
| 3212 | cef.SIMBRIEF_RESULT_ERROR_LOGIN_FAILED: "simbrief_result_error_login_failed"
|
---|
| 3213 | }
|
---|
| 3214 |
|
---|
[1076] | 3215 | _resultQueryInterval = 2000
|
---|
| 3216 |
|
---|
| 3217 | _waitTimeout = 2 * 60.0
|
---|
| 3218 |
|
---|
[687] | 3219 | @staticmethod
|
---|
| 3220 | def getHTMLFilePath():
|
---|
| 3221 | """Get the path of the HTML file to contain the generated flight
|
---|
| 3222 | plan."""
|
---|
| 3223 | if os.name=="nt":
|
---|
| 3224 | return os.path.join(tempfile.gettempdir(),
|
---|
| 3225 | "mlx_simbrief" +
|
---|
| 3226 | (".secondary" if secondaryInstallation else "") +
|
---|
| 3227 | ".html")
|
---|
| 3228 | else:
|
---|
| 3229 | import pwd
|
---|
| 3230 | return os.path.join(tempfile.gettempdir(),
|
---|
| 3231 | "mlx_simbrief." + pwd.getpwuid(os.getuid())[0] + "" +
|
---|
| 3232 | (".secondary" if secondaryInstallation else "") +
|
---|
| 3233 | ".html")
|
---|
| 3234 |
|
---|
| 3235 | def __init__(self, wizard):
|
---|
| 3236 | """Construct the setup page."""
|
---|
| 3237 |
|
---|
[754] | 3238 | super(SimBriefSetupPage, self).__init__(wizard, "simbrief_setup",
|
---|
[691] | 3239 | xstr("simbrief_setup_title"),
|
---|
| 3240 | xstr("simbrief_setup_help"),
|
---|
| 3241 | xstr("simbrief_setup_chelp"))
|
---|
[687] | 3242 |
|
---|
[996] | 3243 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[687] | 3244 | xscale = 0.0, yscale = 0.0)
|
---|
| 3245 |
|
---|
[1084] | 3246 | table = Gtk.Table(7, 3)
|
---|
[687] | 3247 | table.set_row_spacings(4)
|
---|
| 3248 | table.set_col_spacings(16)
|
---|
| 3249 | table.set_homogeneous(False)
|
---|
| 3250 | alignment.add(table)
|
---|
| 3251 | self.setMainWidget(alignment)
|
---|
| 3252 |
|
---|
[1076] | 3253 |
|
---|
| 3254 | row = 0
|
---|
| 3255 |
|
---|
[1084] | 3256 | frame = Gtk.Frame.new()
|
---|
| 3257 | self._useInternalBrowser = Gtk.CheckButton(xstr("simbrief_uib"))
|
---|
| 3258 | frame.set_label_widget(self._useInternalBrowser)
|
---|
| 3259 | frame.set_label_align(0.025, 0.5)
|
---|
| 3260 |
|
---|
| 3261 | self._useInternalBrowser.set_use_underline(True)
|
---|
| 3262 | self._useInternalBrowser.connect("toggled",
|
---|
| 3263 | self._useInternalBrowserToggled)
|
---|
| 3264 | self._useInternalBrowser.set_tooltip_text(xstr("simbrief_uib_tooltip"))
|
---|
| 3265 |
|
---|
| 3266 | uibTable = Gtk.Table(2, 3)
|
---|
| 3267 | uibTable.set_row_spacings(4)
|
---|
| 3268 | uibTable.set_col_spacings(16)
|
---|
| 3269 | uibTable.set_homogeneous(False)
|
---|
| 3270 |
|
---|
| 3271 | uibRow = 0
|
---|
| 3272 |
|
---|
| 3273 | label = Gtk.Label(xstr("simbrief_username"))
|
---|
| 3274 | label.set_use_underline(True)
|
---|
| 3275 | label.set_alignment(0.0, 0.5)
|
---|
| 3276 | uibTable.attach(label, 0, 1, uibRow, uibRow+1)
|
---|
| 3277 |
|
---|
| 3278 | self._userName = Gtk.Entry()
|
---|
| 3279 | self._userName.set_width_chars(16)
|
---|
| 3280 | self._userName.connect("changed",
|
---|
| 3281 | lambda button: self._updateForwardButton())
|
---|
| 3282 | self._userName.set_tooltip_text(xstr("simbrief_username_tooltip"))
|
---|
| 3283 | uibTable.attach(self._userName, 1, 2, uibRow, uibRow+1)
|
---|
| 3284 | label.set_mnemonic_widget(self._userName)
|
---|
| 3285 | uibRow += 1
|
---|
| 3286 |
|
---|
| 3287 | label = Gtk.Label(xstr("simbrief_password"))
|
---|
| 3288 | label.set_use_underline(True)
|
---|
| 3289 | label.set_alignment(0.0, 0.5)
|
---|
| 3290 | uibTable.attach(label, 0, 1, uibRow, uibRow+1)
|
---|
| 3291 |
|
---|
| 3292 | self._password = Gtk.Entry()
|
---|
| 3293 | self._password.set_visibility(False)
|
---|
| 3294 | self._password.connect("changed",
|
---|
| 3295 | lambda button: self._updateForwardButton())
|
---|
| 3296 | self._password.set_tooltip_text(xstr("simbrief_password_tooltip"))
|
---|
| 3297 | uibTable.attach(self._password, 1, 2, uibRow, uibRow+1)
|
---|
| 3298 | label.set_mnemonic_widget(self._password)
|
---|
| 3299 |
|
---|
| 3300 | self._rememberButton = Gtk.CheckButton(xstr("simbrief_remember_password"))
|
---|
| 3301 | self._rememberButton.set_use_underline(True)
|
---|
| 3302 | self._rememberButton.set_tooltip_text(xstr("simbrief_remember_tooltip"))
|
---|
| 3303 | uibTable.attach(self._rememberButton, 2, 3, uibRow, uibRow+1, ypadding = 8)
|
---|
| 3304 | uibRow += 1
|
---|
| 3305 |
|
---|
| 3306 | uibTable.set_margin_top(6)
|
---|
| 3307 | uibTable.set_margin_bottom(6)
|
---|
| 3308 | uibTable.set_margin_left(4)
|
---|
| 3309 | uibTable.set_margin_right(4)
|
---|
| 3310 |
|
---|
| 3311 | frame.add(uibTable)
|
---|
| 3312 | frame.set_margin_bottom(10)
|
---|
| 3313 |
|
---|
| 3314 | table.attach(frame, 0, 3, row, row+1)
|
---|
| 3315 | row += 1
|
---|
[690] | 3316 |
|
---|
[996] | 3317 | label = Gtk.Label(xstr("simbrief_extra_fuel"))
|
---|
[707] | 3318 | label.set_use_underline(True)
|
---|
| 3319 | label.set_alignment(0.0, 0.5)
|
---|
[1076] | 3320 | table.attach(label, 0, 1, row, row+1)
|
---|
[707] | 3321 |
|
---|
| 3322 | self._extraFuel = IntegerEntry(defaultValue = 0)
|
---|
| 3323 | self._extraFuel.set_width_chars(6)
|
---|
| 3324 | self._extraFuel.set_tooltip_text(xstr("simbrief_extra_fuel_tooltip"))
|
---|
[1076] | 3325 | table.attach(self._extraFuel, 1, 2, row, row+1)
|
---|
[707] | 3326 | label.set_mnemonic_widget(self._extraFuel)
|
---|
| 3327 |
|
---|
[1084] | 3328 | label = Gtk.Label("kg")
|
---|
| 3329 | label.set_alignment(0.0, 0.5)
|
---|
| 3330 | table.attach(label, 2, 3, row, row+1)
|
---|
[1076] | 3331 | row += 1
|
---|
[996] | 3332 |
|
---|
| 3333 | label = Gtk.Label(xstr("simbrief_takeoff_runway"))
|
---|
[708] | 3334 | label.set_use_underline(True)
|
---|
| 3335 | label.set_alignment(0.0, 0.5)
|
---|
[1076] | 3336 | table.attach(label, 0, 1, row, row+1)
|
---|
[708] | 3337 |
|
---|
[996] | 3338 | self._takeoffRunway = Gtk.Entry()
|
---|
[708] | 3339 | self._takeoffRunway.set_width_chars(10)
|
---|
| 3340 | self._takeoffRunway.set_tooltip_text(xstr("simbrief_takeoff_runway_tooltip"))
|
---|
| 3341 | self._takeoffRunway.connect("changed", self._upperChanged)
|
---|
[1076] | 3342 | table.attach(self._takeoffRunway, 1, 2, row, row+1)
|
---|
[708] | 3343 | label.set_mnemonic_widget(self._takeoffRunway)
|
---|
[1076] | 3344 | row += 1
|
---|
[708] | 3345 |
|
---|
[996] | 3346 | label = Gtk.Label(xstr("simbrief_landing_runway"))
|
---|
[708] | 3347 | label.set_use_underline(True)
|
---|
| 3348 | label.set_alignment(0.0, 0.5)
|
---|
[1076] | 3349 | table.attach(label, 0, 1, row, row+1)
|
---|
[708] | 3350 |
|
---|
[996] | 3351 | self._landingRunway = Gtk.Entry()
|
---|
[708] | 3352 | self._landingRunway.set_width_chars(10)
|
---|
[1076] | 3353 | self._landingRunway.set_tooltip_text(xstr("simbrief_landing_runway_tooltip"))
|
---|
[708] | 3354 | self._landingRunway.connect("changed", self._upperChanged)
|
---|
[1076] | 3355 | table.attach(self._landingRunway, 1, 2, row, row+1)
|
---|
[708] | 3356 | label.set_mnemonic_widget(self._landingRunway)
|
---|
[1076] | 3357 | row += 1
|
---|
[708] | 3358 |
|
---|
[996] | 3359 | label = Gtk.Label(xstr("simbrief_climb_profile"))
|
---|
[711] | 3360 | label.set_use_underline(True)
|
---|
| 3361 | label.set_alignment(0.0, 0.5)
|
---|
[1076] | 3362 | table.attach(label, 0, 1, row, row+1)
|
---|
[711] | 3363 |
|
---|
[996] | 3364 | self._climbProfile = Gtk.ComboBox()
|
---|
| 3365 | renderer = Gtk.CellRendererText()
|
---|
[711] | 3366 | self._climbProfile.pack_start(renderer, True)
|
---|
| 3367 | self._climbProfile.add_attribute(renderer, "text", 0)
|
---|
| 3368 | self._climbProfile.set_tooltip_text(xstr("simbrief_climb_profile_tooltip"))
|
---|
[1076] | 3369 | table.attach(self._climbProfile, 1, 2, row, row+1)
|
---|
[711] | 3370 | label.set_mnemonic_widget(self._climbProfile)
|
---|
[1076] | 3371 | row += 1
|
---|
[711] | 3372 |
|
---|
[996] | 3373 | label = Gtk.Label(xstr("simbrief_cruise_profile"))
|
---|
[711] | 3374 | label.set_use_underline(True)
|
---|
| 3375 | label.set_alignment(0.0, 0.5)
|
---|
[1076] | 3376 | table.attach(label, 0, 1, row, row+1)
|
---|
[711] | 3377 |
|
---|
[996] | 3378 | self._cruiseProfile = Gtk.ComboBox()
|
---|
| 3379 | renderer = Gtk.CellRendererText()
|
---|
[711] | 3380 | self._cruiseProfile.pack_start(renderer, True)
|
---|
| 3381 | self._cruiseProfile.add_attribute(renderer, "text", 0)
|
---|
| 3382 | self._cruiseProfile.set_tooltip_text(xstr("simbrief_cruise_profile_tooltip"))
|
---|
[1087] | 3383 | self._cruiseProfile.connect("changed", self._cruiseProfileChanged)
|
---|
[1076] | 3384 | table.attach(self._cruiseProfile, 1, 2, row, row+1)
|
---|
[711] | 3385 | label.set_mnemonic_widget(self._cruiseProfile)
|
---|
[1087] | 3386 |
|
---|
| 3387 | self._cruiseParameter = Gtk.Entry()
|
---|
| 3388 | self._cruiseParameter.set_width_chars(5)
|
---|
| 3389 | self._cruiseParameter.set_tooltip_text(xstr("simbrief_cruise_parameter_tooltip"))
|
---|
| 3390 | self._cruiseParameter.set_sensitive(False)
|
---|
| 3391 | self._cruiseParameter.connect("changed", self._cruiseParameterChanged)
|
---|
| 3392 | table.attach(self._cruiseParameter, 2, 3, row, row+1)
|
---|
| 3393 |
|
---|
[1076] | 3394 | row += 1
|
---|
[711] | 3395 |
|
---|
[996] | 3396 | label = Gtk.Label(xstr("simbrief_descent_profile"))
|
---|
[711] | 3397 | label.set_use_underline(True)
|
---|
| 3398 | label.set_alignment(0.0, 0.5)
|
---|
[1076] | 3399 | table.attach(label, 0, 1, row, row+1)
|
---|
[711] | 3400 |
|
---|
[996] | 3401 | self._descentProfile = Gtk.ComboBox()
|
---|
| 3402 | renderer = Gtk.CellRendererText()
|
---|
[711] | 3403 | self._descentProfile.pack_start(renderer, True)
|
---|
| 3404 | self._descentProfile.add_attribute(renderer, "text", 0)
|
---|
| 3405 | self._descentProfile.set_tooltip_text(xstr("simbrief_descent_profile_tooltip"))
|
---|
[1076] | 3406 | table.attach(self._descentProfile, 1, 2, row, row+1)
|
---|
[711] | 3407 | label.set_mnemonic_widget(self._descentProfile)
|
---|
| 3408 |
|
---|
[687] | 3409 | self.addCancelFlightButton()
|
---|
| 3410 |
|
---|
| 3411 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 3412 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 3413 |
|
---|
[1076] | 3414 | self._resultTimestamp = None
|
---|
| 3415 |
|
---|
[687] | 3416 | def activate(self):
|
---|
| 3417 | """Activate the SimBrief setup page"""
|
---|
[690] | 3418 | config = self._wizard.gui.config
|
---|
| 3419 |
|
---|
[1084] | 3420 | self._useInternalBrowser.set_active(config.useInternalBrowserForSimBrief)
|
---|
| 3421 | self._useInternalBrowser.set_sensitive(True)
|
---|
| 3422 |
|
---|
| 3423 | self._userName.set_text(config.simBriefUserName)
|
---|
| 3424 | self._userName.set_sensitive(config.useInternalBrowserForSimBrief)
|
---|
| 3425 |
|
---|
| 3426 | self._password.set_text(config.simBriefPassword)
|
---|
| 3427 | self._password.set_sensitive(config.useInternalBrowserForSimBrief)
|
---|
| 3428 |
|
---|
| 3429 | self._rememberButton.set_active(config.rememberSimBriefPassword)
|
---|
| 3430 | self._rememberButton.set_sensitive(config.useInternalBrowserForSimBrief)
|
---|
[690] | 3431 |
|
---|
[707] | 3432 | self._extraFuel.set_int(0)
|
---|
| 3433 | self._extraFuel.set_sensitive(True)
|
---|
| 3434 |
|
---|
[708] | 3435 | self._takeoffRunway.set_text("")
|
---|
| 3436 | self._takeoffRunway.set_sensitive(True)
|
---|
| 3437 |
|
---|
| 3438 | self._landingRunway.set_text("")
|
---|
| 3439 | self._landingRunway.set_sensitive(True)
|
---|
| 3440 |
|
---|
[711] | 3441 | simBriefData = self._wizard.gui.flight.aircraft.simBriefData
|
---|
| 3442 | for (control, profiles) in [(self._climbProfile,
|
---|
| 3443 | simBriefData.climbProfiles),
|
---|
| 3444 | (self._cruiseProfile,
|
---|
| 3445 | simBriefData.cruiseProfiles),
|
---|
| 3446 | (self._descentProfile,
|
---|
| 3447 | simBriefData.descentProfiles)]:
|
---|
[996] | 3448 | model = Gtk.ListStore(str)
|
---|
[711] | 3449 | for profile in profiles:
|
---|
| 3450 | model.append([profile])
|
---|
| 3451 | control.set_model(model)
|
---|
| 3452 | control.set_sensitive(True)
|
---|
| 3453 |
|
---|
| 3454 | self._climbProfile.set_active(0)
|
---|
| 3455 | self._cruiseProfile.set_active(0)
|
---|
| 3456 | self._descentProfile.set_active(0)
|
---|
| 3457 |
|
---|
[1076] | 3458 | self._resultTimestamp = None
|
---|
| 3459 | self._waitEnd = None
|
---|
| 3460 |
|
---|
[687] | 3461 | self._updateForwardButton()
|
---|
| 3462 |
|
---|
| 3463 | def _updateForwardButton(self):
|
---|
| 3464 | """Update the sensitivity of the forward button."""
|
---|
[1076] | 3465 | self._button.set_sensitive(True)
|
---|
[1087] | 3466 |
|
---|
| 3467 | sensitive = not self._useInternalBrowser.get_active() or \
|
---|
| 3468 | (len(self._userName.get_text())>0 and
|
---|
| 3469 | len(self._password.get_text())>0)
|
---|
| 3470 | if sensitive:
|
---|
| 3471 | simBriefData = self._wizard.gui.flight.aircraft.simBriefData
|
---|
| 3472 | cruiseProfileIndex = self._cruiseProfile.get_active()
|
---|
| 3473 | sensitive = \
|
---|
| 3474 | cruiseProfileIndex not in simBriefData.cruiseParameters or \
|
---|
| 3475 | not simBriefData.cruiseParameters[cruiseProfileIndex][0] or \
|
---|
| 3476 | len(self._cruiseParameter.get_text())>0
|
---|
| 3477 |
|
---|
| 3478 | self._button.set_sensitive(sensitive)
|
---|
[687] | 3479 |
|
---|
| 3480 | def _backClicked(self, button):
|
---|
| 3481 | """Called when the Back button is pressed."""
|
---|
| 3482 | self.goBack()
|
---|
| 3483 |
|
---|
| 3484 | def _forwardClicked(self, button):
|
---|
| 3485 | if self._completed:
|
---|
| 3486 | self._wizard.nextPage()
|
---|
| 3487 | else:
|
---|
[1084] | 3488 | config = self._wizard.gui.config
|
---|
| 3489 |
|
---|
| 3490 | config.simBriefUserName = self._userName.get_text()
|
---|
| 3491 |
|
---|
| 3492 | rememberPassword = self._rememberButton.get_active()
|
---|
| 3493 | config.simBriefPassword = \
|
---|
| 3494 | self._password.get_text() if rememberPassword else ""
|
---|
| 3495 | config.rememberSimBriefPassword = rememberPassword
|
---|
| 3496 |
|
---|
| 3497 | config.useInternalBrowserForSimBrief = \
|
---|
| 3498 | self._useInternalBrowser.get_active()
|
---|
| 3499 |
|
---|
| 3500 | config.save()
|
---|
[1076] | 3501 |
|
---|
| 3502 | self._wizard.gui.simulator.requestTime(self._handleTime)
|
---|
| 3503 |
|
---|
[1084] | 3504 | def _useInternalBrowserToggled(self, checkButton):
|
---|
| 3505 | """Called when the check button indicating if the internal browser
|
---|
| 3506 | should be used is toggled."""
|
---|
| 3507 | useInternalBrowserForSimBrief = self._useInternalBrowser.get_active()
|
---|
| 3508 | self._userName.set_sensitive(useInternalBrowserForSimBrief)
|
---|
| 3509 | self._password.set_sensitive(useInternalBrowserForSimBrief)
|
---|
| 3510 | self._rememberButton.set_sensitive(useInternalBrowserForSimBrief)
|
---|
[1086] | 3511 | self._updateForwardButton()
|
---|
[1084] | 3512 |
|
---|
[1076] | 3513 | def _handleTime(self, simulatorNow):
|
---|
| 3514 | """Handle the result of a time retrieval."""
|
---|
| 3515 | GObject.idle_add(self._processTime, simulatorNow)
|
---|
| 3516 |
|
---|
| 3517 | def _processTime(self, simulatorNow):
|
---|
| 3518 | """Process the given time."""
|
---|
| 3519 | plan = self._getPlan(simulatorNow)
|
---|
| 3520 | print("plan:", plan)
|
---|
| 3521 |
|
---|
| 3522 | takeoffRunway = self._takeoffRunway.get_text()
|
---|
| 3523 | if takeoffRunway:
|
---|
| 3524 | self._wizard.takeoffRunway = takeoffRunway
|
---|
| 3525 |
|
---|
| 3526 | landingRunway = self._landingRunway.get_text()
|
---|
| 3527 | if landingRunway:
|
---|
| 3528 | self._wizard.landingRunway = landingRunway
|
---|
| 3529 |
|
---|
[1086] | 3530 | self._useInternalBrowser.set_sensitive(False)
|
---|
[1084] | 3531 | self._userName.set_sensitive(False)
|
---|
| 3532 | self._password.set_sensitive(False)
|
---|
| 3533 | self._rememberButton.set_sensitive(False)
|
---|
[1076] | 3534 | self._extraFuel.set_sensitive(False)
|
---|
| 3535 | self._takeoffRunway.set_sensitive(False)
|
---|
| 3536 | self._landingRunway.set_sensitive(False)
|
---|
| 3537 |
|
---|
| 3538 | self._climbProfile.set_sensitive(False)
|
---|
| 3539 | self._cruiseProfile.set_sensitive(False)
|
---|
[1087] | 3540 | self._cruiseParameter.set_sensitive(False)
|
---|
[1076] | 3541 | self._descentProfile.set_sensitive(False)
|
---|
| 3542 |
|
---|
| 3543 | self._wizard.gui.beginBusy(xstr("simbrief_calling"))
|
---|
| 3544 |
|
---|
[1084] | 3545 | url = cef.SimBriefHandler.getFormURL(plan)
|
---|
[1076] | 3546 | print("url:", url)
|
---|
| 3547 |
|
---|
[1084] | 3548 | config = self._wizard.gui.config
|
---|
| 3549 | if config.useInternalBrowserForSimBrief:
|
---|
| 3550 | self._waitEnd = 0
|
---|
| 3551 | cef.callSimBrief(plan,
|
---|
| 3552 | self._getCredentials,
|
---|
| 3553 | self._simBriefProgress,
|
---|
| 3554 | SimBriefSetupPage.getHTMLFilePath())
|
---|
| 3555 | else:
|
---|
| 3556 | webbrowser.open(url = url, new = 1)
|
---|
| 3557 | self._waitEnd = time.time() + SimBriefSetupPage._waitTimeout
|
---|
| 3558 | GObject.timeout_add(SimBriefSetupPage._resultQueryInterval,
|
---|
| 3559 | lambda: self._wizard.gui.webHandler. \
|
---|
| 3560 | getSimBriefResult(self._resultCallback,
|
---|
| 3561 | self._resultTimestamp))
|
---|
| 3562 |
|
---|
[1076] | 3563 |
|
---|
| 3564 | startSound(const.SOUND_NOTAM)
|
---|
| 3565 |
|
---|
[1084] | 3566 | def _getCredentials(self, count):
|
---|
| 3567 | """Get the credentials.
|
---|
| 3568 |
|
---|
| 3569 | If count is 0, the user name and password entered into the setup page
|
---|
| 3570 | are returned. Otherwise a dialog box is displayed informing the user of
|
---|
| 3571 | invalid credentials and requesting another set of them."""
|
---|
| 3572 | print("_getCredentials", count)
|
---|
| 3573 | if count==0:
|
---|
| 3574 | return (self._userName.get_text(), self._password.get_text())
|
---|
| 3575 | else:
|
---|
| 3576 | gui = self._wizard.gui
|
---|
| 3577 | config = gui.config
|
---|
| 3578 |
|
---|
| 3579 | dialog = SimBriefCredentialsDialog(gui,
|
---|
| 3580 | config.simBriefUserName,
|
---|
| 3581 | config.simBriefPassword,
|
---|
| 3582 | config.rememberSimBriefPassword)
|
---|
| 3583 | response = dialog.run()
|
---|
| 3584 |
|
---|
| 3585 | if response==Gtk.ResponseType.OK:
|
---|
| 3586 | userName = dialog.userName
|
---|
| 3587 | self._userName.set_text(userName)
|
---|
| 3588 | password = dialog.password
|
---|
| 3589 | self._password.set_text(password)
|
---|
| 3590 | rememberPassword = dialog.rememberPassword
|
---|
| 3591 |
|
---|
| 3592 | config.simBriefUserName = userName
|
---|
| 3593 |
|
---|
| 3594 | config.simBriefPassword = \
|
---|
| 3595 | password if rememberPassword else ""
|
---|
| 3596 | config.rememberSimBriefPassword = rememberPassword
|
---|
| 3597 |
|
---|
| 3598 | config.save()
|
---|
| 3599 |
|
---|
| 3600 | return (userName, password)
|
---|
| 3601 | else:
|
---|
| 3602 | return (None, None)
|
---|
| 3603 |
|
---|
| 3604 | def _simBriefProgress(self, progress, result, flightInfo):
|
---|
| 3605 | """The real SimBrief progress handler."""
|
---|
| 3606 | print("_simBriefProgress", progress, result, flightInfo)
|
---|
| 3607 | if result==cef.SIMBRIEF_RESULT_NONE:
|
---|
| 3608 | message = SimBriefSetupPage.progress2Message.get(progress,
|
---|
| 3609 | "simbrief_progress_unknown")
|
---|
| 3610 | self._wizard.gui.updateBusyState(xstr(message))
|
---|
| 3611 | else:
|
---|
| 3612 | if result==cef.SIMBRIEF_RESULT_OK:
|
---|
| 3613 | self._waitEnd = 0
|
---|
| 3614 | self._wizard.gui.webHandler. \
|
---|
| 3615 | getSimBriefResult(self._resultCallback,
|
---|
| 3616 | self._resultTimestamp)
|
---|
| 3617 | else:
|
---|
| 3618 | self._wizard.gui.endBusy()
|
---|
| 3619 |
|
---|
| 3620 | message = SimBriefSetupPage.result2Message.get(result,
|
---|
| 3621 | "simbrief_result_unknown")
|
---|
| 3622 | dialog = Gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 3623 | type = Gtk.MessageType.ERROR,
|
---|
| 3624 | message_format =
|
---|
| 3625 | xstr(message) + "\n"+
|
---|
| 3626 | xstr("simbrief_cancelled"))
|
---|
| 3627 |
|
---|
| 3628 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
| 3629 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 3630 | secondary = xstr("flightsel_save_failed_sec")
|
---|
| 3631 | dialog.format_secondary_markup(secondary)
|
---|
| 3632 | dialog.run()
|
---|
| 3633 | dialog.hide()
|
---|
| 3634 |
|
---|
| 3635 | self._wizard.usingSimBrief = False
|
---|
| 3636 | self._wizard.jumpPage("fuel", fromPageShift = 1)
|
---|
[1076] | 3637 |
|
---|
| 3638 | def _getPlan(self, simulatorNow):
|
---|
[687] | 3639 | """Get the flight plan data for SimBrief."""
|
---|
[1076] | 3640 | print("timestamp:", simulatorNow)
|
---|
| 3641 |
|
---|
| 3642 | self._resultTimestamp = now = int(time.time())
|
---|
| 3643 |
|
---|
[687] | 3644 | plan = {
|
---|
| 3645 | "airline": "MAH",
|
---|
| 3646 | "selcal": "XXXX",
|
---|
| 3647 | "fuelfactor": "P000",
|
---|
| 3648 | "contpct": "0.05",
|
---|
| 3649 | "resvrule": "45",
|
---|
| 3650 | "taxiout": "10",
|
---|
| 3651 | "taxiin": "10",
|
---|
[1076] | 3652 | "civalue": "AUTO",
|
---|
| 3653 | "lang": "hun" if getLanguage().lower()=="hu" else "eng",
|
---|
| 3654 | "sessionID": self._wizard._loginResult.sessionID,
|
---|
| 3655 | "timestamp": now
|
---|
[687] | 3656 | }
|
---|
| 3657 |
|
---|
| 3658 | wizard = self._wizard
|
---|
| 3659 | gui = wizard.gui
|
---|
| 3660 |
|
---|
| 3661 | loginResult = wizard.loginResult
|
---|
| 3662 | plan["cpt"] = loginResult.pilotName
|
---|
| 3663 | plan["pid"] = loginResult.pilotID
|
---|
| 3664 |
|
---|
| 3665 | bookedFlight = wizard.bookedFlight
|
---|
| 3666 | plan["fltnum"] = wizard.bookedFlight.callsign[2:]
|
---|
| 3667 | plan["type"] = const.icaoCodes[bookedFlight.aircraftType]
|
---|
| 3668 | plan["orig"] = bookedFlight.departureICAO
|
---|
| 3669 | plan["dest"] = bookedFlight.arrivalICAO
|
---|
| 3670 | plan["reg"] = bookedFlight.tailNumber
|
---|
| 3671 | plan["pax"] = str(bookedFlight.numPassengers)
|
---|
| 3672 |
|
---|
| 3673 | departureTime = bookedFlight.departureTime
|
---|
[1076] | 3674 | print("departureTime", departureTime)
|
---|
| 3675 |
|
---|
| 3676 | tm = time.gmtime(simulatorNow)
|
---|
| 3677 | diffMinutes = (departureTime.hour - tm.tm_hour)*60 + \
|
---|
| 3678 | departureTime.minute - tm.tm_min
|
---|
| 3679 | while diffMinutes<0:
|
---|
| 3680 | diffMinutes += 24*60
|
---|
| 3681 |
|
---|
| 3682 | realDepartureTime = datetime.datetime.utcnow()
|
---|
| 3683 | realDepartureTime += datetime.timedelta(minutes = diffMinutes)
|
---|
| 3684 |
|
---|
| 3685 | plan["date"] = "%02d%s%02d" % (realDepartureTime.day,
|
---|
| 3686 | SimBriefSetupPage.monthNum2Name[realDepartureTime.month-1],
|
---|
| 3687 | realDepartureTime.year%100)
|
---|
| 3688 | plan["deph"] = str(realDepartureTime.hour)
|
---|
| 3689 | plan["depm"] = str(realDepartureTime.minute)
|
---|
[687] | 3690 |
|
---|
| 3691 | arrivalTime = bookedFlight.arrivalTime
|
---|
[1076] | 3692 | blockMinutes = (arrivalTime.hour - departureTime.hour)*60 + \
|
---|
| 3693 | arrivalTime.minute - departureTime.minute
|
---|
| 3694 | while blockMinutes<0:
|
---|
| 3695 | blockMinutes += 24*60
|
---|
| 3696 | plan["steh"] = str(blockMinutes//60)
|
---|
| 3697 | plan["stem"] = str(blockMinutes%60)
|
---|
[687] | 3698 |
|
---|
[705] | 3699 | plan["manualzfw"] = str(wizard.zfw / 1000.0)
|
---|
| 3700 | plan["cargo"] = str((wizard.bagWeight + wizard.cargoWeight + wizard.mailWeight)/1000.0)
|
---|
[687] | 3701 |
|
---|
| 3702 | plan["route"] = wizard.route
|
---|
| 3703 | plan["fl"] = str(wizard.filedCruiseAltitude)
|
---|
| 3704 | plan["altn"] = wizard.alternate
|
---|
| 3705 |
|
---|
[707] | 3706 | plan["addedfuel"] = str(self._extraFuel.get_int() / 1000.0)
|
---|
[708] | 3707 | plan["origrwy"] = self._takeoffRunway.get_text()
|
---|
| 3708 | plan["destrwy"] = self._landingRunway.get_text()
|
---|
[711] | 3709 |
|
---|
| 3710 | for (key, control) in [("climb", self._climbProfile),
|
---|
| 3711 | ("cruise", self._cruiseProfile),
|
---|
| 3712 | ("descent", self._descentProfile)]:
|
---|
| 3713 | model = control.get_model()
|
---|
| 3714 | active = control.get_active_iter()
|
---|
| 3715 | value = model.get_value(active, 0)
|
---|
| 3716 | plan[key] = value
|
---|
[687] | 3717 |
|
---|
[1087] | 3718 | cruiseParameters = self._wizard.gui.flight.aircraft.simBriefData.cruiseParameters
|
---|
| 3719 | cruiseProfileIndex = self._cruiseProfile.get_active()
|
---|
| 3720 | if cruiseProfileIndex in cruiseParameters:
|
---|
| 3721 | value = self._cruiseParameter.get_text()
|
---|
| 3722 | if value:
|
---|
| 3723 | plan[cruiseParameters[cruiseProfileIndex][1]] = value
|
---|
| 3724 |
|
---|
[687] | 3725 | return plan
|
---|
| 3726 |
|
---|
[1076] | 3727 | def _resultCallback(self, returned, result):
|
---|
| 3728 | """Callback for the SimBrief result query."""
|
---|
| 3729 | GObject.idle_add(self._handleResult, returned, result)
|
---|
| 3730 |
|
---|
| 3731 | def _handleResult(self, returned, result):
|
---|
| 3732 | """Handle an RPC query result."""
|
---|
| 3733 | print("_handleResult", returned, result)
|
---|
| 3734 | if result.result and result.result.get("result"):
|
---|
| 3735 | link = result.result.get("result")
|
---|
| 3736 | if link=="<failed>":
|
---|
| 3737 | self._wizard.gui.endBusy()
|
---|
| 3738 |
|
---|
| 3739 | self._finishWithError()
|
---|
| 3740 | else:
|
---|
| 3741 | link ="https://www.simbrief.com/ofp/flightplans/xml/" + link + ".xml"
|
---|
| 3742 |
|
---|
| 3743 | thread = threading.Thread(target = self._getResults, args = (link,))
|
---|
| 3744 | thread.daemon = True
|
---|
| 3745 | thread.start()
|
---|
| 3746 |
|
---|
| 3747 | elif time.time() >= self._waitEnd:
|
---|
| 3748 | self._wizard.gui.endBusy()
|
---|
| 3749 |
|
---|
| 3750 | self._finishWithError()
|
---|
| 3751 | else:
|
---|
| 3752 | GObject.timeout_add(SimBriefSetupPage._resultQueryInterval,
|
---|
| 3753 | lambda: self._wizard.gui.webHandler. \
|
---|
| 3754 | getSimBriefResult(self._resultCallback,
|
---|
| 3755 | self._resultTimestamp))
|
---|
| 3756 |
|
---|
[708] | 3757 | def _upperChanged(self, entry, arg = None):
|
---|
| 3758 | """Called when the value of some entry widget has changed and the value
|
---|
| 3759 | should be converted to uppercase."""
|
---|
| 3760 | entry.set_text(entry.get_text().upper())
|
---|
| 3761 |
|
---|
[1087] | 3762 | def _cruiseProfileChanged(self, comboBox):
|
---|
| 3763 | """Called when the cruise profile has changed.
|
---|
| 3764 |
|
---|
| 3765 | It updates the sensitivity of the cruise parameter entry field"""
|
---|
| 3766 | simBriefData = self._wizard.gui.flight.aircraft.simBriefData
|
---|
| 3767 |
|
---|
| 3768 | activeIndex = self._cruiseProfile.get_active()
|
---|
| 3769 | self._cruiseParameter.set_sensitive(activeIndex in
|
---|
| 3770 | simBriefData.cruiseParameters)
|
---|
| 3771 |
|
---|
| 3772 | self._updateForwardButton()
|
---|
| 3773 |
|
---|
| 3774 | def _cruiseParameterChanged(self, entry):
|
---|
| 3775 | """Called when the cruise parameter has changed.
|
---|
| 3776 |
|
---|
| 3777 | The sensitivty of the Forward button will be updated"""
|
---|
| 3778 | self._updateForwardButton()
|
---|
| 3779 |
|
---|
[1076] | 3780 | def _getResults(self, link):
|
---|
| 3781 | """Get the result from the given link."""
|
---|
| 3782 | ## Holds analysis data to be used
|
---|
| 3783 | flightInfo = {}
|
---|
| 3784 | try:
|
---|
| 3785 | availableInfo = {}
|
---|
| 3786 |
|
---|
| 3787 | # Obtaining the xml
|
---|
| 3788 | response = urllib.request.urlopen(link,
|
---|
| 3789 | cafile = certifi.where())
|
---|
| 3790 | content = etree.iterparse(response)
|
---|
| 3791 |
|
---|
| 3792 | for (action, element) in content:
|
---|
| 3793 | # Processing tags that occur multiple times
|
---|
| 3794 | if element.tag == "weather":
|
---|
| 3795 | weatherElementList = list(element)
|
---|
| 3796 | for weatherElement in weatherElementList:
|
---|
| 3797 | flightInfo[weatherElement.tag] = weatherElement.text
|
---|
[1085] | 3798 | elif element.tag in ["files", "prefile"]:
|
---|
| 3799 | availableInfo[element.tag] = element
|
---|
[1076] | 3800 | else:
|
---|
| 3801 | availableInfo[element.tag] = element.text
|
---|
| 3802 |
|
---|
| 3803 | # Processing plan_html
|
---|
| 3804 | ## Obtaining chart links
|
---|
| 3805 | imageLinks = []
|
---|
| 3806 | for imageLinkElement in lxml.html.find_class(availableInfo["plan_html"],
|
---|
| 3807 | "ofpmaplink"):
|
---|
| 3808 | for imageLink in imageLinkElement.iterlinks():
|
---|
| 3809 | if imageLink[1] == 'src':
|
---|
| 3810 | imageLinks.append(imageLink[2])
|
---|
| 3811 | flightInfo["image_links"] = imageLinks
|
---|
| 3812 | print((sorted(availableInfo.keys())))
|
---|
| 3813 | htmlFilePath = SimBriefSetupPage.getHTMLFilePath()
|
---|
| 3814 | with open(htmlFilePath, 'w') as f:
|
---|
[1085] | 3815 | f.write("<html>")
|
---|
| 3816 | f.write("<body>")
|
---|
| 3817 | f.write("<h3 style=\"text-align: center;\">%s</h3></br>" % (xstr("simbrief_result_briefing"),))
|
---|
| 3818 | f.write("<div style=\"height: 300px; width: fit-content; overflow: auto; margin: 0 auto;\">")
|
---|
[1076] | 3819 | f.write(availableInfo["plan_html"])
|
---|
[1085] | 3820 | f.write("</div>\n")
|
---|
| 3821 |
|
---|
| 3822 | f.write("<h2/>");
|
---|
| 3823 | f.write("<h3 style=\"text-align: center;\">%s</h3></br>" % (xstr("simbrief_result_downloads"),))
|
---|
| 3824 | f.write("<div style=\"height: 300px; width: fit-content; overflow: auto; margin: 0 auto\">")
|
---|
| 3825 | f.write("<table style=\"border: 1px solid; border-collapse: collapse;\">")
|
---|
| 3826 |
|
---|
| 3827 | directory = ""
|
---|
| 3828 | for fileData in availableInfo["files"]:
|
---|
| 3829 | if fileData.tag=="directory":
|
---|
| 3830 | directory = fileData.text
|
---|
| 3831 |
|
---|
| 3832 | for fileData in availableInfo["files"]:
|
---|
| 3833 | if fileData.tag in ["pdf", "file"]:
|
---|
| 3834 | name = fileData.find("name").text
|
---|
| 3835 | link = fileData.find("link").text
|
---|
| 3836 |
|
---|
| 3837 | f.write("<tr>")
|
---|
| 3838 | f.write("<td style=\"border: 1px solid; padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px;\">")
|
---|
| 3839 | f.write(name)
|
---|
| 3840 | f.write("</td>")
|
---|
| 3841 | f.write("<td style=\"border: 1px solid; padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px;\">")
|
---|
| 3842 | url = directory + link
|
---|
| 3843 | target = " target=\"_blank\"" if fileData.tag=="pdf" else ""
|
---|
| 3844 | f.write("<a href=\"%s\"%s>%s</a>" % (url, target, name))
|
---|
| 3845 | f.write("</td>")
|
---|
| 3846 | f.write("</tr>")
|
---|
| 3847 |
|
---|
| 3848 | f.write("</table>")
|
---|
| 3849 | f.write("</div>\n")
|
---|
| 3850 |
|
---|
| 3851 | f.write("<h2/>")
|
---|
| 3852 | f.write("<h3 style=\"text-align: center;\">%s</h3></br>" % (xstr("simbrief_result_prefile"),))
|
---|
| 3853 | f.write("<div style=\"height: 400px; width: fit-content; margin: 0 auto\">")
|
---|
| 3854 | f.write("<table style=\"border: 1px solid; border-collapse: collapse;\">")
|
---|
| 3855 | for prefileData in availableInfo["prefile"]:
|
---|
| 3856 | name = prefileData.find("name").text
|
---|
| 3857 | link = prefileData.find("link").text
|
---|
| 3858 | f.write("<tr>")
|
---|
| 3859 | f.write("<td style=\"border: 1px solid; padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px;\">")
|
---|
| 3860 | f.write("<a href=\"%s\" target=\"_blank\">%s</a>" % (link, name))
|
---|
| 3861 | f.write("</td>");
|
---|
| 3862 | f.write("</tr>")
|
---|
| 3863 |
|
---|
| 3864 | f.write("</table>")
|
---|
| 3865 | f.write("</div>\n")
|
---|
| 3866 |
|
---|
| 3867 | f.write("</body>")
|
---|
| 3868 | f.write("</html>")
|
---|
| 3869 |
|
---|
[1076] | 3870 | except Exception as e:
|
---|
| 3871 | print("_getResults", e)
|
---|
| 3872 |
|
---|
| 3873 | GObject.idle_add(self._resultsAvailable, flightInfo)
|
---|
| 3874 |
|
---|
| 3875 | def _resultsAvailable(self, flightInfo):
|
---|
| 3876 | """Called from the result retrieval thread when the result is
|
---|
| 3877 | available."""
|
---|
| 3878 | print("_resultsAvailable")
|
---|
| 3879 | self._wizard.gui.endBusy()
|
---|
| 3880 |
|
---|
| 3881 | if flightInfo:
|
---|
| 3882 | self._wizard.departureMETARChanged(flightInfo["orig_metar"],
|
---|
| 3883 | self)
|
---|
[1110] | 3884 | self._wizard.arrivalMETARChanged(flightInfo["dest_metar"], self,
|
---|
| 3885 | fromDownload = True)
|
---|
[1076] | 3886 | self._wizard.nextPage()
|
---|
| 3887 | else:
|
---|
| 3888 | self._finishWithError()
|
---|
| 3889 |
|
---|
| 3890 | def _finishWithError(self):
|
---|
| 3891 | """Display an error dialog, and when it is accepted, cancel
|
---|
| 3892 | SimBrief briefing and jump to the fuel page."""
|
---|
| 3893 | dialog = Gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 3894 | type = Gtk.MessageType.ERROR,
|
---|
| 3895 | message_format =
|
---|
| 3896 | xstr("simbrief_result_error_other") + "\n"+
|
---|
| 3897 | xstr("simbrief_cancelled"))
|
---|
| 3898 |
|
---|
| 3899 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
| 3900 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 3901 | secondary = xstr("flightsel_save_failed_sec")
|
---|
| 3902 | dialog.format_secondary_markup(secondary)
|
---|
| 3903 | dialog.run()
|
---|
| 3904 | dialog.hide()
|
---|
| 3905 |
|
---|
| 3906 | self._wizard.usingSimBrief = False
|
---|
| 3907 | self._wizard.jumpPage("fuel", fromPageShift = 1)
|
---|
| 3908 |
|
---|
| 3909 |
|
---|
| 3910 |
|
---|
[687] | 3911 | #-----------------------------------------------------------------------------
|
---|
| 3912 |
|
---|
| 3913 | class SimBriefingPage(Page):
|
---|
| 3914 | """Page to display the SimBrief HTML briefing."""
|
---|
[712] | 3915 | class BrowserLifeSpanHandler(object):
|
---|
| 3916 | """The life-span handler of a browser."""
|
---|
| 3917 | def __init__(self, simBriefingPage):
|
---|
| 3918 | """Construct the life-span handler for the given page."""
|
---|
| 3919 | self._simBriefingPage = simBriefingPage
|
---|
| 3920 |
|
---|
| 3921 | def OnBeforeClose(self, browser):
|
---|
| 3922 | """Called before closing the browser."""
|
---|
[1085] | 3923 | if browser is self._simBriefingPage._browser:
|
---|
| 3924 | self._simBriefingPage._invalidateBrowser()
|
---|
| 3925 |
|
---|
| 3926 | def OnBeforeDownload(self, browser, downloadItem, suggestedName, callback):
|
---|
| 3927 | callback.Continue(suggestedName, True)
|
---|
| 3928 | return True
|
---|
[712] | 3929 |
|
---|
[687] | 3930 | def __init__(self, wizard):
|
---|
| 3931 | """Construct the setup page."""
|
---|
| 3932 |
|
---|
[754] | 3933 | super(SimBriefingPage, self).__init__(wizard, "simbrief_result",
|
---|
[727] | 3934 | xstr("simbrief_result_title"), "")
|
---|
[687] | 3935 |
|
---|
[698] | 3936 | self._container = cef.getContainer()
|
---|
[1085] | 3937 | self._container.set_size_request(650, -1)
|
---|
| 3938 |
|
---|
| 3939 | self.setMainWidget(self._container)
|
---|
[687] | 3940 |
|
---|
[698] | 3941 | self._browser = None
|
---|
| 3942 |
|
---|
[687] | 3943 | self.addCancelFlightButton()
|
---|
| 3944 |
|
---|
| 3945 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 3946 |
|
---|
| 3947 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 3948 | self._button.set_label(xstr("briefing_button"))
|
---|
| 3949 | self._button.set_has_tooltip(False)
|
---|
| 3950 | self._button.set_use_stock(False)
|
---|
| 3951 |
|
---|
[1076] | 3952 | def prepareShow(self):
|
---|
| 3953 | """Prepare the page for showing (again)."""
|
---|
[698] | 3954 | if self._browser is None:
|
---|
[712] | 3955 | self._startBrowser()
|
---|
[698] | 3956 | else:
|
---|
| 3957 | self._browser.Reload()
|
---|
[687] | 3958 |
|
---|
[1076] | 3959 | def prepareHide(self):
|
---|
| 3960 | """Prepare the page for hiding."""
|
---|
| 3961 | if os.name!="nt":
|
---|
| 3962 | self._browser.CloseBrowser(False)
|
---|
| 3963 |
|
---|
[712] | 3964 | def grabDefault(self):
|
---|
| 3965 | """If the page has a default button, make it the default one."""
|
---|
| 3966 | super(SimBriefingPage, self).grabDefault()
|
---|
| 3967 |
|
---|
| 3968 | if self._browser is None:
|
---|
| 3969 | self._startBrowser()
|
---|
| 3970 |
|
---|
[687] | 3971 | def _backClicked(self, button):
|
---|
| 3972 | """Called when the Back button has been pressed."""
|
---|
| 3973 | self.goBack()
|
---|
| 3974 |
|
---|
| 3975 | def _forwardClicked(self, button):
|
---|
| 3976 | """Called when the Forward button has been pressed."""
|
---|
| 3977 | if not self._completed:
|
---|
| 3978 | self._button.set_label(xstr("button_next"))
|
---|
| 3979 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
| 3980 | self._wizard.usingSimBrief = True
|
---|
| 3981 | self.complete()
|
---|
| 3982 |
|
---|
| 3983 | self._wizard.nextPage()
|
---|
| 3984 |
|
---|
[712] | 3985 | def _startBrowser(self):
|
---|
| 3986 | """Start the browser.
|
---|
| 3987 |
|
---|
| 3988 | If a container is needed, create one."""
|
---|
| 3989 | if self._container is None:
|
---|
| 3990 | self._container = cef.getContainer()
|
---|
[1085] | 3991 | self.setMainWidget(self._container)
|
---|
[1076] | 3992 | else:
|
---|
| 3993 | self._container.show()
|
---|
[712] | 3994 |
|
---|
| 3995 | url = "file://" + SimBriefSetupPage.getHTMLFilePath()
|
---|
| 3996 | self._browser = cef.startInContainer(self._container, url)
|
---|
| 3997 |
|
---|
| 3998 | lifeSpanHandler = SimBriefingPage.BrowserLifeSpanHandler(self)
|
---|
| 3999 | self._browser.SetClientHandler(lifeSpanHandler)
|
---|
| 4000 |
|
---|
| 4001 | def _invalidateBrowser(self):
|
---|
| 4002 | """Invalidate the browser (and associated stuff)."""
|
---|
[1076] | 4003 | self._container.hide()
|
---|
[712] | 4004 | self._browser = None
|
---|
| 4005 |
|
---|
[1097] | 4006 | def finalizeCEF(self):
|
---|
| 4007 | """Close the CEF browser."""
|
---|
| 4008 | if self._browser is not None:
|
---|
| 4009 | self._container.hide()
|
---|
| 4010 | self._browser.CloseBrowser(True)
|
---|
| 4011 | self._browser = None
|
---|
| 4012 |
|
---|
[687] | 4013 | #-----------------------------------------------------------------------------
|
---|
| 4014 |
|
---|
[996] | 4015 | class FuelTank(Gtk.VBox):
|
---|
[141] | 4016 | """Widget for the fuel tank."""
|
---|
| 4017 | def __init__(self, fuelTank, name, capacity, currentWeight):
|
---|
| 4018 | """Construct the widget for the tank with the given name."""
|
---|
| 4019 | super(FuelTank, self).__init__()
|
---|
| 4020 |
|
---|
[146] | 4021 | self._enabled = True
|
---|
[141] | 4022 | self.fuelTank = fuelTank
|
---|
| 4023 | self.capacity = capacity
|
---|
| 4024 | self.currentWeight = currentWeight
|
---|
| 4025 | self.expectedWeight = currentWeight
|
---|
| 4026 |
|
---|
[996] | 4027 | self._label = label = Gtk.Label("<b>" + name + "</b>")
|
---|
[141] | 4028 | label.set_use_markup(True)
|
---|
[145] | 4029 | label.set_use_underline(True)
|
---|
[999] | 4030 | label.set_justify(Gtk.Justification.CENTER)
|
---|
[141] | 4031 | label.set_alignment(0.5, 1.0)
|
---|
| 4032 |
|
---|
[996] | 4033 | self._tankFigure = Gtk.EventBox()
|
---|
[989] | 4034 | self._tankFigure.set_size_request(38, 200)
|
---|
[142] | 4035 | self._tankFigure.set_visible_window(False)
|
---|
[144] | 4036 | self._tankFigure.set_tooltip_markup(xstr("fuel_tank_tooltip"))
|
---|
[141] | 4037 |
|
---|
[994] | 4038 | self._tankFigure.connect("draw", self._drawTankFigure)
|
---|
[144] | 4039 | self._tankFigure.connect("button_press_event", self._buttonPressed)
|
---|
| 4040 | self._tankFigure.connect("motion_notify_event", self._motionNotify)
|
---|
[1003] | 4041 |
|
---|
| 4042 | self._tankFigure.add_events(Gdk.EventMask.SCROLL_MASK)
|
---|
[144] | 4043 | self._tankFigure.connect("scroll-event", self._scrolled)
|
---|
[347] | 4044 |
|
---|
[996] | 4045 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[141] | 4046 | xscale = 0.0, yscale = 1.0)
|
---|
[142] | 4047 | alignment.add(self._tankFigure)
|
---|
[141] | 4048 |
|
---|
| 4049 | self.pack_start(alignment, True, True, 4)
|
---|
| 4050 |
|
---|
[996] | 4051 | self._expectedButton = Gtk.SpinButton()
|
---|
[141] | 4052 | self._expectedButton.set_numeric(True)
|
---|
| 4053 | self._expectedButton.set_range(0, self.capacity)
|
---|
| 4054 | self._expectedButton.set_increments(10, 100)
|
---|
| 4055 | self._expectedButton.set_value(currentWeight)
|
---|
| 4056 | self._expectedButton.set_alignment(1.0)
|
---|
| 4057 | self._expectedButton.set_width_chars(5)
|
---|
| 4058 | self._expectedButton.connect("value-changed", self._expectedChanged)
|
---|
| 4059 |
|
---|
[145] | 4060 | label.set_mnemonic_widget(self._expectedButton)
|
---|
| 4061 |
|
---|
[989] | 4062 | @property
|
---|
| 4063 | def label(self):
|
---|
| 4064 | """Get the label with the caption."""
|
---|
| 4065 | return self._label
|
---|
| 4066 |
|
---|
| 4067 | @property
|
---|
| 4068 | def expectedButton(self):
|
---|
| 4069 | """Get the button containing the expected value."""
|
---|
| 4070 | return self._expectedButton
|
---|
[141] | 4071 |
|
---|
| 4072 | def setCurrent(self, currentWeight):
|
---|
| 4073 | """Set the current weight."""
|
---|
| 4074 | self.currentWeight = currentWeight
|
---|
| 4075 | self._redraw()
|
---|
| 4076 |
|
---|
| 4077 | def isCorrect(self):
|
---|
| 4078 | """Determine if the contents of the fuel tank are as expected"""
|
---|
| 4079 | return abs(self.expectedWeight - self.currentWeight)<=1
|
---|
| 4080 |
|
---|
| 4081 | def disable(self):
|
---|
| 4082 | """Disable the fuel tank."""
|
---|
| 4083 | self._expectedButton.set_sensitive(False)
|
---|
[146] | 4084 | self._enabled = False
|
---|
[141] | 4085 |
|
---|
| 4086 | def _redraw(self):
|
---|
| 4087 | """Redraw the tank figure."""
|
---|
| 4088 | self._tankFigure.queue_draw()
|
---|
| 4089 |
|
---|
[142] | 4090 | def _drawTankFigure(self, tankFigure, eventOrContext):
|
---|
[141] | 4091 | """Draw the tank figure."""
|
---|
| 4092 | triangleSize = 5
|
---|
[142] | 4093 |
|
---|
[994] | 4094 | context = eventOrContext
|
---|
| 4095 | (xOffset, yOffset) = (0, 0)
|
---|
| 4096 |
|
---|
| 4097 | width = tankFigure.get_allocated_width()
|
---|
| 4098 | height = tankFigure.get_allocated_height()
|
---|
[141] | 4099 |
|
---|
| 4100 | rectangleX0 = triangleSize
|
---|
| 4101 | rectangleY0 = triangleSize
|
---|
| 4102 | rectangleX1 = width - 1 - triangleSize
|
---|
| 4103 | rectangleY1 = height - 1 - triangleSize
|
---|
| 4104 | rectangleLineWidth = 2.0
|
---|
| 4105 |
|
---|
| 4106 | context.set_source_rgb(0.0, 0.0, 0.0)
|
---|
| 4107 | context.set_line_width(rectangleLineWidth)
|
---|
[142] | 4108 | context.rectangle(xOffset + rectangleX0 + rectangleLineWidth/2,
|
---|
| 4109 | yOffset + rectangleY0 + rectangleLineWidth/2,
|
---|
[141] | 4110 | rectangleX1 - rectangleX0 - rectangleLineWidth,
|
---|
| 4111 | rectangleY1 - rectangleY0 - rectangleLineWidth)
|
---|
| 4112 | context.stroke()
|
---|
| 4113 |
|
---|
| 4114 | rectangleInnerLeft = rectangleX0 + rectangleLineWidth
|
---|
| 4115 | rectangleInnerRight = rectangleX1 - rectangleLineWidth
|
---|
[144] | 4116 | self._rectangleInnerTop = rectangleInnerTop = rectangleY0 + rectangleLineWidth
|
---|
| 4117 | self._rectangleInnerBottom = rectangleInnerBottom = rectangleY1 - rectangleLineWidth
|
---|
[141] | 4118 |
|
---|
| 4119 | rectangleInnerWidth = rectangleInnerRight - rectangleInnerLeft
|
---|
| 4120 | rectangleInnerHeight = rectangleInnerBottom - rectangleInnerTop
|
---|
| 4121 |
|
---|
| 4122 | context.set_source_rgb(1.0, 0.9, 0.6)
|
---|
| 4123 | currentHeight = self.currentWeight * rectangleInnerHeight / self.capacity
|
---|
| 4124 | currentX = rectangleInnerTop + rectangleInnerHeight - currentHeight
|
---|
[142] | 4125 | context.rectangle(xOffset + rectangleInnerLeft,
|
---|
| 4126 | yOffset + rectangleInnerTop +
|
---|
| 4127 | rectangleInnerHeight - currentHeight,
|
---|
[141] | 4128 | rectangleInnerWidth, currentHeight)
|
---|
| 4129 | context.fill()
|
---|
| 4130 |
|
---|
| 4131 | expectedHeight = self.expectedWeight * rectangleInnerHeight / self.capacity
|
---|
| 4132 | expectedY = rectangleInnerTop + rectangleInnerHeight - expectedHeight
|
---|
| 4133 |
|
---|
| 4134 | context.set_line_width(1.5)
|
---|
| 4135 | context.set_source_rgb(0.0, 0.85, 0.85)
|
---|
[142] | 4136 | context.move_to(xOffset + rectangleX0, yOffset + expectedY)
|
---|
| 4137 | context.line_to(xOffset + rectangleX1, yOffset + expectedY)
|
---|
[141] | 4138 | context.stroke()
|
---|
| 4139 |
|
---|
| 4140 | context.set_line_width(0.0)
|
---|
[142] | 4141 | context.move_to(xOffset + 0, yOffset + expectedY - triangleSize)
|
---|
| 4142 | context.line_to(xOffset + 0, yOffset + expectedY + triangleSize)
|
---|
| 4143 | context.line_to(xOffset + rectangleX0 + 1, yOffset + expectedY)
|
---|
| 4144 | context.line_to(xOffset + 0, yOffset + expectedY - triangleSize)
|
---|
[141] | 4145 | context.fill()
|
---|
| 4146 |
|
---|
| 4147 | context.set_line_width(0.0)
|
---|
[142] | 4148 | context.move_to(xOffset + width, yOffset + expectedY - triangleSize)
|
---|
| 4149 | context.line_to(xOffset + width, yOffset + expectedY + triangleSize)
|
---|
| 4150 | context.line_to(xOffset + rectangleX1 - 1, yOffset + expectedY)
|
---|
| 4151 | context.line_to(xOffset + width, yOffset + expectedY - triangleSize)
|
---|
[141] | 4152 | context.fill()
|
---|
| 4153 |
|
---|
[142] | 4154 | return True
|
---|
| 4155 |
|
---|
[144] | 4156 | def _setExpectedFromY(self, y):
|
---|
| 4157 | """Set the expected weight from the given Y-coordinate."""
|
---|
| 4158 | level = (self._rectangleInnerBottom - y) / \
|
---|
| 4159 | (self._rectangleInnerBottom - self._rectangleInnerTop)
|
---|
| 4160 | level = min(1.0, max(0.0, level))
|
---|
| 4161 | self._expectedButton.set_value(level * self.capacity)
|
---|
[347] | 4162 |
|
---|
[144] | 4163 | def _buttonPressed(self, tankFigure, event):
|
---|
| 4164 | """Called when a button is pressed in the figure.
|
---|
| 4165 |
|
---|
| 4166 | The expected level will be set there."""
|
---|
[146] | 4167 | if self._enabled and event.button==1:
|
---|
[144] | 4168 | self._setExpectedFromY(event.y)
|
---|
[347] | 4169 |
|
---|
[144] | 4170 | def _motionNotify(self, tankFigure, event):
|
---|
| 4171 | """Called when the mouse pointer moves within the area of a tank figure."""
|
---|
[999] | 4172 | if self._enabled and event.state==Gdk.ModifierType.BUTTON1_MASK:
|
---|
[144] | 4173 | self._setExpectedFromY(event.y)
|
---|
| 4174 |
|
---|
| 4175 | def _scrolled(self, tankFigure, event):
|
---|
| 4176 | """Called when a scroll event is received."""
|
---|
[146] | 4177 | if self._enabled:
|
---|
[999] | 4178 | increment = 1 if event.state==Gdk.ModifierType.CONTROL_MASK \
|
---|
| 4179 | else 100 if event.state==Gdk.ModifierType.SHIFT_MASK \
|
---|
[146] | 4180 | else 10 if event.state==0 else 0
|
---|
| 4181 | if increment!=0:
|
---|
[999] | 4182 | if event.direction==Gdk.ScrollDirection.DOWN:
|
---|
[146] | 4183 | increment *= -1
|
---|
[999] | 4184 | self._expectedButton.spin(Gtk.SpinType.USER_DEFINED, increment)
|
---|
[347] | 4185 |
|
---|
[141] | 4186 | def _expectedChanged(self, spinButton):
|
---|
| 4187 | """Called when the expected value has changed."""
|
---|
| 4188 | self.expectedWeight = spinButton.get_value_as_int()
|
---|
[347] | 4189 | self._redraw()
|
---|
[141] | 4190 |
|
---|
| 4191 | #-----------------------------------------------------------------------------
|
---|
| 4192 |
|
---|
| 4193 | class FuelPage(Page):
|
---|
| 4194 | """The page containing the fuel tank filling."""
|
---|
| 4195 | _pumpStep = 0.02
|
---|
[347] | 4196 |
|
---|
[141] | 4197 | def __init__(self, wizard):
|
---|
| 4198 | """Construct the page."""
|
---|
[754] | 4199 | super(FuelPage, self).__init__(wizard, "fuel",
|
---|
| 4200 | xstr("fuel_title"),
|
---|
[592] | 4201 | xstr("fuel_help_pre") +
|
---|
| 4202 | xstr("fuel_help_post"),
|
---|
[141] | 4203 | completedHelp = xstr("fuel_chelp"))
|
---|
| 4204 |
|
---|
| 4205 | self._fuelTanks = []
|
---|
| 4206 | self._fuelTable = None
|
---|
[996] | 4207 | self._fuelAlignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[141] | 4208 | xscale = 0.0, yscale = 1.0)
|
---|
| 4209 | self.setMainWidget(self._fuelAlignment)
|
---|
| 4210 |
|
---|
[274] | 4211 | tankData = [(tank, 2500, 3900) for tank in acft.mostFuelTanks]
|
---|
| 4212 | self._setupTanks(tankData)
|
---|
[141] | 4213 |
|
---|
[208] | 4214 | self.addCancelFlightButton()
|
---|
| 4215 |
|
---|
[141] | 4216 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 4217 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 4218 |
|
---|
| 4219 | self._pumpIndex = 0
|
---|
| 4220 |
|
---|
[145] | 4221 | def activate(self):
|
---|
| 4222 | """Activate the page."""
|
---|
[274] | 4223 | self._setupTanks(self._wizard._fuelData)
|
---|
[141] | 4224 |
|
---|
[592] | 4225 | aircraft = self._wizard.gui.flight.aircraft
|
---|
| 4226 | minLandingFuel = aircraft.minLandingFuel
|
---|
| 4227 | recommendedLandingFuel = aircraft.recommendedLandingFuel
|
---|
| 4228 |
|
---|
| 4229 | middleHelp = "" if minLandingFuel is None else \
|
---|
| 4230 | (xstr("fuel_help_min") % (minLandingFuel,)) \
|
---|
| 4231 | if recommendedLandingFuel is None else \
|
---|
| 4232 | (xstr("fuel_help_min_rec") % (minLandingFuel,
|
---|
| 4233 | recommendedLandingFuel))
|
---|
| 4234 | self.setHelp(xstr("fuel_help_pre") + middleHelp + xstr("fuel_help_post"))
|
---|
| 4235 |
|
---|
[141] | 4236 | def finalize(self):
|
---|
| 4237 | """Finalize the page."""
|
---|
| 4238 | for fuelTank in self._fuelTanks:
|
---|
| 4239 | fuelTank.disable()
|
---|
| 4240 |
|
---|
| 4241 | def _backClicked(self, button):
|
---|
| 4242 | """Called when the Back button is pressed."""
|
---|
| 4243 | self.goBack()
|
---|
[347] | 4244 |
|
---|
[141] | 4245 | def _forwardClicked(self, button):
|
---|
| 4246 | """Called when the forward button is clicked."""
|
---|
| 4247 | if not self._completed:
|
---|
| 4248 | self._pumpIndex = 0
|
---|
| 4249 | self._wizard.gui.beginBusy(xstr("fuel_pump_busy"))
|
---|
| 4250 | self._pump()
|
---|
[687] | 4251 | elif self._wizard.usingSimBrief:
|
---|
[754] | 4252 | self._wizard.jumpPage("takeoff")
|
---|
[141] | 4253 | else:
|
---|
[754] | 4254 | self._wizard.jumpPage("briefing1")
|
---|
[141] | 4255 |
|
---|
[274] | 4256 | def _setupTanks(self, tankData):
|
---|
[141] | 4257 | """Setup the tanks for the given data."""
|
---|
[274] | 4258 | numTanks = len(tankData)
|
---|
[141] | 4259 | if self._fuelTable is not None:
|
---|
| 4260 | self._fuelAlignment.remove(self._fuelTable)
|
---|
| 4261 |
|
---|
| 4262 | self._fuelTanks = []
|
---|
[996] | 4263 | self._fuelTable = Gtk.Grid()
|
---|
[989] | 4264 | self._fuelTable.set_column_homogeneous(True)
|
---|
| 4265 | self._fuelTable.set_row_spacing(4)
|
---|
[1008] | 4266 | self._fuelTable.set_column_spacing(16 if numTanks<5 else 0)
|
---|
[274] | 4267 | index = 0
|
---|
| 4268 | for (tank, current, capacity) in tankData:
|
---|
[141] | 4269 | fuelTank = FuelTank(tank,
|
---|
| 4270 | xstr("fuel_tank_" +
|
---|
| 4271 | const.fuelTank2string(tank)),
|
---|
| 4272 | capacity, current)
|
---|
| 4273 | self._fuelTanks.append(fuelTank)
|
---|
[989] | 4274 |
|
---|
[996] | 4275 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 1.0,
|
---|
[989] | 4276 | xscale = 1.0, yscale = 0.0)
|
---|
| 4277 | alignment.add(fuelTank.label)
|
---|
[1008] | 4278 | self._fuelTable.attach(alignment,
|
---|
| 4279 | index*(1 if numTanks<5 else 2), 0,
|
---|
| 4280 | 1 if numTanks<5 else 3, 1)
|
---|
[989] | 4281 |
|
---|
[996] | 4282 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[989] | 4283 | xscale = 0.0, yscale = 1.0)
|
---|
| 4284 | alignment.add(fuelTank)
|
---|
[1008] | 4285 | self._fuelTable.attach(alignment,
|
---|
| 4286 | index*(1 if numTanks<5 else 2) +
|
---|
| 4287 | (0 if numTanks<5 else 1), 1, 1, 1)
|
---|
[989] | 4288 |
|
---|
| 4289 |
|
---|
[996] | 4290 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[989] | 4291 | xscale = 1.0, yscale = 0.0)
|
---|
| 4292 | alignment.add(fuelTank.expectedButton)
|
---|
| 4293 |
|
---|
[1008] | 4294 | self._fuelTable.attach(alignment,
|
---|
| 4295 | index* (1 if numTanks<5 else 2),
|
---|
| 4296 | 2 if (index%2)==0 or numTanks<5 else 3,
|
---|
| 4297 | 1 if numTanks<5 else 3, 1)
|
---|
[989] | 4298 |
|
---|
[274] | 4299 | index += 1
|
---|
[347] | 4300 |
|
---|
[141] | 4301 | self._fuelAlignment.add(self._fuelTable)
|
---|
| 4302 | self.show_all()
|
---|
| 4303 |
|
---|
| 4304 | def _pump(self):
|
---|
| 4305 | """Perform one step of pumping.
|
---|
| 4306 |
|
---|
| 4307 | It is checked, if the current tank's contents are of the right
|
---|
| 4308 | quantity. If not, it is filled one step further to the desired
|
---|
| 4309 | contents. Otherwise the next tank is started. If all tanks are are
|
---|
| 4310 | filled, the next page is selected."""
|
---|
| 4311 | numTanks = len(self._fuelTanks)
|
---|
| 4312 |
|
---|
| 4313 | fuelTank = None
|
---|
| 4314 | while self._pumpIndex < numTanks:
|
---|
| 4315 | fuelTank = self._fuelTanks[self._pumpIndex]
|
---|
| 4316 | if fuelTank.isCorrect():
|
---|
| 4317 | self._pumpIndex += 1
|
---|
| 4318 | fuelTank = None
|
---|
| 4319 | else:
|
---|
| 4320 | break
|
---|
| 4321 |
|
---|
| 4322 | if fuelTank is None:
|
---|
| 4323 | self._wizard.gui.endBusy()
|
---|
[687] | 4324 | if self._wizard.usingSimBrief:
|
---|
| 4325 | self._wizard.gui.startMonitoring()
|
---|
[754] | 4326 | self._wizard.jumpPage("takeoff")
|
---|
[687] | 4327 | else:
|
---|
| 4328 | bookedFlight = self._wizard._bookedFlight
|
---|
| 4329 | self._wizard.gui.beginBusy(xstr("route_down_notams"))
|
---|
| 4330 | self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback,
|
---|
| 4331 | bookedFlight.departureICAO,
|
---|
| 4332 | bookedFlight.arrivalICAO)
|
---|
| 4333 | startSound(const.SOUND_NOTAM)
|
---|
[141] | 4334 | else:
|
---|
| 4335 | currentLevel = fuelTank.currentWeight / fuelTank.capacity
|
---|
| 4336 | expectedLevel = fuelTank.expectedWeight / fuelTank.capacity
|
---|
| 4337 | if currentLevel<expectedLevel:
|
---|
| 4338 | currentLevel += FuelPage._pumpStep
|
---|
| 4339 | if currentLevel>expectedLevel: currentLevel = expectedLevel
|
---|
| 4340 | else:
|
---|
| 4341 | currentLevel -= FuelPage._pumpStep
|
---|
| 4342 | if currentLevel<expectedLevel: currentLevel = expectedLevel
|
---|
| 4343 | fuelTank.setCurrent(currentLevel * fuelTank.capacity)
|
---|
| 4344 | self._wizard.gui.simulator.setFuelLevel([(fuelTank.fuelTank,
|
---|
| 4345 | currentLevel)])
|
---|
[995] | 4346 | GObject.timeout_add(50, self._pump)
|
---|
[347] | 4347 |
|
---|
[64] | 4348 | def _notamsCallback(self, returned, result):
|
---|
| 4349 | """Callback for the NOTAMs."""
|
---|
[995] | 4350 | GObject.idle_add(self._handleNOTAMs, returned, result)
|
---|
[64] | 4351 |
|
---|
| 4352 | def _handleNOTAMs(self, returned, result):
|
---|
| 4353 | """Handle the NOTAMs."""
|
---|
| 4354 | if returned:
|
---|
| 4355 | self._wizard._departureNOTAMs = result.departureNOTAMs
|
---|
| 4356 | self._wizard._arrivalNOTAMs = result.arrivalNOTAMs
|
---|
[67] | 4357 | else:
|
---|
| 4358 | self._wizard._departureNOTAMs = None
|
---|
| 4359 | self._wizard._arrivalNOTAMs = None
|
---|
[64] | 4360 |
|
---|
[67] | 4361 | bookedFlight = self._wizard._bookedFlight
|
---|
[107] | 4362 | self._wizard.gui.beginBusy(xstr("route_down_metars"))
|
---|
[67] | 4363 | self._wizard.gui.webHandler.getMETARs(self._metarsCallback,
|
---|
| 4364 | [bookedFlight.departureICAO,
|
---|
| 4365 | bookedFlight.arrivalICAO])
|
---|
| 4366 |
|
---|
| 4367 | def _metarsCallback(self, returned, result):
|
---|
| 4368 | """Callback for the METARs."""
|
---|
[995] | 4369 | GObject.idle_add(self._handleMETARs, returned, result)
|
---|
[67] | 4370 |
|
---|
| 4371 | def _handleMETARs(self, returned, result):
|
---|
| 4372 | """Handle the METARs."""
|
---|
| 4373 | self._wizard._departureMETAR = None
|
---|
| 4374 | self._wizard._arrivalMETAR = None
|
---|
| 4375 | bookedFlight = self._wizard._bookedFlight
|
---|
| 4376 | if returned:
|
---|
| 4377 | if bookedFlight.departureICAO in result.metars:
|
---|
| 4378 | self._wizard._departureMETAR = result.metars[bookedFlight.departureICAO]
|
---|
| 4379 | if bookedFlight.arrivalICAO in result.metars:
|
---|
| 4380 | self._wizard._arrivalMETAR = result.metars[bookedFlight.arrivalICAO]
|
---|
| 4381 |
|
---|
| 4382 | self._wizard.gui.endBusy()
|
---|
[70] | 4383 | self._backButton.set_sensitive(True)
|
---|
| 4384 | self._button.set_sensitive(True)
|
---|
[62] | 4385 | self._wizard.nextPage()
|
---|
| 4386 |
|
---|
| 4387 | #-----------------------------------------------------------------------------
|
---|
| 4388 |
|
---|
[67] | 4389 | class BriefingPage(Page):
|
---|
| 4390 | """Page for the briefing."""
|
---|
| 4391 | def __init__(self, wizard, departure):
|
---|
| 4392 | """Construct the briefing page."""
|
---|
| 4393 | self._departure = departure
|
---|
[347] | 4394 |
|
---|
[754] | 4395 | number = 1 if departure else 2
|
---|
| 4396 |
|
---|
| 4397 | title = xstr("briefing_title") % (number,
|
---|
[107] | 4398 | xstr("briefing_departure")
|
---|
| 4399 | if departure
|
---|
| 4400 | else xstr("briefing_arrival"))
|
---|
[754] | 4401 | super(BriefingPage, self).__init__(wizard,
|
---|
| 4402 | "briefing%d" % (number,),
|
---|
| 4403 | title, xstr("briefing_help"),
|
---|
[107] | 4404 | completedHelp = xstr("briefing_chelp"))
|
---|
[64] | 4405 |
|
---|
[996] | 4406 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[64] | 4407 | xscale = 1.0, yscale = 1.0)
|
---|
| 4408 |
|
---|
[996] | 4409 | mainBox = Gtk.VBox()
|
---|
[64] | 4410 | alignment.add(mainBox)
|
---|
| 4411 | self.setMainWidget(alignment)
|
---|
| 4412 |
|
---|
[996] | 4413 | self._notamsFrame = Gtk.Frame()
|
---|
[107] | 4414 | self._notamsFrame.set_label(xstr("briefing_notams_init"))
|
---|
[996] | 4415 | scrolledWindow = Gtk.ScrolledWindow()
|
---|
[67] | 4416 | scrolledWindow.set_size_request(-1, 128)
|
---|
[94] | 4417 | # FIXME: these constants should be in common
|
---|
[996] | 4418 | scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC,
|
---|
| 4419 | Gtk.PolicyType.AUTOMATIC)
|
---|
| 4420 | self._notams = Gtk.TextView()
|
---|
[67] | 4421 | self._notams.set_editable(False)
|
---|
| 4422 | self._notams.set_accepts_tab(False)
|
---|
[996] | 4423 | self._notams.set_wrap_mode(Gtk.WrapMode.WORD)
|
---|
[67] | 4424 | scrolledWindow.add(self._notams)
|
---|
[996] | 4425 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[67] | 4426 | xscale = 1.0, yscale = 1.0)
|
---|
| 4427 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 4428 | padding_left = 0, padding_right = 0)
|
---|
| 4429 | alignment.add(scrolledWindow)
|
---|
| 4430 | self._notamsFrame.add(alignment)
|
---|
| 4431 | mainBox.pack_start(self._notamsFrame, True, True, 4)
|
---|
[347] | 4432 |
|
---|
[996] | 4433 | self._metarFrame = Gtk.Frame()
|
---|
[107] | 4434 | self._metarFrame.set_label(xstr("briefing_metar_init"))
|
---|
[996] | 4435 | scrolledWindow = Gtk.ScrolledWindow()
|
---|
[67] | 4436 | scrolledWindow.set_size_request(-1, 32)
|
---|
[996] | 4437 | scrolledWindow.set_policy(Gtk.PolicyType.AUTOMATIC,
|
---|
| 4438 | Gtk.PolicyType.AUTOMATIC)
|
---|
[138] | 4439 |
|
---|
[586] | 4440 | self._updatingMETAR = False
|
---|
[138] | 4441 |
|
---|
[996] | 4442 | self._metar = Gtk.TextView()
|
---|
[67] | 4443 | self._metar.set_accepts_tab(False)
|
---|
[996] | 4444 | self._metar.set_wrap_mode(Gtk.WrapMode.WORD)
|
---|
[106] | 4445 | self._metar.get_buffer().connect("changed", self._metarChanged)
|
---|
[138] | 4446 | self._metar.get_buffer().connect_after("insert-text", self._metarInserted)
|
---|
[67] | 4447 | scrolledWindow.add(self._metar)
|
---|
[996] | 4448 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[67] | 4449 | xscale = 1.0, yscale = 1.0)
|
---|
| 4450 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 4451 | padding_left = 0, padding_right = 0)
|
---|
| 4452 | alignment.add(scrolledWindow)
|
---|
| 4453 | self._metarFrame.add(alignment)
|
---|
| 4454 | mainBox.pack_start(self._metarFrame, True, True, 4)
|
---|
[106] | 4455 | self.metarEdited = False
|
---|
[64] | 4456 |
|
---|
[208] | 4457 | self.addCancelFlightButton()
|
---|
| 4458 |
|
---|
[107] | 4459 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 4460 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[64] | 4461 |
|
---|
[97] | 4462 | @property
|
---|
| 4463 | def metar(self):
|
---|
| 4464 | """Get the METAR on the page."""
|
---|
| 4465 | buffer = self._metar.get_buffer()
|
---|
| 4466 | return buffer.get_text(buffer.get_start_iter(),
|
---|
[347] | 4467 | buffer.get_end_iter(), True)
|
---|
[97] | 4468 |
|
---|
[106] | 4469 | def setMETAR(self, metar):
|
---|
[586] | 4470 | """Set the METAR."""
|
---|
[106] | 4471 | self._metar.get_buffer().set_text(metar)
|
---|
| 4472 | self.metarEdited = False
|
---|
| 4473 |
|
---|
[1110] | 4474 | def changeMETAR(self, metar, fromEditing = True):
|
---|
[586] | 4475 | """Change the METAR as a result of an edit on one of the other
|
---|
| 4476 | pages."""
|
---|
| 4477 | self._updatingMETAR = True
|
---|
| 4478 | self._metar.get_buffer().set_text(metar)
|
---|
| 4479 | self._updatingMETAR = False
|
---|
[588] | 4480 |
|
---|
| 4481 | self._updateButton()
|
---|
[1110] | 4482 | self.metarEdited = fromEditing
|
---|
[586] | 4483 |
|
---|
[64] | 4484 | def activate(self):
|
---|
| 4485 | """Activate the page."""
|
---|
[70] | 4486 | if not self._departure:
|
---|
[107] | 4487 | self._button.set_label(xstr("briefing_button"))
|
---|
| 4488 | self._button.set_has_tooltip(False)
|
---|
[70] | 4489 | self._button.set_use_stock(False)
|
---|
| 4490 |
|
---|
| 4491 | bookedFlight = self._wizard._bookedFlight
|
---|
[67] | 4492 |
|
---|
[70] | 4493 | icao = bookedFlight.departureICAO if self._departure \
|
---|
| 4494 | else bookedFlight.arrivalICAO
|
---|
| 4495 | notams = self._wizard._departureNOTAMs if self._departure \
|
---|
| 4496 | else self._wizard._arrivalNOTAMs
|
---|
| 4497 | metar = self._wizard._departureMETAR if self._departure \
|
---|
| 4498 | else self._wizard._arrivalMETAR
|
---|
[64] | 4499 |
|
---|
[107] | 4500 | self._notamsFrame.set_label(xstr("briefing_notams_template") % (icao,))
|
---|
[70] | 4501 | buffer = self._notams.get_buffer()
|
---|
| 4502 | if notams is None:
|
---|
[107] | 4503 | buffer.set_text(xstr("briefing_notams_failed"))
|
---|
[92] | 4504 | elif not notams:
|
---|
[107] | 4505 | buffer.set_text(xstr("briefing_notams_missing"))
|
---|
[70] | 4506 | else:
|
---|
| 4507 | s = ""
|
---|
| 4508 | for notam in notams:
|
---|
[570] | 4509 | s += str(notam)
|
---|
[70] | 4510 | s += "-------------------- * --------------------\n"
|
---|
| 4511 | buffer.set_text(s)
|
---|
[67] | 4512 |
|
---|
[107] | 4513 | self._metarFrame.set_label(xstr("briefing_metar_template") % (icao,))
|
---|
[70] | 4514 | buffer = self._metar.get_buffer()
|
---|
[586] | 4515 | self._updatingMETAR = True
|
---|
[70] | 4516 | if metar is None:
|
---|
[584] | 4517 | buffer.set_text("")
|
---|
| 4518 | self.setHelp(xstr("briefing_help_nometar"))
|
---|
[70] | 4519 | else:
|
---|
| 4520 | buffer.set_text(metar)
|
---|
[586] | 4521 | self._updatingMETAR = False
|
---|
[584] | 4522 | self._updateButton()
|
---|
[67] | 4523 |
|
---|
[107] | 4524 | label = self._metarFrame.get_label_widget()
|
---|
| 4525 | label.set_use_underline(True)
|
---|
| 4526 | label.set_mnemonic_widget(self._metar)
|
---|
| 4527 |
|
---|
[106] | 4528 | self.metarEdited = False
|
---|
| 4529 |
|
---|
[70] | 4530 | def _backClicked(self, button):
|
---|
| 4531 | """Called when the Back button is pressed."""
|
---|
| 4532 | self.goBack()
|
---|
[347] | 4533 |
|
---|
[67] | 4534 | def _forwardClicked(self, button):
|
---|
[64] | 4535 | """Called when the forward button is clicked."""
|
---|
[70] | 4536 | if not self._departure:
|
---|
[94] | 4537 | if not self._completed:
|
---|
[70] | 4538 | self._wizard.gui.startMonitoring()
|
---|
[107] | 4539 | self._button.set_label(xstr("button_next"))
|
---|
| 4540 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
[94] | 4541 | self.complete()
|
---|
[71] | 4542 |
|
---|
| 4543 | self._wizard.nextPage()
|
---|
| 4544 |
|
---|
[106] | 4545 | def _metarChanged(self, buffer):
|
---|
| 4546 | """Called when the METAR has changed."""
|
---|
[919] | 4547 | print("BriefingPage.metarChanged", self._updatingMETAR)
|
---|
[586] | 4548 | if not self._updatingMETAR:
|
---|
[138] | 4549 | self.metarEdited = True
|
---|
[584] | 4550 | self._updateButton()
|
---|
[586] | 4551 | metar = buffer.get_text(buffer.get_start_iter(),
|
---|
| 4552 | buffer.get_end_iter(), True)
|
---|
| 4553 | self._wizard.metarChanged(metar, self)
|
---|
[138] | 4554 |
|
---|
| 4555 | def _metarInserted(self, textBuffer, iter, text, length):
|
---|
| 4556 | """Called when new characters are inserted into the METAR.
|
---|
| 4557 |
|
---|
| 4558 | It uppercases all characters."""
|
---|
[919] | 4559 | print("BriefingPage.metarInserted", self._updatingMETAR)
|
---|
[586] | 4560 | if not self._updatingMETAR:
|
---|
| 4561 | self._updatingMETAR = True
|
---|
[138] | 4562 |
|
---|
| 4563 | iter1 = iter.copy()
|
---|
| 4564 | iter1.backward_chars(length)
|
---|
| 4565 | textBuffer.delete(iter, iter1)
|
---|
| 4566 |
|
---|
| 4567 | textBuffer.insert(iter, text.upper())
|
---|
| 4568 |
|
---|
[586] | 4569 | self._updatingMETAR = False
|
---|
[106] | 4570 |
|
---|
[584] | 4571 | def _updateButton(self):
|
---|
| 4572 | """Update the sensitivity of the Next button based on the contents of
|
---|
| 4573 | the METAR field."""
|
---|
| 4574 | buffer = self._metar.get_buffer()
|
---|
| 4575 | self._button.set_sensitive(buffer.get_text(buffer.get_start_iter(),
|
---|
| 4576 | buffer.get_end_iter(),
|
---|
| 4577 | True)!="")
|
---|
| 4578 |
|
---|
| 4579 |
|
---|
[71] | 4580 | #-----------------------------------------------------------------------------
|
---|
| 4581 |
|
---|
| 4582 | class TakeoffPage(Page):
|
---|
| 4583 | """Page for entering the takeoff data."""
|
---|
| 4584 | def __init__(self, wizard):
|
---|
| 4585 | """Construct the takeoff page."""
|
---|
[754] | 4586 | super(TakeoffPage, self).__init__(wizard, "takeoff",
|
---|
| 4587 | xstr("takeoff_title"),
|
---|
[107] | 4588 | xstr("takeoff_help"),
|
---|
| 4589 | completedHelp = xstr("takeoff_chelp"))
|
---|
[71] | 4590 |
|
---|
[101] | 4591 | self._forwardAllowed = False
|
---|
| 4592 |
|
---|
[996] | 4593 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[71] | 4594 | xscale = 0.0, yscale = 0.0)
|
---|
| 4595 |
|
---|
[996] | 4596 | table = Gtk.Table(9, 24)
|
---|
[71] | 4597 | table.set_row_spacings(4)
|
---|
| 4598 | table.set_col_spacings(16)
|
---|
| 4599 | table.set_homogeneous(False)
|
---|
| 4600 | alignment.add(table)
|
---|
| 4601 | self.setMainWidget(alignment)
|
---|
| 4602 |
|
---|
[586] | 4603 | row = 0
|
---|
| 4604 |
|
---|
[996] | 4605 | label = Gtk.Label(xstr("takeoff_metar"))
|
---|
[586] | 4606 | label.set_use_underline(True)
|
---|
| 4607 | label.set_alignment(0.0, 0.5)
|
---|
| 4608 | table.attach(label, 0, 1, row, row+1)
|
---|
| 4609 |
|
---|
[996] | 4610 | self._metar = Gtk.Entry()
|
---|
[586] | 4611 | self._metar.set_width_chars(40)
|
---|
[590] | 4612 | self._metar.set_tooltip_text(xstr("takeoff_metar_tooltip"))
|
---|
[586] | 4613 | self._metar.connect("changed", self._metarChanged)
|
---|
[587] | 4614 | self._metar.get_buffer().connect_after("inserted-text", self._metarInserted)
|
---|
[586] | 4615 | table.attach(self._metar, 1, 24, row, row+1)
|
---|
| 4616 | label.set_mnemonic_widget(self._metar)
|
---|
| 4617 |
|
---|
| 4618 | self._updatingMETAR = False
|
---|
| 4619 |
|
---|
| 4620 | row += 1
|
---|
| 4621 |
|
---|
[996] | 4622 | label = Gtk.Label(xstr("takeoff_runway"))
|
---|
[71] | 4623 | label.set_use_underline(True)
|
---|
| 4624 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 4625 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 4626 |
|
---|
[996] | 4627 | self._runway = Gtk.Entry()
|
---|
[71] | 4628 | self._runway.set_width_chars(10)
|
---|
[107] | 4629 | self._runway.set_tooltip_text(xstr("takeoff_runway_tooltip"))
|
---|
[138] | 4630 | self._runway.connect("changed", self._upperChanged)
|
---|
[586] | 4631 | table.attach(self._runway, 1, 3, row, row+1)
|
---|
[71] | 4632 | label.set_mnemonic_widget(self._runway)
|
---|
[347] | 4633 |
|
---|
[586] | 4634 | row += 1
|
---|
| 4635 |
|
---|
[996] | 4636 | label = Gtk.Label(xstr("takeoff_sid"))
|
---|
[71] | 4637 | label.set_use_underline(True)
|
---|
| 4638 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 4639 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 4640 |
|
---|
[996] | 4641 | self._sid = Gtk.ComboBox.new_with_model_and_entry(comboModel)
|
---|
[621] | 4642 |
|
---|
| 4643 | self._sid.set_entry_text_column(0)
|
---|
| 4644 | self._sid.get_child().set_width_chars(10)
|
---|
[107] | 4645 | self._sid.set_tooltip_text(xstr("takeoff_sid_tooltip"))
|
---|
[621] | 4646 | self._sid.connect("changed", self._upperChangedComboBox)
|
---|
[586] | 4647 | table.attach(self._sid, 1, 3, row, row+1)
|
---|
[71] | 4648 | label.set_mnemonic_widget(self._sid)
|
---|
[347] | 4649 |
|
---|
[586] | 4650 | row += 1
|
---|
| 4651 |
|
---|
[996] | 4652 | label = Gtk.Label(xstr("takeoff_v1"))
|
---|
[71] | 4653 | label.set_use_markup(True)
|
---|
| 4654 | label.set_use_underline(True)
|
---|
| 4655 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 4656 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 4657 |
|
---|
[84] | 4658 | self._v1 = IntegerEntry()
|
---|
[86] | 4659 | self._v1.set_width_chars(4)
|
---|
[241] | 4660 | self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip_knots"))
|
---|
[101] | 4661 | self._v1.connect("integer-changed", self._valueChanged)
|
---|
[586] | 4662 | table.attach(self._v1, 2, 3, row, row+1)
|
---|
[71] | 4663 | label.set_mnemonic_widget(self._v1)
|
---|
[241] | 4664 |
|
---|
[996] | 4665 | self._v1Unit = Gtk.Label(xstr("label_knots"))
|
---|
[384] | 4666 | self._v1Unit.set_alignment(0.0, 0.5)
|
---|
[586] | 4667 | table.attach(self._v1Unit, 3, 4, row, row+1)
|
---|
| 4668 |
|
---|
| 4669 | row += 1
|
---|
[347] | 4670 |
|
---|
[996] | 4671 | label = Gtk.Label(xstr("takeoff_vr"))
|
---|
[71] | 4672 | label.set_use_markup(True)
|
---|
| 4673 | label.set_use_underline(True)
|
---|
| 4674 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 4675 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 4676 |
|
---|
[84] | 4677 | self._vr = IntegerEntry()
|
---|
[86] | 4678 | self._vr.set_width_chars(4)
|
---|
[241] | 4679 | self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip_knots"))
|
---|
[101] | 4680 | self._vr.connect("integer-changed", self._valueChanged)
|
---|
[586] | 4681 | table.attach(self._vr, 2, 3, row, row+1)
|
---|
[71] | 4682 | label.set_mnemonic_widget(self._vr)
|
---|
[347] | 4683 |
|
---|
[996] | 4684 | self._vrUnit = Gtk.Label(xstr("label_knots"))
|
---|
[384] | 4685 | self._vrUnit.set_alignment(0.0, 0.5)
|
---|
[586] | 4686 | table.attach(self._vrUnit, 3, 4, row, row+1)
|
---|
| 4687 |
|
---|
| 4688 | row += 1
|
---|
[347] | 4689 |
|
---|
[996] | 4690 | label = Gtk.Label(xstr("takeoff_v2"))
|
---|
[71] | 4691 | label.set_use_markup(True)
|
---|
| 4692 | label.set_use_underline(True)
|
---|
| 4693 | label.set_alignment(0.0, 0.5)
|
---|
[586] | 4694 | table.attach(label, 0, 1, row, row+1)
|
---|
[71] | 4695 |
|
---|
[84] | 4696 | self._v2 = IntegerEntry()
|
---|
[86] | 4697 | self._v2.set_width_chars(4)
|
---|
[241] | 4698 | self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip_knots"))
|
---|
[101] | 4699 | self._v2.connect("integer-changed", self._valueChanged)
|
---|
[586] | 4700 | table.attach(self._v2, 2, 3, row, row+1)
|
---|
[71] | 4701 | label.set_mnemonic_widget(self._v2)
|
---|
[347] | 4702 |
|
---|
[996] | 4703 | self._v2Unit = Gtk.Label(xstr("label_knots"))
|
---|
[384] | 4704 | self._v2Unit.set_alignment(0.0, 0.5)
|
---|
[586] | 4705 | table.attach(self._v2Unit, 3, 4, row, row+1)
|
---|
| 4706 |
|
---|
| 4707 | row += 1
|
---|
[71] | 4708 |
|
---|
[512] | 4709 | self._derateType = acft.DERATE_NONE
|
---|
[384] | 4710 |
|
---|
[996] | 4711 | self._derateLabel = Gtk.Label()
|
---|
[384] | 4712 | self._derateLabel.set_use_underline(True)
|
---|
| 4713 | self._derateLabel.set_markup(xstr("takeoff_derate_tupolev"))
|
---|
| 4714 | self._derateLabel.set_alignment(0.0, 0.5)
|
---|
[586] | 4715 | table.attach(self._derateLabel, 0, 1, row, row+1)
|
---|
[384] | 4716 |
|
---|
[996] | 4717 | self._derate = Gtk.Alignment()
|
---|
[586] | 4718 | table.attach(self._derate, 2, 4, row, row+1)
|
---|
[512] | 4719 | self._derateWidget = None
|
---|
| 4720 | self._derateEntry = None
|
---|
| 4721 | self._derateUnit = None
|
---|
| 4722 | self._derateButtons = None
|
---|
[384] | 4723 |
|
---|
[586] | 4724 | row += 1
|
---|
| 4725 |
|
---|
[996] | 4726 | self._antiIceOn = Gtk.CheckButton(xstr("takeoff_antiice"))
|
---|
[391] | 4727 | self._antiIceOn.set_use_underline(True)
|
---|
| 4728 | self._antiIceOn.set_tooltip_text(xstr("takeoff_antiice_tooltip"))
|
---|
[586] | 4729 | table.attach(self._antiIceOn, 2, 4, row, row+1)
|
---|
| 4730 |
|
---|
| 4731 | row += 1
|
---|
[391] | 4732 |
|
---|
[996] | 4733 | self._rto = Gtk.CheckButton(xstr("takeoff_rto"))
|
---|
[349] | 4734 | self._rto.set_use_underline(True)
|
---|
| 4735 | self._rto.set_tooltip_text(xstr("takeoff_rto_tooltip"))
|
---|
| 4736 | self._rto.connect("toggled", self._rtoToggled)
|
---|
[586] | 4737 | table.attach(self._rto, 2, 4, row, row+1, ypadding = 8)
|
---|
[349] | 4738 |
|
---|
[208] | 4739 | self.addCancelFlightButton()
|
---|
| 4740 |
|
---|
[107] | 4741 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 4742 |
|
---|
| 4743 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[71] | 4744 |
|
---|
[586] | 4745 | self._active = False
|
---|
| 4746 |
|
---|
[84] | 4747 | @property
|
---|
[97] | 4748 | def runway(self):
|
---|
| 4749 | """Get the runway."""
|
---|
| 4750 | return self._runway.get_text()
|
---|
| 4751 |
|
---|
| 4752 | @property
|
---|
| 4753 | def sid(self):
|
---|
| 4754 | """Get the SID."""
|
---|
[621] | 4755 | text = self._sid.get_child().get_text()
|
---|
| 4756 | return text if self._sid.get_active()!=0 and text and text!="N/A" \
|
---|
| 4757 | else None
|
---|
[97] | 4758 |
|
---|
| 4759 | @property
|
---|
[84] | 4760 | def v1(self):
|
---|
| 4761 | """Get the v1 speed."""
|
---|
| 4762 | return self._v1.get_int()
|
---|
| 4763 |
|
---|
| 4764 | @property
|
---|
| 4765 | def vr(self):
|
---|
| 4766 | """Get the vr speed."""
|
---|
| 4767 | return self._vr.get_int()
|
---|
| 4768 |
|
---|
| 4769 | @property
|
---|
| 4770 | def v2(self):
|
---|
| 4771 | """Get the v2 speed."""
|
---|
| 4772 | return self._v2.get_int()
|
---|
| 4773 |
|
---|
[349] | 4774 | @property
|
---|
[384] | 4775 | def derate(self):
|
---|
| 4776 | """Get the derate value, if any."""
|
---|
[512] | 4777 | if self._derateWidget is None:
|
---|
| 4778 | return None
|
---|
| 4779 | if self._derateType==acft.DERATE_BOEING:
|
---|
| 4780 | derate = self._derateEntry.get_text()
|
---|
[384] | 4781 | return derate if derate else None
|
---|
[512] | 4782 | elif self._derateType==acft.DERATE_EPR:
|
---|
| 4783 | derate = self._derateWidget.get_text()
|
---|
| 4784 | return derate if derate else None
|
---|
| 4785 | elif self._derateType==acft.DERATE_TUPOLEV:
|
---|
| 4786 | return acft.DERATE_TUPOLEV_NOMINAL \
|
---|
| 4787 | if self._derateButtons[0].get_active() \
|
---|
| 4788 | else acft.DERATE_TUPOLEV_TAKEOFF
|
---|
| 4789 | elif self._derateType==acft.DERATE_B462:
|
---|
| 4790 | return self._derateWidget.get_active()
|
---|
[384] | 4791 | else:
|
---|
| 4792 | return None
|
---|
| 4793 |
|
---|
| 4794 | @property
|
---|
[391] | 4795 | def antiIceOn(self):
|
---|
| 4796 | """Get whether the anti-ice system has been turned on."""
|
---|
| 4797 | return self._antiIceOn.get_active()
|
---|
| 4798 |
|
---|
| 4799 | @antiIceOn.setter
|
---|
| 4800 | def antiIceOn(self, value):
|
---|
| 4801 | """Set the anti-ice indicator."""
|
---|
| 4802 | self._antiIceOn.set_active(value)
|
---|
| 4803 |
|
---|
| 4804 | @property
|
---|
[349] | 4805 | def rtoIndicated(self):
|
---|
| 4806 | """Get whether the pilot has indicated if there was an RTO."""
|
---|
| 4807 | return self._rto.get_active()
|
---|
| 4808 |
|
---|
[71] | 4809 | def activate(self):
|
---|
| 4810 | """Activate the page."""
|
---|
[919] | 4811 | print("TakeoffPage.activate")
|
---|
[551] | 4812 |
|
---|
[586] | 4813 | self._updatingMETAR = True
|
---|
| 4814 | self._metar.get_buffer().set_text(self._wizard.departureMETAR, -1)
|
---|
| 4815 | self._updatingMETAR = False
|
---|
| 4816 |
|
---|
[717] | 4817 | if self._wizard.takeoffRunway is None:
|
---|
| 4818 | self._runway.set_text("")
|
---|
| 4819 | else:
|
---|
| 4820 | self._runway.set_text(self._wizard.takeoffRunway)
|
---|
[71] | 4821 | self._runway.set_sensitive(True)
|
---|
[621] | 4822 | self._sid.set_active(0)
|
---|
[71] | 4823 | self._sid.set_sensitive(True)
|
---|
[84] | 4824 | self._v1.set_int(None)
|
---|
[71] | 4825 | self._v1.set_sensitive(True)
|
---|
[86] | 4826 | self._vr.set_int(None)
|
---|
[71] | 4827 | self._vr.set_sensitive(True)
|
---|
[86] | 4828 | self._v2.set_int(None)
|
---|
[71] | 4829 | self._v2.set_sensitive(True)
|
---|
[241] | 4830 |
|
---|
| 4831 | i18nSpeedUnit = self._wizard.gui.flight.getI18NSpeedUnit()
|
---|
| 4832 | speedUnit = xstr("label" + i18nSpeedUnit)
|
---|
| 4833 | self._v1Unit.set_text(speedUnit)
|
---|
| 4834 | self._vrUnit.set_text(speedUnit)
|
---|
| 4835 | self._v2Unit.set_text(speedUnit)
|
---|
| 4836 |
|
---|
| 4837 | self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip" + i18nSpeedUnit))
|
---|
| 4838 | self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip" + i18nSpeedUnit))
|
---|
| 4839 | self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip" + i18nSpeedUnit))
|
---|
| 4840 |
|
---|
[512] | 4841 | self._derateType = self._wizard.gui.flight.aircraft.derateType
|
---|
| 4842 |
|
---|
| 4843 | self._setupDerateWidget()
|
---|
[384] | 4844 |
|
---|
[349] | 4845 | self._rto.set_active(False)
|
---|
| 4846 | self._rto.set_sensitive(False)
|
---|
| 4847 |
|
---|
[84] | 4848 | self._button.set_sensitive(False)
|
---|
[218] | 4849 | self._forwardAllowed = False
|
---|
[347] | 4850 |
|
---|
[586] | 4851 | self._active = True
|
---|
| 4852 |
|
---|
[101] | 4853 | def allowForward(self):
|
---|
| 4854 | """Allow going to the next page."""
|
---|
[919] | 4855 | print("TakeoffPage.allowForward")
|
---|
[101] | 4856 | self._forwardAllowed = True
|
---|
| 4857 | self._updateForwardButton()
|
---|
| 4858 |
|
---|
[241] | 4859 | def reset(self):
|
---|
| 4860 | """Reset the page if the wizard is reset."""
|
---|
[919] | 4861 | print("TakeoffPage.reset")
|
---|
[551] | 4862 |
|
---|
[241] | 4863 | super(TakeoffPage, self).reset()
|
---|
| 4864 | self._v1.reset()
|
---|
| 4865 | self._vr.reset()
|
---|
| 4866 | self._v2.reset()
|
---|
[384] | 4867 | self._hasDerate = False
|
---|
[391] | 4868 | self._antiIceOn.set_active(False)
|
---|
[586] | 4869 | self._active = False
|
---|
[384] | 4870 |
|
---|
[349] | 4871 | def setRTOEnabled(self, enabled):
|
---|
| 4872 | """Set the RTO checkbox enabled or disabled."""
|
---|
| 4873 | if not enabled:
|
---|
| 4874 | self._rto.set_active(False)
|
---|
| 4875 | self._rto.set_sensitive(enabled)
|
---|
| 4876 |
|
---|
[1110] | 4877 | def changeMETAR(self, metar, fromEditing = True):
|
---|
[586] | 4878 | """Change the METAR as a result of an edit on one of the other
|
---|
| 4879 | pages."""
|
---|
| 4880 | if self._active:
|
---|
[919] | 4881 | print("TakeoffPage.changeMETAR")
|
---|
[586] | 4882 | self._updatingMETAR = True
|
---|
| 4883 | self._metar.get_buffer().set_text(metar, -1)
|
---|
| 4884 | self._updatingMETAR = False
|
---|
| 4885 |
|
---|
[588] | 4886 | self._updateForwardButton()
|
---|
| 4887 |
|
---|
[101] | 4888 | def _updateForwardButton(self):
|
---|
| 4889 | """Update the sensitivity of the forward button based on some conditions."""
|
---|
| 4890 | sensitive = self._forwardAllowed and \
|
---|
[588] | 4891 | self._metar.get_text()!="" and \
|
---|
[101] | 4892 | self._runway.get_text()!="" and \
|
---|
[621] | 4893 | self.sid is not None and \
|
---|
[101] | 4894 | self.v1 is not None and \
|
---|
| 4895 | self.vr is not None and \
|
---|
| 4896 | self.v2 is not None and \
|
---|
| 4897 | self.v1 <= self.vr and \
|
---|
[384] | 4898 | self.vr <= self.v2 and \
|
---|
[512] | 4899 | (self._derateType==acft.DERATE_NONE or
|
---|
| 4900 | self.derate is not None)
|
---|
[551] | 4901 |
|
---|
[919] | 4902 | print("TakeoffPage._updateForwardButton: forwardAllowed:", self._forwardAllowed, ", sensitive:", sensitive)
|
---|
[638] | 4903 | if self._forwardAllowed:
|
---|
[919] | 4904 | print(" METAR: ", self._metar.get_text())
|
---|
| 4905 | print(" runway: ", self._runway.get_text())
|
---|
| 4906 | print(" SID:", self.sid)
|
---|
| 4907 | print(" V1:", self.v1)
|
---|
| 4908 | print(" VR:", self.vr)
|
---|
| 4909 | print(" V2:", self.v2)
|
---|
| 4910 | print(" derateType:", self._derateType)
|
---|
| 4911 | print(" derate:", self.derate)
|
---|
[551] | 4912 |
|
---|
[101] | 4913 | self._button.set_sensitive(sensitive)
|
---|
| 4914 |
|
---|
| 4915 | def _valueChanged(self, widget, arg = None):
|
---|
| 4916 | """Called when the value of some widget has changed."""
|
---|
[919] | 4917 | print("TakeoffPage._valueChanged")
|
---|
[551] | 4918 |
|
---|
[101] | 4919 | self._updateForwardButton()
|
---|
[347] | 4920 |
|
---|
[138] | 4921 | def _upperChanged(self, entry, arg = None):
|
---|
| 4922 | """Called when the value of some entry widget has changed and the value
|
---|
| 4923 | should be converted to uppercase."""
|
---|
[919] | 4924 | print("TakeoffPage._upperChanged")
|
---|
[138] | 4925 | entry.set_text(entry.get_text().upper())
|
---|
| 4926 | self._valueChanged(entry, arg)
|
---|
[347] | 4927 |
|
---|
[621] | 4928 | def _upperChangedComboBox(self, comboBox):
|
---|
| 4929 | """Called for combo box widgets that must be converted to uppercase."""
|
---|
| 4930 | entry = comboBox.get_child()
|
---|
| 4931 | if comboBox.get_active()==-1:
|
---|
| 4932 | entry.set_text(entry.get_text().upper())
|
---|
| 4933 | self._valueChanged(entry)
|
---|
| 4934 |
|
---|
[384] | 4935 | def _derateChanged(self, entry):
|
---|
| 4936 | """Called when the value of the derate is changed."""
|
---|
[919] | 4937 | print("TakeoffPage._derateChanged")
|
---|
[384] | 4938 | self._updateForwardButton()
|
---|
| 4939 |
|
---|
[349] | 4940 | def _rtoToggled(self, button):
|
---|
| 4941 | """Called when the RTO check button is toggled."""
|
---|
| 4942 | self._wizard.rtoToggled(button.get_active())
|
---|
| 4943 |
|
---|
[71] | 4944 | def _backClicked(self, button):
|
---|
| 4945 | """Called when the Back button is pressed."""
|
---|
| 4946 | self.goBack()
|
---|
[347] | 4947 |
|
---|
[71] | 4948 | def _forwardClicked(self, button):
|
---|
| 4949 | """Called when the forward button is clicked."""
|
---|
[391] | 4950 | aircraft = self._wizard.gui.flight.aircraft
|
---|
| 4951 | aircraft.updateV1R2()
|
---|
[512] | 4952 | if self.derate is not None:
|
---|
[391] | 4953 | aircraft.updateDerate()
|
---|
| 4954 | aircraft.updateTakeoffAntiIce()
|
---|
[75] | 4955 | self._wizard.nextPage()
|
---|
| 4956 |
|
---|
[512] | 4957 | def _setupDerateWidget(self):
|
---|
| 4958 | """Setup the derate widget."""
|
---|
| 4959 | if self._derateWidget is not None:
|
---|
| 4960 | self._derate.remove(self._derateWidget)
|
---|
| 4961 |
|
---|
| 4962 | if self._derateType==acft.DERATE_BOEING:
|
---|
| 4963 | self._derateLabel.set_text(xstr("takeoff_derate_boeing"))
|
---|
| 4964 | self._derateLabel.set_use_underline(True)
|
---|
| 4965 | self._derateLabel.set_sensitive(True)
|
---|
| 4966 |
|
---|
[996] | 4967 | self._derateEntry = Gtk.Entry()
|
---|
[512] | 4968 | self._derateEntry.set_width_chars(7)
|
---|
| 4969 | self._derateEntry.set_tooltip_text(xstr("takeoff_derate_boeing_tooltip"))
|
---|
| 4970 | self._derateEntry.set_alignment(1.0)
|
---|
| 4971 | self._derateEntry.connect("changed", self._derateChanged)
|
---|
| 4972 | self._derateLabel.set_mnemonic_widget(self._derateEntry)
|
---|
| 4973 |
|
---|
[996] | 4974 | self._derateUnit = Gtk.Label("%")
|
---|
[512] | 4975 | self._derateUnit.set_alignment(0.0, 0.5)
|
---|
| 4976 |
|
---|
[996] | 4977 | self._derateWidget = Gtk.Table(3, 1)
|
---|
[512] | 4978 | self._derateWidget.set_row_spacings(4)
|
---|
| 4979 | self._derateWidget.set_col_spacings(16)
|
---|
| 4980 | self._derateWidget.set_homogeneous(False)
|
---|
| 4981 |
|
---|
| 4982 | self._derateWidget.attach(self._derateEntry, 0, 2, 0, 1)
|
---|
| 4983 | self._derateWidget.attach(self._derateUnit, 2, 3, 0, 1)
|
---|
| 4984 |
|
---|
| 4985 | self._derate.add(self._derateWidget)
|
---|
| 4986 | elif self._derateType==acft.DERATE_EPR:
|
---|
| 4987 | self._derateLabel.set_text("_EPR:")
|
---|
| 4988 | self._derateLabel.set_use_underline(True)
|
---|
| 4989 | self._derateLabel.set_sensitive(True)
|
---|
| 4990 |
|
---|
[996] | 4991 | self._derateWidget = Gtk.Entry()
|
---|
[512] | 4992 | self._derateWidget.set_width_chars(7)
|
---|
| 4993 | self._derateWidget.set_tooltip_text(xstr("takeoff_derate_epr_tooltip"))
|
---|
| 4994 | self._derateWidget.set_alignment(1.0)
|
---|
| 4995 | self._derateWidget.connect("changed", self._derateChanged)
|
---|
| 4996 | self._derateLabel.set_mnemonic_widget(self._derateWidget)
|
---|
| 4997 |
|
---|
| 4998 | self._derate.add(self._derateWidget)
|
---|
| 4999 | elif self._derateType==acft.DERATE_TUPOLEV:
|
---|
| 5000 | self._derateLabel.set_text(xstr("takeoff_derate_tupolev"))
|
---|
| 5001 | self._derateLabel.set_use_underline(True)
|
---|
| 5002 | self._derateLabel.set_sensitive(True)
|
---|
| 5003 |
|
---|
[996] | 5004 | nominal = Gtk.RadioButton.\
|
---|
[994] | 5005 | new_with_label_from_widget(None,
|
---|
| 5006 | xstr("takeoff_derate_tupolev_nominal"))
|
---|
[512] | 5007 | nominal.set_use_underline(True)
|
---|
| 5008 | nominal.set_tooltip_text(xstr("takeoff_derate_tupolev_nominal_tooltip"))
|
---|
| 5009 | nominal.connect("toggled", self._derateChanged)
|
---|
| 5010 |
|
---|
[996] | 5011 | takeoff = Gtk.RadioButton.\
|
---|
[994] | 5012 | new_with_label_from_widget(nominal,
|
---|
| 5013 | xstr("takeoff_derate_tupolev_takeoff"))
|
---|
[512] | 5014 |
|
---|
| 5015 | takeoff.set_use_underline(True)
|
---|
| 5016 | takeoff.set_tooltip_text(xstr("takeoff_derate_tupolev_takeoff_tooltip"))
|
---|
| 5017 | takeoff.connect("toggled", self._derateChanged)
|
---|
| 5018 |
|
---|
| 5019 | self._derateButtons = [nominal, takeoff]
|
---|
| 5020 |
|
---|
[996] | 5021 | self._derateWidget = Gtk.HBox()
|
---|
[512] | 5022 | self._derateWidget.pack_start(nominal, False, False, 4)
|
---|
| 5023 | self._derateWidget.pack_start(takeoff, False, False, 4)
|
---|
| 5024 |
|
---|
| 5025 | self._derate.add(self._derateWidget)
|
---|
| 5026 | elif self._derateType==acft.DERATE_B462:
|
---|
| 5027 | self._derateLabel.set_text("")
|
---|
| 5028 |
|
---|
[996] | 5029 | self._derateWidget = Gtk.CheckButton(xstr("takeoff_derate_b462"))
|
---|
[512] | 5030 | self._derateWidget.set_tooltip_text(xstr("takeoff_derate_b462_tooltip"))
|
---|
| 5031 | self._derateWidget.set_use_underline(True)
|
---|
| 5032 | self._derate.add(self._derateWidget)
|
---|
| 5033 | else:
|
---|
| 5034 | self._derateWidget = None
|
---|
| 5035 | self._derateLabel.set_text("")
|
---|
| 5036 | self._derateLabel.set_sensitive(False)
|
---|
| 5037 |
|
---|
[586] | 5038 | def _metarChanged(self, entry):
|
---|
| 5039 | """Called when the METAR has changed."""
|
---|
[919] | 5040 | print("TakeoffPage.metarChanged", self._updatingMETAR)
|
---|
[586] | 5041 | if not self._updatingMETAR:
|
---|
| 5042 | self._updateForwardButton()
|
---|
| 5043 | self._wizard.metarChanged(entry.get_text(), self)
|
---|
| 5044 |
|
---|
[587] | 5045 | def _metarInserted(self, buffer, position, text, length):
|
---|
[586] | 5046 | """Called when new characters are inserted into the METAR.
|
---|
| 5047 |
|
---|
| 5048 | It uppercases all characters."""
|
---|
[919] | 5049 | print("TakeoffPage.metarInserted", self._updatingMETAR)
|
---|
[586] | 5050 | if not self._updatingMETAR:
|
---|
| 5051 | self._updatingMETAR = True
|
---|
| 5052 |
|
---|
[587] | 5053 | buffer.delete_text(position, length)
|
---|
| 5054 | buffer.insert_text(position, text.upper(), length)
|
---|
[586] | 5055 |
|
---|
| 5056 | self._updatingMETAR = False
|
---|
| 5057 |
|
---|
[75] | 5058 | #-----------------------------------------------------------------------------
|
---|
| 5059 |
|
---|
[383] | 5060 | class CruisePage(Page):
|
---|
| 5061 | """The page containing the flight level that might change during flight."""
|
---|
| 5062 | def __init__(self, wizard):
|
---|
| 5063 | """Construct the page."""
|
---|
[754] | 5064 | super(CruisePage, self).__init__(wizard, "cruise",
|
---|
| 5065 | xstr("cruise_title"),
|
---|
[383] | 5066 | xstr("cruise_help"))
|
---|
| 5067 |
|
---|
| 5068 | self._loggable = False
|
---|
| 5069 | self._loggedCruiseLevel = 240
|
---|
| 5070 | self._activated = False
|
---|
| 5071 |
|
---|
[996] | 5072 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
[383] | 5073 | xscale = 0.0, yscale = 1.0)
|
---|
| 5074 |
|
---|
[996] | 5075 | mainBox = Gtk.VBox()
|
---|
[383] | 5076 | alignment.add(mainBox)
|
---|
| 5077 | self.setMainWidget(alignment)
|
---|
| 5078 |
|
---|
[996] | 5079 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[383] | 5080 | xscale = 0.0, yscale = 0.0)
|
---|
| 5081 | mainBox.pack_start(alignment, False, False, 16)
|
---|
| 5082 |
|
---|
[996] | 5083 | levelBox = Gtk.HBox()
|
---|
| 5084 |
|
---|
| 5085 | label = Gtk.Label(xstr("route_level"))
|
---|
[383] | 5086 | label.set_use_underline(True)
|
---|
| 5087 | levelBox.pack_start(label, True, True, 0)
|
---|
| 5088 |
|
---|
[996] | 5089 | self._cruiseLevel = Gtk.SpinButton()
|
---|
[383] | 5090 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
| 5091 | self._cruiseLevel.set_range(min = 50, max = 500)
|
---|
| 5092 | self._cruiseLevel.set_tooltip_text(xstr("cruise_route_level_tooltip"))
|
---|
| 5093 | self._cruiseLevel.set_numeric(True)
|
---|
| 5094 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
| 5095 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
| 5096 |
|
---|
| 5097 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
| 5098 |
|
---|
[996] | 5099 | self._updateButton = Gtk.Button(xstr("cruise_route_level_update"));
|
---|
[383] | 5100 | self._updateButton.set_use_underline(True)
|
---|
| 5101 | self._updateButton.set_tooltip_text(xstr("cruise_route_level_update_tooltip"))
|
---|
| 5102 | self._updateButton.connect("clicked", self._updateButtonClicked)
|
---|
| 5103 |
|
---|
| 5104 | levelBox.pack_start(self._updateButton, False, False, 16)
|
---|
| 5105 |
|
---|
| 5106 | mainBox.pack_start(levelBox, False, False, 0)
|
---|
| 5107 |
|
---|
[996] | 5108 | alignment = Gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[383] | 5109 | xscale = 0.0, yscale = 1.0)
|
---|
| 5110 | mainBox.pack_start(alignment, True, True, 0)
|
---|
| 5111 |
|
---|
| 5112 | self.addCancelFlightButton()
|
---|
| 5113 |
|
---|
| 5114 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 5115 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 5116 |
|
---|
| 5117 | @property
|
---|
| 5118 | def activated(self):
|
---|
| 5119 | """Determine if the page is already activated or not."""
|
---|
| 5120 | return self._activated
|
---|
| 5121 |
|
---|
| 5122 | @property
|
---|
| 5123 | def cruiseLevel(self):
|
---|
| 5124 | """Get the cruise level."""
|
---|
| 5125 | return self._loggedCruiseLevel
|
---|
| 5126 |
|
---|
| 5127 | @property
|
---|
| 5128 | def loggableCruiseLevel(self):
|
---|
| 5129 | """Get the cruise level which should be logged."""
|
---|
| 5130 | return self._cruiseLevel.get_value_as_int()
|
---|
| 5131 |
|
---|
| 5132 | def setLoggable(self, loggable):
|
---|
| 5133 | """Set whether the cruise altitude can be logged."""
|
---|
| 5134 | self._loggable = loggable
|
---|
| 5135 | self._updateButtons()
|
---|
| 5136 |
|
---|
| 5137 | def activate(self):
|
---|
| 5138 | """Setup the route from the booked flight."""
|
---|
| 5139 | self._loggedCruiseLevel = self._wizard.filedCruiseLevel
|
---|
| 5140 | self._cruiseLevel.set_value(self._loggedCruiseLevel)
|
---|
| 5141 | self._activated = True
|
---|
| 5142 |
|
---|
| 5143 | def reset(self):
|
---|
| 5144 | """Reset the page."""
|
---|
| 5145 | self._loggable = False
|
---|
| 5146 | self._activated = False
|
---|
| 5147 | super(CruisePage, self).reset()
|
---|
| 5148 |
|
---|
| 5149 | def _updateButtons(self):
|
---|
| 5150 | """Update the sensitivity of the buttons."""
|
---|
| 5151 | self._updateButton.set_sensitive(self._loggable and
|
---|
| 5152 | self.loggableCruiseLevel!=
|
---|
| 5153 | self._loggedCruiseLevel)
|
---|
| 5154 |
|
---|
| 5155 | def _cruiseLevelChanged(self, spinButton):
|
---|
| 5156 | """Called when the cruise level has changed."""
|
---|
| 5157 | self._updateButtons()
|
---|
| 5158 |
|
---|
| 5159 | def _updateButtonClicked(self, button):
|
---|
| 5160 | """Called when the update button is clicked."""
|
---|
| 5161 | if self._wizard.cruiseLevelChanged():
|
---|
| 5162 | self._loggedCruiseLevel = self.loggableCruiseLevel
|
---|
| 5163 | self._updateButtons()
|
---|
| 5164 |
|
---|
| 5165 | def _backClicked(self, button):
|
---|
| 5166 | """Called when the Back button is pressed."""
|
---|
| 5167 | self.goBack()
|
---|
| 5168 |
|
---|
| 5169 | def _forwardClicked(self, button):
|
---|
| 5170 | """Called when the Forward button is clicked."""
|
---|
| 5171 | self._wizard.nextPage()
|
---|
| 5172 |
|
---|
| 5173 | #-----------------------------------------------------------------------------
|
---|
| 5174 |
|
---|
[75] | 5175 | class LandingPage(Page):
|
---|
| 5176 | """Page for entering landing data."""
|
---|
| 5177 | def __init__(self, wizard):
|
---|
| 5178 | """Construct the landing page."""
|
---|
[754] | 5179 | super(LandingPage, self).__init__(wizard, "landing",
|
---|
| 5180 | xstr("landing_title"),
|
---|
[107] | 5181 | xstr("landing_help"),
|
---|
| 5182 | completedHelp = xstr("landing_chelp"))
|
---|
[75] | 5183 |
|
---|
[88] | 5184 | self._flightEnded = False
|
---|
| 5185 |
|
---|
[996] | 5186 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[75] | 5187 | xscale = 0.0, yscale = 0.0)
|
---|
| 5188 |
|
---|
[996] | 5189 | table = Gtk.Table(7, 24)
|
---|
[75] | 5190 | table.set_row_spacings(4)
|
---|
| 5191 | table.set_col_spacings(16)
|
---|
| 5192 | table.set_homogeneous(False)
|
---|
| 5193 | alignment.add(table)
|
---|
| 5194 | self.setMainWidget(alignment)
|
---|
| 5195 |
|
---|
[589] | 5196 | row = 0
|
---|
| 5197 |
|
---|
[996] | 5198 | label = Gtk.Label(xstr("landing_metar"))
|
---|
[589] | 5199 | label.set_use_underline(True)
|
---|
| 5200 | label.set_alignment(0.0, 0.5)
|
---|
[728] | 5201 | table.attach(label, 1, 2, row, row+1)
|
---|
[589] | 5202 |
|
---|
[996] | 5203 | self._metar = Gtk.Entry()
|
---|
[589] | 5204 | self._metar.set_width_chars(40)
|
---|
[590] | 5205 | self._metar.set_tooltip_text(xstr("landing_metar_tooltip"))
|
---|
[589] | 5206 | self._metar.connect("changed", self._metarChanged)
|
---|
| 5207 | self._metar.get_buffer().connect_after("inserted-text", self._metarInserted)
|
---|
[728] | 5208 | table.attach(self._metar, 2, 24, row, row+1)
|
---|
[589] | 5209 | label.set_mnemonic_widget(self._metar)
|
---|
| 5210 |
|
---|
| 5211 | self._updatingMETAR = False
|
---|
| 5212 |
|
---|
| 5213 | row += 1
|
---|
| 5214 |
|
---|
[996] | 5215 | label = Gtk.Label(xstr("landing_star"))
|
---|
[75] | 5216 | label.set_use_underline(True)
|
---|
| 5217 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 5218 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 5219 |
|
---|
[996] | 5220 | self._star = Gtk.ComboBox.new_with_model_and_entry(comboModel)
|
---|
[621] | 5221 |
|
---|
| 5222 | self._star.set_entry_text_column(0)
|
---|
| 5223 | self._star.get_child().set_width_chars(10)
|
---|
[107] | 5224 | self._star.set_tooltip_text(xstr("landing_star_tooltip"))
|
---|
[621] | 5225 | self._star.connect("changed", self._upperChangedComboBox)
|
---|
[75] | 5226 | self._star.set_sensitive(False)
|
---|
[589] | 5227 | table.attach(self._star, 2, 4, row, row + 1)
|
---|
[621] | 5228 | label.set_mnemonic_widget(self._star)
|
---|
[75] | 5229 |
|
---|
[589] | 5230 | row += 1
|
---|
| 5231 |
|
---|
[996] | 5232 | label = Gtk.Label(xstr("landing_transition"))
|
---|
[75] | 5233 | label.set_use_underline(True)
|
---|
| 5234 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 5235 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 5236 |
|
---|
[996] | 5237 | self._transition = Gtk.ComboBox.new_with_model_and_entry(comboModel)
|
---|
[621] | 5238 |
|
---|
| 5239 | self._transition.set_entry_text_column(0)
|
---|
| 5240 | self._transition.get_child().set_width_chars(10)
|
---|
[107] | 5241 | self._transition.set_tooltip_text(xstr("landing_transition_tooltip"))
|
---|
[621] | 5242 | self._transition.connect("changed", self._upperChangedComboBox)
|
---|
[75] | 5243 | self._transition.set_sensitive(False)
|
---|
[589] | 5244 | table.attach(self._transition, 2, 4, row, row + 1)
|
---|
[621] | 5245 | label.set_mnemonic_widget(self._transition)
|
---|
[75] | 5246 |
|
---|
[589] | 5247 | row += 1
|
---|
| 5248 |
|
---|
[996] | 5249 | label = Gtk.Label(xstr("landing_runway"))
|
---|
[75] | 5250 | label.set_use_underline(True)
|
---|
| 5251 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 5252 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 5253 |
|
---|
[996] | 5254 | self._runway = Gtk.Entry()
|
---|
[75] | 5255 | self._runway.set_width_chars(10)
|
---|
[107] | 5256 | self._runway.set_tooltip_text(xstr("landing_runway_tooltip"))
|
---|
[138] | 5257 | self._runway.connect("changed", self._upperChanged)
|
---|
[589] | 5258 | table.attach(self._runway, 2, 4, row, row + 1)
|
---|
[75] | 5259 | label.set_mnemonic_widget(self._runway)
|
---|
| 5260 |
|
---|
[589] | 5261 | row += 1
|
---|
| 5262 |
|
---|
[996] | 5263 | label = Gtk.Label(xstr("landing_approach"))
|
---|
[75] | 5264 | label.set_use_underline(True)
|
---|
| 5265 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 5266 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 5267 |
|
---|
[996] | 5268 | self._approachType = Gtk.Entry()
|
---|
[75] | 5269 | self._approachType.set_width_chars(10)
|
---|
[107] | 5270 | self._approachType.set_tooltip_text(xstr("landing_approach_tooltip"))
|
---|
[138] | 5271 | self._approachType.connect("changed", self._upperChanged)
|
---|
[589] | 5272 | table.attach(self._approachType, 2, 4, row, row + 1)
|
---|
[75] | 5273 | label.set_mnemonic_widget(self._approachType)
|
---|
| 5274 |
|
---|
[589] | 5275 | row += 1
|
---|
| 5276 |
|
---|
[996] | 5277 | label = Gtk.Label(xstr("landing_vref"))
|
---|
[75] | 5278 | label.set_use_markup(True)
|
---|
| 5279 | label.set_use_underline(True)
|
---|
| 5280 | label.set_alignment(0.0, 0.5)
|
---|
[589] | 5281 | table.attach(label, 1, 2, row, row + 1)
|
---|
[75] | 5282 |
|
---|
[86] | 5283 | self._vref = IntegerEntry()
|
---|
| 5284 | self._vref.set_width_chars(5)
|
---|
[241] | 5285 | self._vref.set_tooltip_markup(xstr("landing_vref_tooltip_knots"))
|
---|
[86] | 5286 | self._vref.connect("integer-changed", self._vrefChanged)
|
---|
[589] | 5287 | table.attach(self._vref, 3, 4, row, row + 1)
|
---|
[75] | 5288 | label.set_mnemonic_widget(self._vref)
|
---|
[241] | 5289 |
|
---|
[996] | 5290 | self._vrefUnit = Gtk.Label(xstr("label_knots"))
|
---|
[589] | 5291 | table.attach(self._vrefUnit, 4, 5, row, row + 1)
|
---|
| 5292 |
|
---|
| 5293 | row += 1
|
---|
[391] | 5294 |
|
---|
[996] | 5295 | self._antiIceOn = Gtk.CheckButton(xstr("landing_antiice"))
|
---|
[391] | 5296 | self._antiIceOn.set_use_underline(True)
|
---|
| 5297 | self._antiIceOn.set_tooltip_text(xstr("landing_antiice_tooltip"))
|
---|
[589] | 5298 | table.attach(self._antiIceOn, 3, 5, row, row + 1)
|
---|
[75] | 5299 |
|
---|
[208] | 5300 | self.addCancelFlightButton()
|
---|
| 5301 |
|
---|
[107] | 5302 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 5303 |
|
---|
| 5304 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[75] | 5305 |
|
---|
[589] | 5306 | self._active = False
|
---|
| 5307 |
|
---|
[86] | 5308 | @property
|
---|
[97] | 5309 | def star(self):
|
---|
| 5310 | """Get the STAR or None if none entered."""
|
---|
[621] | 5311 | text = self._star.get_child().get_text()
|
---|
| 5312 | return text if self._star.get_active()!=0 and text and text!="N/A" \
|
---|
| 5313 | else None
|
---|
[97] | 5314 |
|
---|
| 5315 | @property
|
---|
| 5316 | def transition(self):
|
---|
| 5317 | """Get the transition or None if none entered."""
|
---|
[621] | 5318 | text = self._transition.get_child().get_text()
|
---|
| 5319 | return text if self._transition.get_active()!=0 and text and text!="N/A" \
|
---|
| 5320 | else None
|
---|
[97] | 5321 |
|
---|
| 5322 | @property
|
---|
| 5323 | def approachType(self):
|
---|
| 5324 | """Get the approach type."""
|
---|
| 5325 | return self._approachType.get_text()
|
---|
| 5326 |
|
---|
| 5327 | @property
|
---|
| 5328 | def runway(self):
|
---|
| 5329 | """Get the runway."""
|
---|
| 5330 | return self._runway.get_text()
|
---|
| 5331 |
|
---|
| 5332 | @property
|
---|
[86] | 5333 | def vref(self):
|
---|
| 5334 | """Return the landing reference speed."""
|
---|
| 5335 | return self._vref.get_int()
|
---|
| 5336 |
|
---|
[391] | 5337 | @property
|
---|
| 5338 | def antiIceOn(self):
|
---|
| 5339 | """Get whether the anti-ice system has been turned on."""
|
---|
| 5340 | return self._antiIceOn.get_active()
|
---|
| 5341 |
|
---|
| 5342 | @antiIceOn.setter
|
---|
| 5343 | def antiIceOn(self, value):
|
---|
| 5344 | """Set the anti-ice indicator."""
|
---|
| 5345 | self._antiIceOn.set_active(value)
|
---|
| 5346 |
|
---|
[218] | 5347 | def reset(self):
|
---|
| 5348 | """Reset the page if the wizard is reset."""
|
---|
| 5349 | super(LandingPage, self).reset()
|
---|
[241] | 5350 | self._vref.reset()
|
---|
[391] | 5351 | self._antiIceOn.set_active(False)
|
---|
[218] | 5352 | self._flightEnded = False
|
---|
[589] | 5353 | self._active = False
|
---|
[347] | 5354 |
|
---|
[75] | 5355 | def activate(self):
|
---|
| 5356 | """Called when the page is activated."""
|
---|
[589] | 5357 | self._updatingMETAR = True
|
---|
| 5358 | self._metar.get_buffer().set_text(self._wizard.arrivalMETAR, -1)
|
---|
| 5359 | self._updatingMETAR = False
|
---|
| 5360 |
|
---|
[621] | 5361 | self._star.set_active(0)
|
---|
| 5362 | self._star.set_sensitive(True)
|
---|
| 5363 |
|
---|
| 5364 | self._transition.set_active(0)
|
---|
| 5365 | self._transition.set_sensitive(True)
|
---|
[75] | 5366 |
|
---|
[717] | 5367 | if self._wizard.landingRunway is None:
|
---|
| 5368 | self._runway.set_text("")
|
---|
| 5369 | else:
|
---|
| 5370 | self._runway.set_text(self._wizard.landingRunway)
|
---|
[75] | 5371 | self._runway.set_sensitive(True)
|
---|
| 5372 |
|
---|
| 5373 | self._approachType.set_text("")
|
---|
| 5374 | self._approachType.set_sensitive(True)
|
---|
| 5375 |
|
---|
[86] | 5376 | self._vref.set_int(None)
|
---|
[75] | 5377 | self._vref.set_sensitive(True)
|
---|
| 5378 |
|
---|
[241] | 5379 | i18nSpeedUnit = self._wizard.gui.flight.getI18NSpeedUnit()
|
---|
| 5380 | speedUnit = xstr("label" + i18nSpeedUnit)
|
---|
| 5381 | self._vrefUnit.set_text(speedUnit)
|
---|
| 5382 |
|
---|
| 5383 | self._vref.set_tooltip_markup(xstr("landing_vref_tooltip" +
|
---|
| 5384 | i18nSpeedUnit))
|
---|
| 5385 |
|
---|
[75] | 5386 | self._updateForwardButton()
|
---|
| 5387 |
|
---|
[589] | 5388 | self._active = True
|
---|
| 5389 |
|
---|
[88] | 5390 | def flightEnded(self):
|
---|
| 5391 | """Called when the flight has ended."""
|
---|
[275] | 5392 | super(LandingPage, self).flightEnded()
|
---|
[88] | 5393 | self._flightEnded = True
|
---|
| 5394 | self._updateForwardButton()
|
---|
| 5395 |
|
---|
[1110] | 5396 | def changeMETAR(self, metar, fromEditing = True):
|
---|
[589] | 5397 | """Change the METAR as a result of an edit on one of the other
|
---|
| 5398 | pages."""
|
---|
| 5399 | if self._active:
|
---|
[919] | 5400 | print("LandingPage.changeMETAR")
|
---|
[589] | 5401 | self._updatingMETAR = True
|
---|
| 5402 | self._metar.get_buffer().set_text(metar, -1)
|
---|
| 5403 | self._updatingMETAR = False
|
---|
| 5404 |
|
---|
| 5405 | self._updateForwardButton()
|
---|
| 5406 |
|
---|
[138] | 5407 | def _updateForwardButton(self):
|
---|
[75] | 5408 | """Update the sensitivity of the forward button."""
|
---|
[88] | 5409 | sensitive = self._flightEnded and \
|
---|
[589] | 5410 | self._metar.get_text()!="" and \
|
---|
[621] | 5411 | (self.star is not None or
|
---|
| 5412 | self.transition is not None) and \
|
---|
[75] | 5413 | self._runway.get_text()!="" and \
|
---|
[86] | 5414 | self._approachType.get_text()!="" and \
|
---|
| 5415 | self.vref is not None
|
---|
[75] | 5416 | self._button.set_sensitive(sensitive)
|
---|
| 5417 |
|
---|
[138] | 5418 | def _upperChanged(self, entry):
|
---|
| 5419 | """Called for entry widgets that must be converted to uppercase."""
|
---|
| 5420 | entry.set_text(entry.get_text().upper())
|
---|
| 5421 | self._updateForwardButton()
|
---|
| 5422 |
|
---|
[621] | 5423 | def _upperChangedComboBox(self, comboBox):
|
---|
| 5424 | """Called for combo box widgets that must be converted to uppercase."""
|
---|
| 5425 | if comboBox.get_active()==-1:
|
---|
| 5426 | entry = comboBox.get_child()
|
---|
| 5427 | entry.set_text(entry.get_text().upper())
|
---|
| 5428 | self._updateForwardButton()
|
---|
| 5429 |
|
---|
[86] | 5430 | def _vrefChanged(self, widget, value):
|
---|
| 5431 | """Called when the Vref has changed."""
|
---|
| 5432 | self._updateForwardButton()
|
---|
| 5433 |
|
---|
[75] | 5434 | def _backClicked(self, button):
|
---|
| 5435 | """Called when the Back button is pressed."""
|
---|
| 5436 | self.goBack()
|
---|
[347] | 5437 |
|
---|
[75] | 5438 | def _forwardClicked(self, button):
|
---|
| 5439 | """Called when the forward button is clicked."""
|
---|
[769] | 5440 | wizard = self._wizard
|
---|
| 5441 |
|
---|
| 5442 | aircraft = wizard.gui.flight.aircraft
|
---|
[391] | 5443 | aircraft.updateVRef()
|
---|
| 5444 | aircraft.updateLandingAntiIce()
|
---|
[769] | 5445 | if wizard.gui.config.onlineGateSystem and \
|
---|
| 5446 | wizard.loggedIn and not self._completed and \
|
---|
| 5447 | wizard.bookedFlight.arrivalICAO=="LHBP" and \
|
---|
| 5448 | not wizard.entranceExam:
|
---|
| 5449 | wizard.getFleet(callback = self._fleetRetrieved, force = True)
|
---|
| 5450 | elif wizard.entranceExam:
|
---|
| 5451 | self._handleEntranceExamDone()
|
---|
[130] | 5452 | else:
|
---|
[769] | 5453 | wizard.nextPage()
|
---|
[130] | 5454 |
|
---|
| 5455 | def _fleetRetrieved(self, fleet):
|
---|
| 5456 | """Callback for the fleet retrieval."""
|
---|
[89] | 5457 | self._wizard.nextPage()
|
---|
| 5458 |
|
---|
[589] | 5459 | def _metarChanged(self, entry):
|
---|
| 5460 | """Called when the METAR has changed."""
|
---|
[919] | 5461 | print("LandingPage.metarChanged", self._updatingMETAR)
|
---|
[589] | 5462 | if not self._updatingMETAR:
|
---|
| 5463 | self._updateForwardButton()
|
---|
| 5464 | self._wizard.metarChanged(entry.get_text(), self)
|
---|
| 5465 |
|
---|
| 5466 | def _metarInserted(self, buffer, position, text, length):
|
---|
| 5467 | """Called when new characters are inserted into the METAR.
|
---|
| 5468 |
|
---|
| 5469 | It uppercases all characters."""
|
---|
[919] | 5470 | print("LandingPage.metarInserted", self._updatingMETAR)
|
---|
[589] | 5471 | if not self._updatingMETAR:
|
---|
| 5472 | self._updatingMETAR = True
|
---|
| 5473 |
|
---|
| 5474 | buffer.delete_text(position, length)
|
---|
| 5475 | buffer.insert_text(position, text.upper(), length)
|
---|
| 5476 |
|
---|
| 5477 | self._updatingMETAR = False
|
---|
| 5478 |
|
---|
[769] | 5479 | def _handleEntranceExamDone(self):
|
---|
| 5480 | """Handle the end of the entrance exam.
|
---|
| 5481 |
|
---|
| 5482 | If the there was a NO-GO fault, notify the user that exam is a failure
|
---|
| 5483 | and take them back to the student page. Otherwise congratulate, update
|
---|
| 5484 | the database to reflect that the exam has been taken and go back to the
|
---|
| 5485 | student page."""
|
---|
| 5486 | self._wizard.jumpPage("chkfinish")
|
---|
| 5487 |
|
---|
| 5488 | #-----------------------------------------------------------------------------
|
---|
| 5489 |
|
---|
| 5490 | class PIREPSaveHelper(object):
|
---|
| 5491 | """A helper to use for saving PIREPs."""
|
---|
| 5492 | def __init__(self, wizard):
|
---|
| 5493 | """Construct the helper."""
|
---|
| 5494 | super(PIREPSaveHelper, self).__init__()
|
---|
| 5495 |
|
---|
| 5496 | self._wizard = wizard
|
---|
| 5497 |
|
---|
| 5498 | self._lastSavePath = None
|
---|
| 5499 | self._savePIREPDialog = None
|
---|
| 5500 |
|
---|
| 5501 | def addButton(self, page):
|
---|
| 5502 | """Add a button to save the PIREP to the given page."""
|
---|
| 5503 | return page.addButton(xstr("finish_save"), sensitive = False,
|
---|
| 5504 | clicked = self._saveClicked,
|
---|
| 5505 | tooltip = xstr("finish_save_tooltip"),
|
---|
| 5506 | clickedArg = page)
|
---|
| 5507 |
|
---|
[777] | 5508 | def autoSavePIREP(self, page):
|
---|
[769] | 5509 | """Perform the automatic saving of the PIREP."""
|
---|
| 5510 | self._lastSavePath = os.path.join(self._wizard.gui.config.pirepDirectory,
|
---|
| 5511 | self._getDefaultPIREPName())
|
---|
[954] | 5512 | self._lastSavePath = self._lastSavePath
|
---|
[777] | 5513 | self._savePIREP(page, automatic = True)
|
---|
[769] | 5514 |
|
---|
| 5515 | def _getDefaultPIREPName(self):
|
---|
| 5516 | """Get the default name of the PIREP."""
|
---|
| 5517 | gui = self._wizard.gui
|
---|
| 5518 |
|
---|
| 5519 | bookedFlight = gui.bookedFlight
|
---|
| 5520 | tm = time.gmtime()
|
---|
| 5521 |
|
---|
| 5522 | pilotID = self._wizard.pilotID
|
---|
| 5523 | if pilotID: pilotID += " "
|
---|
| 5524 | return "%s%s %02d%02d %s-%s.pirep" % \
|
---|
| 5525 | (pilotID, str(bookedFlight.departureTime.date()),
|
---|
| 5526 | tm.tm_hour, tm.tm_min,
|
---|
| 5527 | bookedFlight.departureICAO, bookedFlight.arrivalICAO)
|
---|
| 5528 |
|
---|
| 5529 | def _saveClicked(self, button, page):
|
---|
| 5530 | """Called when the Save PIREP button is clicked."""
|
---|
| 5531 | gui = self._wizard.gui
|
---|
| 5532 |
|
---|
| 5533 | fileName = self._getDefaultPIREPName()
|
---|
| 5534 |
|
---|
| 5535 | dialog = self._getSaveDialog()
|
---|
| 5536 |
|
---|
| 5537 | if self._lastSavePath is None:
|
---|
| 5538 | pirepDirectory = gui.config.pirepDirectory
|
---|
| 5539 | if pirepDirectory is not None:
|
---|
| 5540 | dialog.set_current_folder(pirepDirectory)
|
---|
| 5541 | else:
|
---|
| 5542 | dialog.set_current_folder(os.path.dirname(self._lastSavePath))
|
---|
| 5543 |
|
---|
| 5544 | dialog.set_current_name(fileName)
|
---|
| 5545 | result = dialog.run()
|
---|
| 5546 | dialog.hide()
|
---|
| 5547 |
|
---|
[999] | 5548 | if result==Gtk.ResponseType.OK:
|
---|
[954] | 5549 | self._lastSavePath = dialog.get_filename()
|
---|
[769] | 5550 | self._savePIREP(page)
|
---|
| 5551 |
|
---|
| 5552 | def _savePIREP(self, page, automatic = False):
|
---|
| 5553 | """Perform the saving of the PIREP."""
|
---|
| 5554 |
|
---|
| 5555 | gui = self._wizard.gui
|
---|
| 5556 |
|
---|
| 5557 | if automatic:
|
---|
| 5558 | gui.beginBusy(xstr("finish_autosave_busy"))
|
---|
| 5559 |
|
---|
| 5560 | pirep = PIREP(gui.flight)
|
---|
| 5561 | error = pirep.save(self._lastSavePath)
|
---|
| 5562 |
|
---|
| 5563 | if automatic:
|
---|
| 5564 | gui.endBusy()
|
---|
| 5565 |
|
---|
| 5566 | if error:
|
---|
[999] | 5567 | type = Gtk.MessageType.ERROR
|
---|
[769] | 5568 | message = xstr("finish_save_failed")
|
---|
[954] | 5569 | secondary = xstr("finish_save_failed_sec") % (error,)
|
---|
[769] | 5570 | else:
|
---|
[999] | 5571 | type = Gtk.MessageType.INFO
|
---|
[769] | 5572 | message = xstr("finish_save_done")
|
---|
| 5573 | if automatic:
|
---|
| 5574 | secondary = xstr("finish_save_done_sec") % (self._lastSavePath,)
|
---|
| 5575 | else:
|
---|
| 5576 | secondary = None
|
---|
| 5577 | page.setPIREPSaved()
|
---|
| 5578 |
|
---|
[996] | 5579 | dialog = Gtk.MessageDialog(parent = gui.mainWindow,
|
---|
[769] | 5580 | type = type, message_format = message)
|
---|
[999] | 5581 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
[769] | 5582 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 5583 | if secondary is not None:
|
---|
| 5584 | dialog.format_secondary_markup(secondary)
|
---|
| 5585 |
|
---|
| 5586 | dialog.run()
|
---|
| 5587 | dialog.hide()
|
---|
| 5588 |
|
---|
| 5589 | def _getSaveDialog(self):
|
---|
| 5590 | """Get the PIREP saving dialog.
|
---|
| 5591 |
|
---|
| 5592 | If it does not exist yet, create it."""
|
---|
| 5593 | if self._savePIREPDialog is None:
|
---|
| 5594 | gui = self._wizard.gui
|
---|
[996] | 5595 | dialog = Gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
[769] | 5596 | xstr("finish_save_title"),
|
---|
[999] | 5597 | action = Gtk.FileChooserAction.SAVE,
|
---|
[996] | 5598 | buttons = (Gtk.STOCK_CANCEL,
|
---|
[999] | 5599 | Gtk.ResponseType.CANCEL,
|
---|
| 5600 | Gtk.STOCK_OK, Gtk.ResponseType.OK),
|
---|
[769] | 5601 | parent = gui.mainWindow)
|
---|
| 5602 | dialog.set_modal(True)
|
---|
| 5603 | dialog.set_do_overwrite_confirmation(True)
|
---|
| 5604 |
|
---|
[996] | 5605 | filter = Gtk.FileFilter()
|
---|
[769] | 5606 | filter.set_name(xstr("file_filter_pireps"))
|
---|
| 5607 | filter.add_pattern("*.pirep")
|
---|
| 5608 | dialog.add_filter(filter)
|
---|
| 5609 |
|
---|
[996] | 5610 | filter = Gtk.FileFilter()
|
---|
[769] | 5611 | filter.set_name(xstr("file_filter_all"))
|
---|
| 5612 | filter.add_pattern("*.*")
|
---|
| 5613 | dialog.add_filter(filter)
|
---|
| 5614 |
|
---|
| 5615 | self._savePIREPDialog = dialog
|
---|
| 5616 |
|
---|
| 5617 | return self._savePIREPDialog
|
---|
| 5618 |
|
---|
[89] | 5619 | #-----------------------------------------------------------------------------
|
---|
| 5620 |
|
---|
| 5621 | class FinishPage(Page):
|
---|
| 5622 | """Flight finish page."""
|
---|
[769] | 5623 | def __init__(self, wizard, saveHelper):
|
---|
[89] | 5624 | """Construct the finish page."""
|
---|
[564] | 5625 | help = xstr("finish_help") + xstr("finish_help_goodtime")
|
---|
[754] | 5626 | super(FinishPage, self).__init__(wizard, "finish",
|
---|
| 5627 | xstr("finish_title"), help)
|
---|
[347] | 5628 |
|
---|
[996] | 5629 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[89] | 5630 | xscale = 0.0, yscale = 0.0)
|
---|
| 5631 |
|
---|
[996] | 5632 | table = Gtk.Table(10, 2)
|
---|
[89] | 5633 | table.set_row_spacings(4)
|
---|
| 5634 | table.set_col_spacings(16)
|
---|
[96] | 5635 | table.set_homogeneous(False)
|
---|
[89] | 5636 | alignment.add(table)
|
---|
| 5637 | self.setMainWidget(alignment)
|
---|
| 5638 |
|
---|
[555] | 5639 | row = 0
|
---|
| 5640 |
|
---|
[996] | 5641 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 5642 | label = Gtk.Label(xstr("finish_rating"))
|
---|
[89] | 5643 | labelAlignment.add(label)
|
---|
[555] | 5644 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 5645 |
|
---|
[996] | 5646 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 5647 | self._flightRating = Gtk.Label()
|
---|
[154] | 5648 | self._flightRating.set_width_chars(8)
|
---|
[89] | 5649 | self._flightRating.set_alignment(0.0, 0.5)
|
---|
| 5650 | self._flightRating.set_use_markup(True)
|
---|
| 5651 | labelAlignment.add(self._flightRating)
|
---|
[555] | 5652 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 5653 |
|
---|
| 5654 | row += 1
|
---|
| 5655 |
|
---|
[996] | 5656 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 5657 | label = Gtk.Label(xstr("finish_dep_time"))
|
---|
[555] | 5658 | labelAlignment.add(label)
|
---|
| 5659 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
| 5660 |
|
---|
[996] | 5661 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 5662 | self._depTime = Gtk.Label()
|
---|
[556] | 5663 | self._depTime.set_width_chars(13)
|
---|
[555] | 5664 | self._depTime.set_alignment(0.0, 0.5)
|
---|
| 5665 | self._depTime.set_use_markup(True)
|
---|
[558] | 5666 | self._depTime.set_tooltip_markup(xstr("finish_dep_time_tooltip"))
|
---|
[555] | 5667 | labelAlignment.add(self._depTime)
|
---|
| 5668 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 5669 |
|
---|
| 5670 | row += 1
|
---|
[89] | 5671 |
|
---|
[996] | 5672 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 5673 | label = Gtk.Label(xstr("finish_flight_time"))
|
---|
[89] | 5674 | labelAlignment.add(label)
|
---|
[555] | 5675 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 5676 |
|
---|
[996] | 5677 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 5678 | self._flightTime = Gtk.Label()
|
---|
[89] | 5679 | self._flightTime.set_width_chars(10)
|
---|
| 5680 | self._flightTime.set_alignment(0.0, 0.5)
|
---|
| 5681 | self._flightTime.set_use_markup(True)
|
---|
| 5682 | labelAlignment.add(self._flightTime)
|
---|
[555] | 5683 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 5684 |
|
---|
| 5685 | row += 1
|
---|
[89] | 5686 |
|
---|
[996] | 5687 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 5688 | label = Gtk.Label(xstr("finish_block_time"))
|
---|
[89] | 5689 | labelAlignment.add(label)
|
---|
[555] | 5690 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 5691 |
|
---|
[996] | 5692 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 5693 | self._blockTime = Gtk.Label()
|
---|
[89] | 5694 | self._blockTime.set_width_chars(10)
|
---|
| 5695 | self._blockTime.set_alignment(0.0, 0.5)
|
---|
| 5696 | self._blockTime.set_use_markup(True)
|
---|
| 5697 | labelAlignment.add(self._blockTime)
|
---|
[555] | 5698 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 5699 |
|
---|
| 5700 | row += 1
|
---|
| 5701 |
|
---|
[996] | 5702 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 5703 | label = Gtk.Label(xstr("finish_arr_time"))
|
---|
[555] | 5704 | labelAlignment.add(label)
|
---|
| 5705 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
| 5706 |
|
---|
[996] | 5707 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 5708 | self._arrTime = Gtk.Label()
|
---|
[556] | 5709 | self._arrTime.set_width_chars(13)
|
---|
[555] | 5710 | self._arrTime.set_alignment(0.0, 0.5)
|
---|
| 5711 | self._arrTime.set_use_markup(True)
|
---|
[558] | 5712 | self._arrTime.set_tooltip_markup(xstr("finish_arr_time_tooltip"))
|
---|
[555] | 5713 | labelAlignment.add(self._arrTime)
|
---|
| 5714 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 5715 |
|
---|
| 5716 | row += 1
|
---|
[89] | 5717 |
|
---|
[996] | 5718 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 5719 | label = Gtk.Label(xstr("finish_distance"))
|
---|
[89] | 5720 | labelAlignment.add(label)
|
---|
[555] | 5721 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 5722 |
|
---|
[996] | 5723 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 5724 | self._distanceFlown = Gtk.Label()
|
---|
[89] | 5725 | self._distanceFlown.set_width_chars(10)
|
---|
| 5726 | self._distanceFlown.set_alignment(0.0, 0.5)
|
---|
| 5727 | self._distanceFlown.set_use_markup(True)
|
---|
| 5728 | labelAlignment.add(self._distanceFlown)
|
---|
[555] | 5729 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 5730 |
|
---|
| 5731 | row += 1
|
---|
[347] | 5732 |
|
---|
[996] | 5733 | labelAlignment = Gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
| 5734 | label = Gtk.Label(xstr("finish_fuel"))
|
---|
[89] | 5735 | labelAlignment.add(label)
|
---|
[555] | 5736 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[89] | 5737 |
|
---|
[996] | 5738 | labelAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 5739 | self._fuelUsed = Gtk.Label()
|
---|
[89] | 5740 | self._fuelUsed.set_width_chars(10)
|
---|
| 5741 | self._fuelUsed.set_alignment(0.0, 0.5)
|
---|
| 5742 | self._fuelUsed.set_use_markup(True)
|
---|
| 5743 | labelAlignment.add(self._fuelUsed)
|
---|
[555] | 5744 | table.attach(labelAlignment, 1, 2, row, row+1)
|
---|
| 5745 |
|
---|
| 5746 | row += 1
|
---|
[89] | 5747 |
|
---|
[996] | 5748 | labelAlignment = Gtk.Alignment(xalign = 1.0, xscale = 0.0,
|
---|
[107] | 5749 | yalign = 0.5, yscale = 0.0)
|
---|
[996] | 5750 | label = Gtk.Label(xstr("finish_type"))
|
---|
[96] | 5751 | label.set_use_underline(True)
|
---|
| 5752 | labelAlignment.add(label)
|
---|
[555] | 5753 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[96] | 5754 |
|
---|
[996] | 5755 | self._onlineFlight = Gtk.CheckButton(xstr("finish_online"))
|
---|
[96] | 5756 | self._onlineFlight.set_use_underline(True)
|
---|
[107] | 5757 | self._onlineFlight.set_tooltip_text(xstr("finish_online_tooltip"))
|
---|
[996] | 5758 | onlineFlightAlignment = Gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[96] | 5759 | onlineFlightAlignment.add(self._onlineFlight)
|
---|
[555] | 5760 | table.attach(onlineFlightAlignment, 1, 2, row, row + 1)
|
---|
| 5761 |
|
---|
| 5762 | row += 1
|
---|
[96] | 5763 |
|
---|
[996] | 5764 | labelAlignment = Gtk.Alignment(xalign = 1.0, xscale = 0.0,
|
---|
[130] | 5765 | yalign = 0.5, yscale = 0.0)
|
---|
[996] | 5766 | self._gateLabel = Gtk.Label(xstr("finish_gate"))
|
---|
[130] | 5767 | self._gateLabel.set_use_underline(True)
|
---|
| 5768 | labelAlignment.add(self._gateLabel)
|
---|
[555] | 5769 | table.attach(labelAlignment, 0, 1, row, row+1)
|
---|
[130] | 5770 |
|
---|
[996] | 5771 | self._gatesModel = Gtk.ListStore(str)
|
---|
| 5772 |
|
---|
| 5773 | self._gate = Gtk.ComboBox(model = self._gatesModel)
|
---|
| 5774 | renderer = Gtk.CellRendererText()
|
---|
[130] | 5775 | self._gate.pack_start(renderer, True)
|
---|
| 5776 | self._gate.add_attribute(renderer, "text", 0)
|
---|
| 5777 | self._gate.set_tooltip_text(xstr("finish_gate_tooltip"))
|
---|
[347] | 5778 | self._gate.connect("changed", self._gateChanged)
|
---|
[996] | 5779 | gateAlignment = Gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
[130] | 5780 | gateAlignment.add(self._gate)
|
---|
[555] | 5781 | table.attach(gateAlignment, 1, 2, row, row+1)
|
---|
[130] | 5782 | self._gateLabel.set_mnemonic_widget(self._gate)
|
---|
| 5783 |
|
---|
[208] | 5784 | self.addButton(xstr("finish_newFlight"),
|
---|
| 5785 | sensitive = True,
|
---|
| 5786 | clicked = self._newFlightClicked,
|
---|
| 5787 | tooltip = xstr("finish_newFlight_tooltip"),
|
---|
| 5788 | padding = 16)
|
---|
| 5789 |
|
---|
[107] | 5790 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[94] | 5791 |
|
---|
[769] | 5792 | self._saveHelper = saveHelper
|
---|
| 5793 | self._saveButton = saveHelper.addButton(self)
|
---|
[208] | 5794 |
|
---|
[555] | 5795 | self._tooBigTimeDifference = False
|
---|
| 5796 | self._deferredAutoSave = False
|
---|
[208] | 5797 | self._pirepSaved = False
|
---|
| 5798 | self._pirepSent = False
|
---|
[347] | 5799 |
|
---|
[151] | 5800 | self._sendButton = self.addButton(xstr("sendPIREP"), default = True,
|
---|
[107] | 5801 | sensitive = False,
|
---|
| 5802 | clicked = self._sendClicked,
|
---|
[151] | 5803 | tooltip = xstr("sendPIREP_tooltip"))
|
---|
[347] | 5804 |
|
---|
[555] | 5805 | # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 10*60.0)
|
---|
| 5806 | # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 20*60.0)
|
---|
| 5807 | # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), 0*60.0)
|
---|
| 5808 | # self._formatTime(datetime.datetime(1970, 1, 1, 0, 10), (23*60.0+50)*60.0)
|
---|
| 5809 | # self._formatTime(datetime.datetime(1970, 1, 1, 1, 0), (1*60.0+5)*60.0)
|
---|
| 5810 | # self._formatTime(datetime.datetime(1970, 1, 1, 1, 0), (0*60.0+50)*60.0)
|
---|
| 5811 | # self._formatTime(datetime.datetime(1970, 1, 1, 23, 55), (0*60.0+5)*60.0)
|
---|
| 5812 | # self._formatTime(datetime.datetime(1970, 1, 1, 23, 55), (23*60.0+45)*60.0)
|
---|
| 5813 |
|
---|
[97] | 5814 | @property
|
---|
| 5815 | def online(self):
|
---|
| 5816 | """Get whether the flight was an online flight or not."""
|
---|
| 5817 | return self._onlineFlight.get_active()
|
---|
[89] | 5818 |
|
---|
| 5819 | def activate(self):
|
---|
| 5820 | """Activate the page."""
|
---|
[555] | 5821 | self._deferredAutoSave = False
|
---|
[208] | 5822 | self._pirepSaved = False
|
---|
| 5823 | self._pirepSent = False
|
---|
| 5824 |
|
---|
[89] | 5825 | flight = self._wizard.gui._flight
|
---|
| 5826 | rating = flight.logger.getRating()
|
---|
| 5827 | if rating<0:
|
---|
| 5828 | self._flightRating.set_markup('<b><span foreground="red">NO GO</span></b>')
|
---|
| 5829 | else:
|
---|
| 5830 | self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
|
---|
| 5831 |
|
---|
| 5832 | flightLength = flight.flightTimeEnd - flight.flightTimeStart
|
---|
| 5833 | self._flightTime.set_markup("<b>%s</b>" % \
|
---|
| 5834 | (util.getTimeIntervalString(flightLength),))
|
---|
[347] | 5835 |
|
---|
[89] | 5836 | blockLength = flight.blockTimeEnd - flight.blockTimeStart
|
---|
| 5837 | self._blockTime.set_markup("<b>%s</b>" % \
|
---|
| 5838 | (util.getTimeIntervalString(blockLength),))
|
---|
| 5839 |
|
---|
| 5840 | self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
|
---|
| 5841 | (flight.flownDistance,))
|
---|
[347] | 5842 |
|
---|
[89] | 5843 | self._fuelUsed.set_markup("<b>%.0f kg</b>" % \
|
---|
[102] | 5844 | (flight.startFuel - flight.endFuel,))
|
---|
[64] | 5845 |
|
---|
[215] | 5846 | self._onlineFlight.set_active(self._wizard.loggedIn)
|
---|
[96] | 5847 |
|
---|
[130] | 5848 | self._gatesModel.clear()
|
---|
[136] | 5849 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 5850 | self._wizard.loggedIn and \
|
---|
[184] | 5851 | self._wizard.bookedFlight.arrivalICAO=="LHBP" and \
|
---|
| 5852 | not self._wizard.entranceExam:
|
---|
[619] | 5853 | occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
| 5854 | for gate in lhbpGates.gates:
|
---|
| 5855 | if gate.isAvailable(lhbpGates, occupiedGateNumbers):
|
---|
| 5856 | self._gatesModel.append([gate.number])
|
---|
[130] | 5857 | self._gateLabel.set_sensitive(True)
|
---|
| 5858 | self._gate.set_sensitive(True)
|
---|
| 5859 | self._gate.set_active(-1)
|
---|
| 5860 | else:
|
---|
| 5861 | self._gateLabel.set_sensitive(False)
|
---|
| 5862 | self._gate.set_sensitive(False)
|
---|
| 5863 |
|
---|
[564] | 5864 | self._updateTimes()
|
---|
[555] | 5865 |
|
---|
| 5866 | def updateButtons(self):
|
---|
[130] | 5867 | """Update the sensitivity state of the buttons."""
|
---|
[555] | 5868 | gui = self._wizard.gui
|
---|
[607] | 5869 | faultsExplained = gui.faultsFullyExplained
|
---|
[1034] | 5870 | timesCorrect = not self._tooBigTimeDifference or \
|
---|
[607] | 5871 | gui.hasComments or gui.hasDelayCode
|
---|
[625] | 5872 | sensitive = gui.flight is not None and \
|
---|
| 5873 | gui.flight.stage==const.STAGE_END and \
|
---|
[130] | 5874 | (self._gatesModel.get_iter_first() is None or
|
---|
[555] | 5875 | self._gate.get_active()>=0) and \
|
---|
[607] | 5876 | faultsExplained and timesCorrect
|
---|
| 5877 |
|
---|
| 5878 | self._updateHelp(faultsExplained, timesCorrect)
|
---|
[347] | 5879 |
|
---|
[393] | 5880 | wasSensitive = self._saveButton.get_sensitive()
|
---|
| 5881 |
|
---|
[555] | 5882 | if gui.config.pirepAutoSave and sensitive and not wasSensitive:
|
---|
| 5883 | if gui.isWizardActive():
|
---|
[777] | 5884 | self._saveHelper.autoSavePIREP(self)
|
---|
[555] | 5885 | else:
|
---|
| 5886 | self._deferredAutoSave = True
|
---|
| 5887 |
|
---|
| 5888 | if not sensitive:
|
---|
| 5889 | self._deferredAutoSave = False
|
---|
[393] | 5890 |
|
---|
[151] | 5891 | self._saveButton.set_sensitive(sensitive)
|
---|
[184] | 5892 | self._sendButton.set_sensitive(sensitive and
|
---|
| 5893 | self._wizard.bookedFlight.id is not None)
|
---|
[130] | 5894 |
|
---|
[555] | 5895 | def grabDefault(self):
|
---|
| 5896 | """If the page has a default button, make it the default one."""
|
---|
| 5897 | super(FinishPage, self).grabDefault()
|
---|
| 5898 | if self._deferredAutoSave:
|
---|
[777] | 5899 | self._saveHelper.autoSavePIREP(self)
|
---|
[555] | 5900 | self._deferredAutoSave = False
|
---|
| 5901 |
|
---|
[769] | 5902 | def setPIREPSaved(self):
|
---|
| 5903 | """Mark the PIREP as saved."""
|
---|
| 5904 | self._pirepSaved = True
|
---|
[555] | 5905 |
|
---|
| 5906 | def _backClicked(self, button):
|
---|
| 5907 | """Called when the Back button is pressed."""
|
---|
| 5908 | self.goBack()
|
---|
| 5909 |
|
---|
[130] | 5910 | def _gateChanged(self, comboBox):
|
---|
| 5911 | """Called when the arrival gate has changed."""
|
---|
[555] | 5912 | self.updateButtons()
|
---|
[97] | 5913 |
|
---|
[208] | 5914 | def _newFlightClicked(self, button):
|
---|
| 5915 | """Called when the new flight button is clicked."""
|
---|
| 5916 | gui = self._wizard.gui
|
---|
| 5917 | if not self._pirepSent and not self._pirepSaved:
|
---|
[996] | 5918 | dialog = Gtk.MessageDialog(parent = gui.mainWindow,
|
---|
[999] | 5919 | type = Gtk.MessageType.QUESTION,
|
---|
[208] | 5920 | message_format = xstr("finish_newFlight_question"))
|
---|
| 5921 |
|
---|
[999] | 5922 | dialog.add_button(xstr("button_no"), Gtk.ResponseType.NO)
|
---|
| 5923 | dialog.add_button(xstr("button_yes"), Gtk.ResponseType.YES)
|
---|
[208] | 5924 |
|
---|
| 5925 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 5926 | result = dialog.run()
|
---|
| 5927 | dialog.hide()
|
---|
[999] | 5928 | if result!=Gtk.ResponseType.YES:
|
---|
[208] | 5929 | return
|
---|
[347] | 5930 |
|
---|
[208] | 5931 | gui.reset()
|
---|
| 5932 |
|
---|
[97] | 5933 | def _sendClicked(self, button):
|
---|
| 5934 | """Called when the Send button is clicked."""
|
---|
[262] | 5935 | pirep = PIREP(self._wizard.gui.flight)
|
---|
[151] | 5936 | self._wizard.gui.sendPIREP(pirep,
|
---|
| 5937 | callback = self._handlePIREPSent)
|
---|
[97] | 5938 |
|
---|
| 5939 | def _handlePIREPSent(self, returned, result):
|
---|
| 5940 | """Callback for the PIREP sending result."""
|
---|
[208] | 5941 | self._pirepSent = returned and result.success
|
---|
[184] | 5942 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 5943 | self._wizard.loggedIn and not self._wizard.entranceExam and \
|
---|
[184] | 5944 | returned and result.success:
|
---|
[130] | 5945 | bookedFlight = self._wizard.bookedFlight
|
---|
| 5946 | if bookedFlight.arrivalICAO=="LHBP":
|
---|
[347] | 5947 | iter = self._gate.get_active_iter()
|
---|
[130] | 5948 | gateNumber = None if iter is None \
|
---|
| 5949 | else self._gatesModel.get_value(iter, 0)
|
---|
[347] | 5950 |
|
---|
[130] | 5951 | status = const.PLANE_PARKING if gateNumber is None \
|
---|
| 5952 | else const.PLANE_HOME
|
---|
| 5953 | else:
|
---|
| 5954 | gateNumber = None
|
---|
| 5955 | status = const.PLANE_AWAY
|
---|
| 5956 |
|
---|
| 5957 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 5958 | bookedFlight.tailNumber,
|
---|
| 5959 | status, gateNumber = gateNumber)
|
---|
| 5960 |
|
---|
| 5961 | def _planeUpdated(self, success):
|
---|
| 5962 | """Callback for the plane updating."""
|
---|
| 5963 | pass
|
---|
[347] | 5964 |
|
---|
[1004] | 5965 | def _formatTime(self, scheduledTime, realTimestamp, warningError):
|
---|
[555] | 5966 | """Format the departure or arrival time based on the given data as a
|
---|
[564] | 5967 | markup for a label."""
|
---|
[1004] | 5968 | (warning, error) = warningError
|
---|
[555] | 5969 | realTime = time.gmtime(realTimestamp)
|
---|
| 5970 |
|
---|
[564] | 5971 | if warning:
|
---|
| 5972 | colour = "red" if error else "orange"
|
---|
[555] | 5973 | markupBegin = '<span foreground="%s">' % (colour,)
|
---|
| 5974 | markupEnd = '</span>'
|
---|
| 5975 | else:
|
---|
| 5976 | markupBegin = markupEnd = ""
|
---|
| 5977 |
|
---|
| 5978 | markup = "<b>%s%02d:%02d [%02d:%02d]%s</b>" % \
|
---|
| 5979 | (markupBegin,
|
---|
| 5980 | realTime.tm_hour, realTime.tm_min,
|
---|
| 5981 | scheduledTime.hour, scheduledTime.minute,
|
---|
| 5982 | markupEnd)
|
---|
| 5983 |
|
---|
[564] | 5984 | return markup
|
---|
| 5985 |
|
---|
| 5986 | def _updateTimes(self):
|
---|
| 5987 | """Format the flight times and the help text according to the flight
|
---|
| 5988 | type.
|
---|
| 5989 |
|
---|
| 5990 | The buttons are also updated.
|
---|
| 5991 | """
|
---|
| 5992 | flight = self._wizard.gui._flight
|
---|
| 5993 | bookedFlight = flight.bookedFlight
|
---|
| 5994 |
|
---|
| 5995 | (departureWarning, departureError) = flight.blockTimeStartWrong
|
---|
| 5996 | (arrivalWarning, arrivalError) = flight.blockTimeEndWrong
|
---|
| 5997 |
|
---|
[1034] | 5998 | if bookedFlight.flightType==const.FLIGHTTYPE_VIP:
|
---|
[564] | 5999 | departureError = arrivalError = False
|
---|
| 6000 |
|
---|
[1034] | 6001 | self._tooBigTimeDifference = departureError and arrivalError
|
---|
[564] | 6002 |
|
---|
| 6003 | self._depTime.set_markup(self._formatTime(bookedFlight.departureTime,
|
---|
| 6004 | flight.blockTimeStart,
|
---|
| 6005 | (departureWarning,
|
---|
| 6006 | departureError)))
|
---|
| 6007 |
|
---|
| 6008 | self._arrTime.set_markup(self._formatTime(bookedFlight.arrivalTime,
|
---|
| 6009 | flight.blockTimeEnd,
|
---|
| 6010 | (arrivalWarning,
|
---|
| 6011 | arrivalError)))
|
---|
| 6012 |
|
---|
| 6013 | self.updateButtons()
|
---|
[555] | 6014 |
|
---|
[607] | 6015 | def _updateHelp(self, faultsExplained, timesCorrect):
|
---|
| 6016 | """Update the help text according to the actual situation."""
|
---|
| 6017 | if not faultsExplained:
|
---|
| 6018 | self.setHelp(xstr("finish_help") + xstr("finish_help_faults"))
|
---|
| 6019 | elif not timesCorrect:
|
---|
| 6020 | self.setHelp(xstr("finish_help") + xstr("finish_help_wrongtime"))
|
---|
| 6021 | else:
|
---|
| 6022 | self.setHelp(xstr("finish_help") + xstr("finish_help_goodtime"))
|
---|
| 6023 |
|
---|
| 6024 |
|
---|
[64] | 6025 | #-----------------------------------------------------------------------------
|
---|
| 6026 |
|
---|
[769] | 6027 | class CheckFlightFinishPage(Page):
|
---|
| 6028 | """Finish page for a check flight."""
|
---|
| 6029 | def __init__(self, wizard, saveHelper):
|
---|
| 6030 | """Construct the check flight finish page."""
|
---|
| 6031 | super(CheckFlightFinishPage, self).__init__(wizard,
|
---|
| 6032 | "chkfinish",
|
---|
| 6033 | xstr("chkfinish_title"),
|
---|
| 6034 | "")
|
---|
| 6035 |
|
---|
[996] | 6036 | alignment = Gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[769] | 6037 | xscale = 1.0, yscale = 1.0)
|
---|
[996] | 6038 | self._label = Gtk.Label()
|
---|
[769] | 6039 | alignment.add(self._label)
|
---|
| 6040 |
|
---|
| 6041 | self.setMainWidget(alignment)
|
---|
| 6042 |
|
---|
| 6043 | self._saveHelper = saveHelper
|
---|
| 6044 | self._saveButton = saveHelper.addButton(self)
|
---|
| 6045 |
|
---|
| 6046 | self._button = self.addNextButton(sensitive = False,
|
---|
| 6047 | clicked = self._forwardClicked)
|
---|
| 6048 |
|
---|
| 6049 | def activate(self):
|
---|
| 6050 | """Activate the page."""
|
---|
| 6051 | wizard = self._wizard
|
---|
| 6052 | loginResult = wizard.loginResult
|
---|
| 6053 | gui = wizard.gui
|
---|
| 6054 | rating = gui.flight.logger.getRating()
|
---|
| 6055 |
|
---|
| 6056 | if rating>=0:
|
---|
| 6057 | loginResult.checkFlightStatus = True
|
---|
| 6058 |
|
---|
| 6059 | firstOfficer = \
|
---|
| 6060 | loginResult.entryExamPassed and loginResult.checkFlightStatus
|
---|
| 6061 |
|
---|
| 6062 | if firstOfficer:
|
---|
| 6063 | loginResult.rank = "FO"
|
---|
| 6064 |
|
---|
| 6065 | if rating<0:
|
---|
| 6066 | mainMessage = xstr("chkfinish_failed")
|
---|
| 6067 | else:
|
---|
| 6068 | mainMessage = xstr("chkfinish_passed_begin")
|
---|
| 6069 | if firstOfficer:
|
---|
| 6070 | mainMessage += xstr("chkfinish_passed_fo")
|
---|
| 6071 | mainMessage += xstr("chkfinish_passed_end")
|
---|
| 6072 |
|
---|
| 6073 | if firstOfficer:
|
---|
| 6074 | nextMessage = xstr("chkfinish_next")
|
---|
| 6075 | else:
|
---|
| 6076 | nextMessage = xstr("chkfinish_next_student_begin")
|
---|
| 6077 | if not loginResult.entryExamPassed and \
|
---|
| 6078 | not loginResult.checkFlightStatus:
|
---|
| 6079 | nextMessage += xstr("chkfinish_next_student_nothing")
|
---|
| 6080 | elif loginResult.entryExamPassed and \
|
---|
| 6081 | not loginResult.checkFlightStatus:
|
---|
| 6082 | nextMessage += xstr("chkfinish_next_student_no_flight")
|
---|
| 6083 | elif not loginResult.entryExamPassed and \
|
---|
| 6084 | loginResult.checkFlightStatus:
|
---|
| 6085 | nextMessage += xstr("chkfinish_next_student_no_exam")
|
---|
| 6086 |
|
---|
| 6087 | self._label.set_text(mainMessage +
|
---|
| 6088 | xstr("chkfinish_savepirep") +
|
---|
| 6089 | nextMessage)
|
---|
| 6090 | self._label.set_use_markup(True)
|
---|
| 6091 | self._label.set_alignment(0.5, 0.0)
|
---|
| 6092 |
|
---|
| 6093 | self._saveButton.set_sensitive(True)
|
---|
| 6094 | self._button.set_sensitive(True)
|
---|
| 6095 |
|
---|
| 6096 | def _forwardClicked(self, button):
|
---|
| 6097 | """Jump to the student page if there are some tasks to do,
|
---|
| 6098 | or to the flight selection page, if the pilot is allowed to perform
|
---|
| 6099 | MAVA flights."""
|
---|
| 6100 | wizard = self._wizard
|
---|
| 6101 | gui = wizard.gui
|
---|
| 6102 |
|
---|
| 6103 | loginResult = wizard.loginResult
|
---|
| 6104 | if loginResult.checkFlightStatus:
|
---|
| 6105 | gui.beginBusy(xstr("chkfinish_updateweb_busy"))
|
---|
| 6106 | gui.webHandler.setCheckFlightPassed(self._checkFlightPassedSetCallback,
|
---|
| 6107 | wizard.checkFlightAircraftType)
|
---|
| 6108 | else:
|
---|
| 6109 | self._resetGUI()
|
---|
| 6110 |
|
---|
| 6111 | def _checkFlightPassedSetCallback(self, returned, result):
|
---|
| 6112 | """Called when the check flight status has been set."""
|
---|
[995] | 6113 | GObject.idle_add(self._checkFlightPassedSet, returned, result)
|
---|
[769] | 6114 |
|
---|
| 6115 | def _checkFlightPassedSet(self, returned, result):
|
---|
| 6116 | """Handle the result of an attempt to set the check flight status."""
|
---|
| 6117 | gui = self._wizard.gui
|
---|
| 6118 |
|
---|
| 6119 | gui.endBusy()
|
---|
| 6120 |
|
---|
| 6121 | if returned:
|
---|
| 6122 | self._resetGUI()
|
---|
| 6123 | else:
|
---|
[996] | 6124 | dialog = Gtk.MessageDialog(parent = gui.mainWindow,
|
---|
[999] | 6125 | type = Gtk.MessageType.ERROR,
|
---|
[769] | 6126 | message_format =
|
---|
| 6127 | xstr("chkfinish_passedset_failed"))
|
---|
| 6128 | dialog.set_title(WINDOW_TITLE_BASE + " - " +
|
---|
| 6129 | xstr("chkfinish_passedset_failed_title"))
|
---|
| 6130 | dialog.format_secondary_markup(xstr("chkfinish_passedset_failed_secondary"))
|
---|
| 6131 |
|
---|
| 6132 | dialog.add_button(xstr("button_ok"), 0)
|
---|
| 6133 |
|
---|
| 6134 | dialog.run()
|
---|
| 6135 | dialog.hide()
|
---|
| 6136 |
|
---|
| 6137 | def _resetGUI(self):
|
---|
| 6138 | """Reset the GUI."""
|
---|
| 6139 | gui = self._wizard.gui
|
---|
| 6140 | gui.reset()
|
---|
| 6141 |
|
---|
| 6142 | #-----------------------------------------------------------------------------
|
---|
| 6143 |
|
---|
[996] | 6144 | class Wizard(Gtk.VBox):
|
---|
[42] | 6145 | """The flight wizard."""
|
---|
| 6146 | def __init__(self, gui):
|
---|
| 6147 | """Construct the wizard."""
|
---|
| 6148 | super(Wizard, self).__init__()
|
---|
| 6149 |
|
---|
| 6150 | self.gui = gui
|
---|
| 6151 |
|
---|
| 6152 | self._pages = []
|
---|
| 6153 | self._currentPage = None
|
---|
[184] | 6154 |
|
---|
| 6155 | self._loginPage = LoginPage(self)
|
---|
| 6156 | self._pages.append(self._loginPage)
|
---|
[821] | 6157 | self._flightSelectionPage = FlightSelectionPage(self)
|
---|
| 6158 | self._pages.append(self._flightSelectionPage)
|
---|
[51] | 6159 | self._pages.append(GateSelectionPage(self))
|
---|
[753] | 6160 | self._pages.append(RegisterPage(self))
|
---|
[769] | 6161 | self._studentPage = StudentPage(self)
|
---|
| 6162 | self._pages.append(self._studentPage)
|
---|
[51] | 6163 | self._pages.append(ConnectPage(self))
|
---|
[347] | 6164 | self._payloadPage = PayloadPage(self)
|
---|
[84] | 6165 | self._pages.append(self._payloadPage)
|
---|
[117] | 6166 | self._payloadIndex = len(self._pages)
|
---|
[61] | 6167 | self._pages.append(TimePage(self))
|
---|
[84] | 6168 | self._routePage = RoutePage(self)
|
---|
| 6169 | self._pages.append(self._routePage)
|
---|
[687] | 6170 | self._simBriefSetupPage = SimBriefSetupPage(self)
|
---|
| 6171 | self._pages.append(self._simBriefSetupPage)
|
---|
| 6172 | self._simBriefingPage = SimBriefingPage(self)
|
---|
| 6173 | self._pages.append(self._simBriefingPage)
|
---|
| 6174 | self._pages.append(FuelPage(self))
|
---|
[97] | 6175 | self._departureBriefingPage = BriefingPage(self, True)
|
---|
| 6176 | self._pages.append(self._departureBriefingPage)
|
---|
| 6177 | self._arrivalBriefingPage = BriefingPage(self, False)
|
---|
| 6178 | self._pages.append(self._arrivalBriefingPage)
|
---|
[117] | 6179 | self._arrivalBriefingIndex = len(self._pages)
|
---|
[347] | 6180 | self._takeoffPage = TakeoffPage(self)
|
---|
[84] | 6181 | self._pages.append(self._takeoffPage)
|
---|
[383] | 6182 | self._cruisePage = CruisePage(self)
|
---|
| 6183 | self._pages.append(self._cruisePage)
|
---|
[347] | 6184 | self._landingPage = LandingPage(self)
|
---|
[86] | 6185 | self._pages.append(self._landingPage)
|
---|
[769] | 6186 |
|
---|
| 6187 | pirepSaveHelper = PIREPSaveHelper(self)
|
---|
| 6188 |
|
---|
| 6189 | self._finishPage = FinishPage(self, pirepSaveHelper)
|
---|
[97] | 6190 | self._pages.append(self._finishPage)
|
---|
[769] | 6191 | self._pages.append(CheckFlightFinishPage(self, pirepSaveHelper))
|
---|
[201] | 6192 |
|
---|
[556] | 6193 | self._requestedWidth = None
|
---|
| 6194 | self._requestedHeight = None
|
---|
| 6195 |
|
---|
| 6196 | self.connect("size-allocate", self._sizeAllocate)
|
---|
| 6197 |
|
---|
| 6198 | for page in self._pages:
|
---|
| 6199 | page.show_all()
|
---|
| 6200 | page.setStyle()
|
---|
| 6201 |
|
---|
| 6202 | self._initialize()
|
---|
[992] | 6203 | self._allocateSize()
|
---|
[556] | 6204 |
|
---|
| 6205 | def _sizeAllocate(self, widget, allocation):
|
---|
| 6206 | if self._requestedWidth is not None and \
|
---|
| 6207 | self._requestedHeight is not None:
|
---|
| 6208 | return
|
---|
| 6209 |
|
---|
[992] | 6210 | (maxWidth, maxHeight) = self._allocateSize()
|
---|
| 6211 |
|
---|
| 6212 | self._requestedWidth = maxWidth
|
---|
| 6213 | self._requestedHeight = maxHeight
|
---|
| 6214 |
|
---|
| 6215 | def _allocateSize(self):
|
---|
| 6216 | """Perform the real size allocation."""
|
---|
| 6217 |
|
---|
[556] | 6218 | if self._currentPage is not None:
|
---|
| 6219 | self.remove(self._pages[self._currentPage])
|
---|
| 6220 |
|
---|
[51] | 6221 | maxWidth = 0
|
---|
| 6222 | maxHeight = 0
|
---|
| 6223 | for page in self._pages:
|
---|
[556] | 6224 | self.add(page)
|
---|
| 6225 | self.show_all()
|
---|
[51] | 6226 | pageSizeRequest = page.size_request()
|
---|
[994] | 6227 | width = pageSizeRequest.width
|
---|
| 6228 | height = pageSizeRequest.height
|
---|
[51] | 6229 | maxWidth = max(maxWidth, width)
|
---|
| 6230 | maxHeight = max(maxHeight, height)
|
---|
[556] | 6231 | self.remove(page)
|
---|
| 6232 |
|
---|
| 6233 | if self._currentPage is not None:
|
---|
| 6234 | self.add(self._pages[self._currentPage])
|
---|
| 6235 |
|
---|
[51] | 6236 | self.set_size_request(maxWidth, maxHeight)
|
---|
| 6237 |
|
---|
[992] | 6238 | return (maxWidth, maxHeight)
|
---|
| 6239 |
|
---|
[184] | 6240 | @property
|
---|
[215] | 6241 | def pilotID(self):
|
---|
| 6242 | """Get the pilot ID, if given."""
|
---|
| 6243 | return self._loginPage.pilotID
|
---|
| 6244 |
|
---|
| 6245 | @property
|
---|
[184] | 6246 | def entranceExam(self):
|
---|
| 6247 | """Get whether an entrance exam is about to be taken."""
|
---|
[760] | 6248 | return self._loginResult is not None and self._loginResult.rank=="STU"
|
---|
[215] | 6249 |
|
---|
| 6250 | @property
|
---|
| 6251 | def loggedIn(self):
|
---|
| 6252 | """Indicate if there was a successful login."""
|
---|
| 6253 | return self._loginResult is not None
|
---|
[347] | 6254 |
|
---|
[48] | 6255 | @property
|
---|
| 6256 | def loginResult(self):
|
---|
| 6257 | """Get the login result."""
|
---|
| 6258 | return self._loginResult
|
---|
| 6259 |
|
---|
[769] | 6260 | @property
|
---|
| 6261 | def checkFlightAircraftType(self):
|
---|
| 6262 | """Get the type of the aircraft used to perform the check flight."""
|
---|
| 6263 | return self._studentPage.aircraftType
|
---|
| 6264 |
|
---|
[692] | 6265 | def setCurrentPage(self, index, finalize = False, fromPageShift = None):
|
---|
| 6266 | """Set the current page to the one with the given index.
|
---|
| 6267 |
|
---|
| 6268 | @param fromPageShift if given, the relative index of one of the
|
---|
| 6269 | previous pages that should be used as the from-page of the next
|
---|
| 6270 | page. E.g. if fromPageShift is 1, the previous page will be the
|
---|
| 6271 | from-page."""
|
---|
[42] | 6272 | assert index < len(self._pages)
|
---|
[70] | 6273 |
|
---|
| 6274 | fromPage = self._currentPage
|
---|
| 6275 | if fromPage is not None:
|
---|
| 6276 | page = self._pages[fromPage]
|
---|
[94] | 6277 | if finalize and not page._completed:
|
---|
| 6278 | page.complete()
|
---|
[1075] | 6279 | page.prepareHide()
|
---|
[70] | 6280 | self.remove(page)
|
---|
[692] | 6281 | if fromPageShift is not None:
|
---|
| 6282 | fromPage -= fromPageShift
|
---|
[42] | 6283 |
|
---|
| 6284 | self._currentPage = index
|
---|
[70] | 6285 | page = self._pages[index]
|
---|
| 6286 | self.add(page)
|
---|
| 6287 | if page._fromPage is None:
|
---|
| 6288 | page._fromPage = fromPage
|
---|
[94] | 6289 | page.initialize()
|
---|
[1075] | 6290 | page.prepareShow()
|
---|
[42] | 6291 | self.show_all()
|
---|
[72] | 6292 | if fromPage is not None:
|
---|
| 6293 | self.grabDefault()
|
---|
[42] | 6294 |
|
---|
[84] | 6295 | @property
|
---|
[97] | 6296 | def bookedFlight(self):
|
---|
| 6297 | """Get the booked flight selected."""
|
---|
| 6298 | return self._bookedFlight
|
---|
| 6299 |
|
---|
| 6300 | @property
|
---|
[1033] | 6301 | def numCockpitCrew(self):
|
---|
| 6302 | """Get the number of cockpit crew members."""
|
---|
| 6303 | return self._payloadPage.numCockpitCrew
|
---|
| 6304 |
|
---|
| 6305 | @property
|
---|
| 6306 | def numCabinCrew(self):
|
---|
| 6307 | """Get the number of cabin crew members."""
|
---|
| 6308 | return self._payloadPage.numCabinCrew
|
---|
[303] | 6309 |
|
---|
| 6310 | @property
|
---|
| 6311 | def numPassengers(self):
|
---|
| 6312 | """Get the number of passengers."""
|
---|
| 6313 | return self._payloadPage.numPassengers
|
---|
| 6314 |
|
---|
| 6315 | @property
|
---|
[1033] | 6316 | def numChildren(self):
|
---|
| 6317 | """Get the number of child passengers."""
|
---|
| 6318 | return self._payloadPage.numChildren
|
---|
| 6319 |
|
---|
| 6320 | @property
|
---|
| 6321 | def numInfants(self):
|
---|
| 6322 | """Get the number of infant passengers."""
|
---|
| 6323 | return self._payloadPage.numInfants
|
---|
| 6324 |
|
---|
| 6325 | @property
|
---|
[303] | 6326 | def bagWeight(self):
|
---|
| 6327 | """Get the baggage weight."""
|
---|
| 6328 | return self._payloadPage.bagWeight
|
---|
| 6329 |
|
---|
| 6330 | @property
|
---|
[97] | 6331 | def cargoWeight(self):
|
---|
[303] | 6332 | """Get the cargo weight."""
|
---|
[97] | 6333 | return self._payloadPage.cargoWeight
|
---|
| 6334 |
|
---|
| 6335 | @property
|
---|
[303] | 6336 | def mailWeight(self):
|
---|
| 6337 | """Get the mail weight."""
|
---|
| 6338 | return self._payloadPage.mailWeight
|
---|
| 6339 |
|
---|
| 6340 | @property
|
---|
[84] | 6341 | def zfw(self):
|
---|
| 6342 | """Get the calculated ZFW value."""
|
---|
| 6343 | return 0 if self._bookedFlight is None \
|
---|
| 6344 | else self._payloadPage.calculateZFW()
|
---|
| 6345 |
|
---|
| 6346 | @property
|
---|
[383] | 6347 | def filedCruiseLevel(self):
|
---|
| 6348 | """Get the filed cruise level."""
|
---|
| 6349 | return self._routePage.filedCruiseLevel
|
---|
| 6350 |
|
---|
| 6351 | @property
|
---|
[97] | 6352 | def filedCruiseAltitude(self):
|
---|
| 6353 | """Get the filed cruise altitude."""
|
---|
| 6354 | return self._routePage.filedCruiseLevel * 100
|
---|
| 6355 |
|
---|
| 6356 | @property
|
---|
[84] | 6357 | def cruiseAltitude(self):
|
---|
| 6358 | """Get the cruise altitude."""
|
---|
[383] | 6359 | level = self._cruisePage.cruiseLevel if self._cruisePage.activated \
|
---|
| 6360 | else self._routePage.filedCruiseLevel
|
---|
| 6361 | return level * 100
|
---|
| 6362 |
|
---|
| 6363 | @property
|
---|
| 6364 | def loggableCruiseAltitude(self):
|
---|
| 6365 | """Get the cruise altitude that can be logged."""
|
---|
| 6366 | if self._cruisePage.activated:
|
---|
| 6367 | return self._cruisePage.loggableCruiseLevel * 100
|
---|
| 6368 | else:
|
---|
| 6369 | return 0
|
---|
[84] | 6370 |
|
---|
| 6371 | @property
|
---|
[97] | 6372 | def route(self):
|
---|
| 6373 | """Get the route."""
|
---|
| 6374 | return self._routePage.route
|
---|
| 6375 |
|
---|
| 6376 | @property
|
---|
[687] | 6377 | def alternate(self):
|
---|
| 6378 | """Get the ICAO code of the alternate airport."""
|
---|
| 6379 | return self._routePage.alternate
|
---|
| 6380 |
|
---|
| 6381 | @property
|
---|
[97] | 6382 | def departureMETAR(self):
|
---|
| 6383 | """Get the METAR of the departure airport."""
|
---|
| 6384 | return self._departureBriefingPage.metar
|
---|
| 6385 |
|
---|
| 6386 | @property
|
---|
| 6387 | def arrivalMETAR(self):
|
---|
| 6388 | """Get the METAR of the arrival airport."""
|
---|
| 6389 | return self._arrivalBriefingPage.metar
|
---|
| 6390 |
|
---|
| 6391 | @property
|
---|
| 6392 | def departureRunway(self):
|
---|
| 6393 | """Get the departure runway."""
|
---|
| 6394 | return self._takeoffPage.runway
|
---|
| 6395 |
|
---|
| 6396 | @property
|
---|
| 6397 | def sid(self):
|
---|
| 6398 | """Get the SID."""
|
---|
| 6399 | return self._takeoffPage.sid
|
---|
| 6400 |
|
---|
| 6401 | @property
|
---|
[84] | 6402 | def v1(self):
|
---|
| 6403 | """Get the V1 speed."""
|
---|
[86] | 6404 | return self._takeoffPage.v1
|
---|
[84] | 6405 |
|
---|
| 6406 | @property
|
---|
| 6407 | def vr(self):
|
---|
| 6408 | """Get the Vr speed."""
|
---|
[86] | 6409 | return self._takeoffPage.vr
|
---|
[84] | 6410 |
|
---|
| 6411 | @property
|
---|
| 6412 | def v2(self):
|
---|
| 6413 | """Get the V2 speed."""
|
---|
[86] | 6414 | return self._takeoffPage.v2
|
---|
| 6415 |
|
---|
| 6416 | @property
|
---|
[384] | 6417 | def derate(self):
|
---|
| 6418 | """Get the derate value."""
|
---|
| 6419 | return self._takeoffPage.derate
|
---|
| 6420 |
|
---|
| 6421 | @property
|
---|
[391] | 6422 | def takeoffAntiIceOn(self):
|
---|
| 6423 | """Get whether the anti-ice system was on during take-off."""
|
---|
| 6424 | return self._takeoffPage.antiIceOn
|
---|
| 6425 |
|
---|
| 6426 | @takeoffAntiIceOn.setter
|
---|
| 6427 | def takeoffAntiIceOn(self, value):
|
---|
| 6428 | """Set anti-ice on indicator."""
|
---|
| 6429 | self._takeoffPage.antiIceOn = value
|
---|
| 6430 |
|
---|
| 6431 | @property
|
---|
[349] | 6432 | def rtoIndicated(self):
|
---|
| 6433 | """Get whether the pilot has indicated that an RTO has occured."""
|
---|
| 6434 | return self._takeoffPage.rtoIndicated
|
---|
| 6435 |
|
---|
| 6436 | @property
|
---|
[97] | 6437 | def arrivalRunway(self):
|
---|
| 6438 | """Get the arrival runway."""
|
---|
| 6439 | return self._landingPage.runway
|
---|
| 6440 |
|
---|
| 6441 | @property
|
---|
| 6442 | def star(self):
|
---|
| 6443 | """Get the STAR."""
|
---|
| 6444 | return self._landingPage.star
|
---|
| 6445 |
|
---|
| 6446 | @property
|
---|
| 6447 | def transition(self):
|
---|
| 6448 | """Get the transition."""
|
---|
| 6449 | return self._landingPage.transition
|
---|
| 6450 |
|
---|
| 6451 | @property
|
---|
| 6452 | def approachType(self):
|
---|
| 6453 | """Get the approach type."""
|
---|
| 6454 | return self._landingPage.approachType
|
---|
| 6455 |
|
---|
| 6456 | @property
|
---|
[86] | 6457 | def vref(self):
|
---|
| 6458 | """Get the Vref speed."""
|
---|
| 6459 | return self._landingPage.vref
|
---|
[84] | 6460 |
|
---|
[97] | 6461 | @property
|
---|
[391] | 6462 | def landingAntiIceOn(self):
|
---|
| 6463 | """Get whether the anti-ice system was on during landing."""
|
---|
| 6464 | return self._landingPage.antiIceOn
|
---|
| 6465 |
|
---|
| 6466 | @landingAntiIceOn.setter
|
---|
| 6467 | def landingAntiIceOn(self, value):
|
---|
| 6468 | """Set anti-ice on indicator."""
|
---|
| 6469 | self._landingPage.antiIceOn = value
|
---|
| 6470 |
|
---|
| 6471 | @property
|
---|
[97] | 6472 | def flightType(self):
|
---|
| 6473 | """Get the flight type."""
|
---|
| 6474 | return self._finishPage.flightType
|
---|
| 6475 |
|
---|
| 6476 | @property
|
---|
| 6477 | def online(self):
|
---|
| 6478 | """Get whether the flight was online or not."""
|
---|
| 6479 | return self._finishPage.online
|
---|
| 6480 |
|
---|
[687] | 6481 | @property
|
---|
| 6482 | def usingSimBrief(self):
|
---|
| 6483 | """Indicate if we are using a SimBrief briefing or not."""
|
---|
| 6484 | return self._usingSimBrief
|
---|
| 6485 |
|
---|
| 6486 | @usingSimBrief.setter
|
---|
| 6487 | def usingSimBrief(self, x):
|
---|
| 6488 | """Set whether we are using a SimBrief briefing or not."""
|
---|
| 6489 | self._usingSimBrief = x
|
---|
| 6490 |
|
---|
[70] | 6491 | def nextPage(self, finalize = True):
|
---|
[42] | 6492 | """Go to the next page."""
|
---|
[754] | 6493 | nextPageID = self._pages[self._currentPage].nextPageID
|
---|
| 6494 | self.jumpPage(1 if nextPageID is None else nextPageID, finalize)
|
---|
| 6495 |
|
---|
| 6496 | def jumpPage(self, countOrID, finalize = True, fromPageShift = None):
|
---|
[51] | 6497 | """Go to the page which is 'count' pages after the current one."""
|
---|
[754] | 6498 | if isinstance(countOrID, str):
|
---|
| 6499 | targetIndex = self._getIndexOf(countOrID)
|
---|
| 6500 | else:
|
---|
| 6501 | targetIndex = self._currentPage + countOrID
|
---|
| 6502 | self.setCurrentPage(targetIndex,
|
---|
[692] | 6503 | finalize = finalize, fromPageShift = fromPageShift)
|
---|
[46] | 6504 |
|
---|
| 6505 | def grabDefault(self):
|
---|
| 6506 | """Make the default button of the current page the default."""
|
---|
| 6507 | self._pages[self._currentPage].grabDefault()
|
---|
[51] | 6508 |
|
---|
[59] | 6509 | def connected(self, fsType, descriptor):
|
---|
| 6510 | """Called when the connection could be made to the simulator."""
|
---|
| 6511 | self.nextPage()
|
---|
| 6512 |
|
---|
[208] | 6513 | def reset(self, loginResult):
|
---|
[91] | 6514 | """Resets the wizard to go back to the login page."""
|
---|
[208] | 6515 | self._initialize(keepLoginResult = loginResult is None,
|
---|
| 6516 | loginResult = loginResult)
|
---|
[59] | 6517 |
|
---|
[84] | 6518 | def setStage(self, stage):
|
---|
| 6519 | """Set the flight stage to the given one."""
|
---|
[383] | 6520 | if stage!=const.STAGE_END:
|
---|
| 6521 | self._cruisePage.setLoggable(Flight.canLogCruiseAltitude(stage))
|
---|
| 6522 |
|
---|
[84] | 6523 | if stage==const.STAGE_TAKEOFF:
|
---|
[101] | 6524 | self._takeoffPage.allowForward()
|
---|
[106] | 6525 | elif stage==const.STAGE_LANDING:
|
---|
| 6526 | if not self._arrivalBriefingPage.metarEdited:
|
---|
[919] | 6527 | print("Downloading arrival METAR again")
|
---|
[106] | 6528 | self.gui.webHandler.getMETARs(self._arrivalMETARCallback,
|
---|
| 6529 | [self._bookedFlight.arrivalICAO])
|
---|
[347] | 6530 |
|
---|
[88] | 6531 | elif stage==const.STAGE_END:
|
---|
[275] | 6532 | for page in self._pages:
|
---|
| 6533 | page.flightEnded()
|
---|
[84] | 6534 |
|
---|
[208] | 6535 | def _initialize(self, keepLoginResult = False, loginResult = None):
|
---|
[59] | 6536 | """Initialize the wizard."""
|
---|
[208] | 6537 | if not keepLoginResult:
|
---|
| 6538 | self._loginResult = loginResult
|
---|
| 6539 |
|
---|
| 6540 | self._loginCallback = None
|
---|
| 6541 |
|
---|
[59] | 6542 | self._fleet = None
|
---|
| 6543 | self._fleetCallback = None
|
---|
[347] | 6544 |
|
---|
[59] | 6545 | self._bookedFlight = None
|
---|
| 6546 | self._departureGate = "-"
|
---|
[141] | 6547 | self._fuelData = None
|
---|
[64] | 6548 | self._departureNOTAMs = None
|
---|
[67] | 6549 | self._departureMETAR = None
|
---|
[64] | 6550 | self._arrivalNOTAMs = None
|
---|
[67] | 6551 | self._arrivalMETAR = None
|
---|
[692] | 6552 | self._usingSimBrief = None
|
---|
[717] | 6553 | self.takeoffRunway = None
|
---|
| 6554 | self.landingRunway = None
|
---|
[67] | 6555 |
|
---|
[208] | 6556 | firstPage = 0 if self._loginResult is None else 1
|
---|
| 6557 | for page in self._pages[firstPage:]:
|
---|
[67] | 6558 | page.reset()
|
---|
[347] | 6559 |
|
---|
[208] | 6560 | self.setCurrentPage(firstPage)
|
---|
[621] | 6561 | #self.setCurrentPage(10)
|
---|
[208] | 6562 |
|
---|
[1106] | 6563 | @property
|
---|
| 6564 | def isDepartureGateTaxiThrough(self):
|
---|
| 6565 | """Determine if the departure gate is a taxi-through one."""
|
---|
| 6566 | if self._departureGate=="-":
|
---|
| 6567 | return True
|
---|
| 6568 | else:
|
---|
| 6569 | gate = lhbpGates.find(self._departureGate)
|
---|
| 6570 | return False if gate is None else gate.taxiThrough
|
---|
| 6571 |
|
---|
[760] | 6572 | def login(self, callback, pilotID, password):
|
---|
[208] | 6573 | """Called when the login button was clicked."""
|
---|
| 6574 | self._loginCallback = callback
|
---|
| 6575 | if pilotID is None:
|
---|
| 6576 | loginResult = self._loginResult
|
---|
| 6577 | assert loginResult is not None and loginResult.loggedIn
|
---|
| 6578 | pilotID = loginResult.pilotID
|
---|
| 6579 | password = loginResult.password
|
---|
| 6580 | busyMessage = xstr("reload_busy")
|
---|
| 6581 | else:
|
---|
| 6582 | self._loginResult = None
|
---|
| 6583 | busyMessage = xstr("login_busy")
|
---|
| 6584 |
|
---|
| 6585 | self.gui.beginBusy(busyMessage)
|
---|
[347] | 6586 |
|
---|
[208] | 6587 | self.gui.webHandler.login(self._loginResultCallback,
|
---|
[760] | 6588 | pilotID, password)
|
---|
[208] | 6589 |
|
---|
| 6590 | def reloadFlights(self, callback):
|
---|
| 6591 | """Reload the flights from the MAVA server."""
|
---|
[769] | 6592 | self.login(callback, None, None)
|
---|
| 6593 |
|
---|
[859] | 6594 | def addFlight(self, bookedFlight):
|
---|
| 6595 | """Add the given booked flight to the flight selection page."""
|
---|
| 6596 | self._flightSelectionPage.addFlight(bookedFlight)
|
---|
| 6597 |
|
---|
[821] | 6598 | def reflyFlight(self, bookedFlight):
|
---|
| 6599 | """Add the given booked flight to the flight selection page."""
|
---|
| 6600 | self._removePendingFlight(bookedFlight)
|
---|
| 6601 | self._flightSelectionPage._reflyFlight(bookedFlight)
|
---|
| 6602 |
|
---|
[824] | 6603 | def deleteFlight(self, bookedFlight):
|
---|
| 6604 | """Remove the given flight from the pending flight list."""
|
---|
| 6605 | self._removePendingFlight(bookedFlight)
|
---|
| 6606 | self._flightSelectionPage._updatePending()
|
---|
| 6607 |
|
---|
[769] | 6608 | def cancelFlight(self, reloadCallback):
|
---|
| 6609 | """Cancel the flight.
|
---|
| 6610 |
|
---|
| 6611 | If it is an entry exam flight, we go back to the student page.
|
---|
| 6612 | Otherwise we reload the flights."""
|
---|
| 6613 | if self.entranceExam:
|
---|
| 6614 | self.reset(None)
|
---|
| 6615 | self.jumpPage("student")
|
---|
| 6616 | else:
|
---|
| 6617 | self.reloadFlights(reloadCallback)
|
---|
[208] | 6618 |
|
---|
[304] | 6619 | def cruiseLevelChanged(self):
|
---|
| 6620 | """Called when the cruise level is changed."""
|
---|
[383] | 6621 | return self.gui.cruiseLevelChanged()
|
---|
[304] | 6622 |
|
---|
[586] | 6623 | def metarChanged(self, metar, originator):
|
---|
| 6624 | """Called when a METER is changed on on of the pages.
|
---|
| 6625 |
|
---|
| 6626 | originator is the page that originated the changed. It will be used to
|
---|
| 6627 | determine which METAR (departure or arrival) has changed."""
|
---|
| 6628 | metar = metar.upper()
|
---|
| 6629 | if originator in [self._departureBriefingPage, self._takeoffPage]:
|
---|
[718] | 6630 | self.departureMETARChanged(metar, originator)
|
---|
[586] | 6631 | else:
|
---|
[718] | 6632 | self.arrivalMETARChanged(metar, originator)
|
---|
| 6633 |
|
---|
| 6634 | def departureMETARChanged(self, metar, originator):
|
---|
[586] | 6635 | """Called when the departure METAR has been edited on one of the
|
---|
| 6636 | pages.
|
---|
| 6637 |
|
---|
| 6638 | originator is the page that originated the change. It will not be
|
---|
| 6639 | called to set the METAR, while others will be."""
|
---|
| 6640 | for page in [self._departureBriefingPage, self._takeoffPage]:
|
---|
| 6641 | if page is not originator:
|
---|
| 6642 | page.changeMETAR(metar)
|
---|
| 6643 |
|
---|
[1110] | 6644 | def arrivalMETARChanged(self, metar, originator, fromDownload = False):
|
---|
[586] | 6645 | """Called when the arrival METAR has been edited on one of the
|
---|
| 6646 | pages.
|
---|
| 6647 |
|
---|
| 6648 | originator is the page that originated the change. It will not be
|
---|
| 6649 | called to set the METAR, while others will be."""
|
---|
[589] | 6650 | for page in [self._arrivalBriefingPage, self._landingPage]:
|
---|
[586] | 6651 | if page is not originator:
|
---|
[1110] | 6652 | page.changeMETAR(metar, fromEditing = not fromDownload)
|
---|
[586] | 6653 |
|
---|
[821] | 6654 | def _removePendingFlight(self, flight):
|
---|
| 6655 | """Remove the given pending flight from the login result."""
|
---|
| 6656 | for flights in [self._loginResult.reportedFlights,
|
---|
| 6657 | self._loginResult.rejectedFlights]:
|
---|
| 6658 | for f in flights:
|
---|
| 6659 | if f.id==flight.id:
|
---|
| 6660 | flights.remove(f)
|
---|
| 6661 | return
|
---|
| 6662 |
|
---|
[208] | 6663 | def _loginResultCallback(self, returned, result):
|
---|
| 6664 | """The login result callback, called in the web handler's thread."""
|
---|
[995] | 6665 | GObject.idle_add(self._handleLoginResult, returned, result)
|
---|
[208] | 6666 |
|
---|
| 6667 | def _handleLoginResult(self, returned, result):
|
---|
| 6668 | """Handle the login result."""
|
---|
| 6669 | self.gui.endBusy()
|
---|
| 6670 | isReload = self._loginResult is not None
|
---|
| 6671 | if returned:
|
---|
| 6672 | if result.loggedIn:
|
---|
| 6673 | self._loginResult = result
|
---|
[854] | 6674 | self.gui.loginSuccessful()
|
---|
[208] | 6675 | else:
|
---|
| 6676 | if isReload:
|
---|
| 6677 | message = xstr("reload_failed")
|
---|
| 6678 | else:
|
---|
| 6679 | message = xstr("login_entranceExam_invalid"
|
---|
| 6680 | if self.entranceExam else
|
---|
| 6681 | xstr("login_invalid"))
|
---|
[996] | 6682 | dialog = Gtk.MessageDialog(parent = self.gui.mainWindow,
|
---|
[999] | 6683 | type = Gtk.MessageType.ERROR,
|
---|
[208] | 6684 | message_format = message)
|
---|
[999] | 6685 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
[208] | 6686 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 6687 | if isReload:
|
---|
| 6688 | secondary = xstr("reload_failed_sec")
|
---|
| 6689 | else:
|
---|
| 6690 | secondary = xstr("login_entranceExam_invalid_sec"
|
---|
| 6691 | if self.entranceExam else
|
---|
| 6692 | xstr("login_invalid_sec"))
|
---|
| 6693 | dialog.format_secondary_markup(secondary)
|
---|
| 6694 | dialog.run()
|
---|
| 6695 | dialog.hide()
|
---|
| 6696 | else:
|
---|
| 6697 | message = xstr("reload_failconn") if isReload \
|
---|
| 6698 | else xstr("login_failconn")
|
---|
[996] | 6699 | dialog = Gtk.MessageDialog(parent = self.gui.mainWindow,
|
---|
[999] | 6700 | type = Gtk.MessageType.ERROR,
|
---|
[208] | 6701 | message_format = message)
|
---|
[999] | 6702 | dialog.add_button(xstr("button_ok"), Gtk.ResponseType.OK)
|
---|
[208] | 6703 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 6704 | secondary = xstr("reload_failconn_sec") if isReload \
|
---|
| 6705 | else xstr("login_failconn_sec")
|
---|
| 6706 | dialog.format_secondary_markup(secondary)
|
---|
[347] | 6707 |
|
---|
[208] | 6708 | dialog.run()
|
---|
| 6709 | dialog.hide()
|
---|
| 6710 |
|
---|
| 6711 | callback = self._loginCallback
|
---|
| 6712 | self._loginCallback = None
|
---|
| 6713 | callback(returned, result)
|
---|
[126] | 6714 |
|
---|
[130] | 6715 | def getFleet(self, callback, force = False):
|
---|
[126] | 6716 | """Get the fleet via the GUI and call the given callback."""
|
---|
| 6717 | self._fleetCallback = callback
|
---|
[130] | 6718 | self.gui.getFleet(callback = self._fleetRetrieved, force = force)
|
---|
[126] | 6719 |
|
---|
| 6720 | def _fleetRetrieved(self, fleet):
|
---|
| 6721 | """Callback for the fleet retrieval."""
|
---|
| 6722 | self._fleet = fleet
|
---|
| 6723 | if self._fleetCallback is not None:
|
---|
| 6724 | self._fleetCallback(fleet)
|
---|
| 6725 | self._fleetCallback = None
|
---|
[347] | 6726 |
|
---|
[130] | 6727 | def updatePlane(self, callback, tailNumber, status, gateNumber = None):
|
---|
[51] | 6728 | """Update the given plane's gate information."""
|
---|
[130] | 6729 | self.gui.updatePlane(tailNumber, status, gateNumber = gateNumber,
|
---|
| 6730 | callback = callback)
|
---|
[51] | 6731 |
|
---|
[349] | 6732 | def updateRTO(self):
|
---|
| 6733 | """Update the RTO state.
|
---|
| 6734 |
|
---|
| 6735 | The RTO checkbox will be enabled if the flight has an RTO state and the
|
---|
| 6736 | comments field contains some text."""
|
---|
| 6737 | flight = self.gui.flight
|
---|
| 6738 | rtoEnabled = flight is not None and flight.hasRTO and \
|
---|
| 6739 | self.gui.hasComments
|
---|
| 6740 | self._takeoffPage.setRTOEnabled(rtoEnabled)
|
---|
| 6741 |
|
---|
[555] | 6742 | def commentsChanged(self):
|
---|
| 6743 | """Called when the comments have changed."""
|
---|
| 6744 | self.updateRTO()
|
---|
| 6745 | self._finishPage.updateButtons()
|
---|
| 6746 |
|
---|
| 6747 | def delayCodesChanged(self):
|
---|
| 6748 | """Called when the delay codes have changed."""
|
---|
| 6749 | self._finishPage.updateButtons()
|
---|
| 6750 |
|
---|
[605] | 6751 | def faultExplanationsChanged(self):
|
---|
| 6752 | """Called when the faults and their explanations have changed."""
|
---|
| 6753 | self._finishPage.updateButtons()
|
---|
| 6754 |
|
---|
[349] | 6755 | def rtoToggled(self, indicated):
|
---|
| 6756 | """Called when the RTO indication has changed."""
|
---|
| 6757 | self.gui.rtoToggled(indicated)
|
---|
| 6758 |
|
---|
[1097] | 6759 | def finalizeCEF(self):
|
---|
| 6760 | """Called when any CEF browsers should be finalized."""
|
---|
| 6761 | self._simBriefingPage.finalizeCEF()
|
---|
| 6762 |
|
---|
[501] | 6763 | def _connectSimulator(self, simulatorType):
|
---|
[51] | 6764 | """Connect to the simulator."""
|
---|
[798] | 6765 | self.gui.connectSimulator(self._bookedFlight, simulatorType)
|
---|
[106] | 6766 |
|
---|
| 6767 | def _arrivalMETARCallback(self, returned, result):
|
---|
| 6768 | """Called when the METAR of the arrival airport is retrieved."""
|
---|
[995] | 6769 | GObject.idle_add(self._handleArrivalMETAR, returned, result)
|
---|
[347] | 6770 |
|
---|
[106] | 6771 | def _handleArrivalMETAR(self, returned, result):
|
---|
| 6772 | """Called when the METAR of the arrival airport is retrieved."""
|
---|
| 6773 | icao = self._bookedFlight.arrivalICAO
|
---|
| 6774 | if returned and icao in result.metars:
|
---|
| 6775 | metar = result.metars[icao]
|
---|
| 6776 | if metar!="":
|
---|
| 6777 | self._arrivalBriefingPage.setMETAR(metar)
|
---|
[347] | 6778 |
|
---|
[754] | 6779 | def _getIndexOf(self, pageID):
|
---|
| 6780 | """Get the index for the given page ID.
|
---|
| 6781 |
|
---|
| 6782 | It is an assertion failure if the ID is not found."""
|
---|
| 6783 | for index in range(0, len(self._pages)):
|
---|
| 6784 | page = self._pages[index]
|
---|
| 6785 | if page.id==pageID:
|
---|
| 6786 | return index
|
---|
| 6787 | assert False
|
---|
| 6788 |
|
---|
[42] | 6789 | #-----------------------------------------------------------------------------
|
---|