[42] | 1 |
|
---|
| 2 | from mlx.gui.common import *
|
---|
| 3 |
|
---|
[51] | 4 | import mlx.const as const
|
---|
| 5 | import mlx.fs as fs
|
---|
[141] | 6 | import mlx.acft as acft
|
---|
[383] | 7 | from mlx.flight import Flight
|
---|
[60] | 8 | from mlx.checks import PayloadChecker
|
---|
[89] | 9 | import mlx.util as util
|
---|
[97] | 10 | from mlx.pirep import PIREP
|
---|
[107] | 11 | from mlx.i18n import xstr
|
---|
[170] | 12 | from mlx.sound import startSound
|
---|
[184] | 13 | import mlx.web as web
|
---|
[51] | 14 |
|
---|
[61] | 15 | import datetime
|
---|
| 16 | import time
|
---|
[393] | 17 | import os
|
---|
[61] | 18 |
|
---|
[42] | 19 | #-----------------------------------------------------------------------------
|
---|
| 20 |
|
---|
[300] | 21 | ## @package mlx.gui.flight
|
---|
| 22 | #
|
---|
| 23 | # The flight "wizard".
|
---|
| 24 | #
|
---|
| 25 | # This module implements the main tab of the application, the flight
|
---|
| 26 | # wizard. The wizard consists of \ref Page "pages", that come one after the
|
---|
| 27 | # other. As some pages might be skipped, the pages dynamically store the index
|
---|
| 28 | # of the previous page so that going back to it is simpler. The \ref
|
---|
| 29 | # Page.activate "activate" function is called before a page is first shown
|
---|
| 30 | # during a flight. This function should initialize the page's controls and fill
|
---|
| 31 | # it with initial data. When a page is left for the first time, its \ref
|
---|
| 32 | # Page.finalize "finalize" function is called. It should set those controls
|
---|
| 33 | # insensitive, that will not be available if the user comes back to this page.
|
---|
| 34 | #
|
---|
| 35 | # Each page has a title at the top displayed in inverted colors and a big
|
---|
| 36 | # font. There is a help text below it centered, that shortly describes what is
|
---|
| 37 | # expected on the page. There can be two help texts: one shown when the page is
|
---|
| 38 | # first displayed during a flight, another shown when the user goes back to the
|
---|
| 39 | # page. The main content area is below this, also centered. Finally, there are
|
---|
| 40 | # some buttons at the bottom on the right. As some buttons occur very
|
---|
| 41 | # frequently, there are functions to add them (\ref Page.addCancelFlightButton
|
---|
| 42 | # "addCancelFlightButton", \ref Page.addPreviousButton "addPreviousButton" and
|
---|
| 43 | # \ref Page.addNextButton "addNextButton".
|
---|
| 44 | #
|
---|
| 45 | # The \ref Wizard class is the main class to collect the pages. It also stores
|
---|
| 46 | # some data passed from one page to another and provides properties to access
|
---|
| 47 | # data items set via the wizard pages.
|
---|
| 48 |
|
---|
| 49 | #-----------------------------------------------------------------------------
|
---|
| 50 |
|
---|
[44] | 51 | class Page(gtk.Alignment):
|
---|
[42] | 52 | """A page in the flight wizard."""
|
---|
[94] | 53 | def __init__(self, wizard, title, help, completedHelp = None):
|
---|
[42] | 54 | """Construct the page."""
|
---|
[44] | 55 | super(Page, self).__init__(xalign = 0.0, yalign = 0.0,
|
---|
| 56 | xscale = 1.0, yscale = 1.0)
|
---|
| 57 | self.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 58 | padding_left = 12, padding_right = 12)
|
---|
| 59 |
|
---|
| 60 | frame = gtk.Frame()
|
---|
| 61 | self.add(frame)
|
---|
| 62 |
|
---|
| 63 | self._vbox = gtk.VBox()
|
---|
[48] | 64 | self._vbox.set_homogeneous(False)
|
---|
[44] | 65 | frame.add(self._vbox)
|
---|
| 66 |
|
---|
| 67 | eventBox = gtk.EventBox()
|
---|
| 68 |
|
---|
| 69 | alignment = gtk.Alignment(xalign = 0.0, xscale = 0.0)
|
---|
[347] | 70 |
|
---|
[201] | 71 | titleLabel = gtk.Label(title)
|
---|
| 72 | titleLabel.modify_font(pango.FontDescription("bold 24"))
|
---|
[44] | 73 | alignment.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 74 | padding_left = 6, padding_right = 0)
|
---|
[347] | 75 |
|
---|
[201] | 76 | alignment.add(titleLabel)
|
---|
[44] | 77 | eventBox.add(alignment)
|
---|
[347] | 78 |
|
---|
[44] | 79 | self._vbox.pack_start(eventBox, False, False, 0)
|
---|
| 80 |
|
---|
[201] | 81 | self._titleEventBox = eventBox
|
---|
| 82 | self._titleLabel = titleLabel
|
---|
| 83 |
|
---|
[347] | 84 | mainBox = gtk.VBox()
|
---|
[48] | 85 |
|
---|
| 86 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
[347] | 87 | xscale = 1.0, yscale = 1.0)
|
---|
[48] | 88 | alignment.set_padding(padding_top = 16, padding_bottom = 16,
|
---|
| 89 | padding_left = 16, padding_right = 16)
|
---|
[79] | 90 | alignment.add(mainBox)
|
---|
[48] | 91 | self._vbox.pack_start(alignment, True, True, 0)
|
---|
[347] | 92 |
|
---|
[48] | 93 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
[94] | 94 | xscale = 0.0, yscale = 0.0)
|
---|
[50] | 95 | alignment.set_padding(padding_top = 0, padding_bottom = 16,
|
---|
| 96 | padding_left = 0, padding_right = 0)
|
---|
[48] | 97 |
|
---|
[94] | 98 | self._help = help
|
---|
| 99 | self._completedHelp = completedHelp
|
---|
| 100 |
|
---|
| 101 | if self._completedHelp is None or \
|
---|
| 102 | len(help.splitlines())>=len(completedHelp.splitlines()):
|
---|
| 103 | longerHelp = help
|
---|
| 104 | else:
|
---|
| 105 | longerHelp = completedHelp
|
---|
[347] | 106 |
|
---|
[94] | 107 | self._helpLabel = gtk.Label(completedHelp)
|
---|
| 108 | # FIXME: should be a constant in common
|
---|
| 109 | self._helpLabel.set_justify(gtk.Justification.CENTER if pygobject
|
---|
| 110 | else gtk.JUSTIFY_CENTER)
|
---|
| 111 | self._helpLabel.set_use_markup(True)
|
---|
| 112 | alignment.add(self._helpLabel)
|
---|
[79] | 113 | mainBox.pack_start(alignment, False, False, 0)
|
---|
[44] | 114 |
|
---|
| 115 | self._mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[48] | 116 | xscale = 1.0, yscale = 1.0)
|
---|
[79] | 117 | mainBox.pack_start(self._mainAlignment, True, True, 0)
|
---|
[347] | 118 |
|
---|
[48] | 119 | buttonAlignment = gtk.Alignment(xalign = 1.0, xscale=0.0, yscale = 0.0)
|
---|
[44] | 120 | buttonAlignment.set_padding(padding_top = 4, padding_bottom = 10,
|
---|
| 121 | padding_left = 16, padding_right = 16)
|
---|
| 122 |
|
---|
[70] | 123 | self._buttonBox = gtk.HBox()
|
---|
| 124 | self._buttonBox.set_homogeneous(False)
|
---|
[46] | 125 | self._defaultButton = None
|
---|
[44] | 126 | buttonAlignment.add(self._buttonBox)
|
---|
| 127 |
|
---|
| 128 | self._vbox.pack_start(buttonAlignment, False, False, 0)
|
---|
| 129 |
|
---|
[42] | 130 | self._wizard = wizard
|
---|
| 131 |
|
---|
[275] | 132 | self._cancelFlightButton = None
|
---|
| 133 |
|
---|
[94] | 134 | self._completed = False
|
---|
[70] | 135 | self._fromPage = None
|
---|
| 136 |
|
---|
[44] | 137 | def setMainWidget(self, widget):
|
---|
| 138 | """Set the given widget as the main one."""
|
---|
| 139 | self._mainAlignment.add(widget)
|
---|
| 140 |
|
---|
[107] | 141 | def addButton(self, label, default = False, sensitive = True,
|
---|
[208] | 142 | tooltip = None, clicked = None, padding = 4):
|
---|
[44] | 143 | """Add a button with the given label.
|
---|
| 144 |
|
---|
| 145 | Return the button object created."""
|
---|
| 146 | button = gtk.Button(label)
|
---|
[208] | 147 | self._buttonBox.pack_start(button, False, False, padding)
|
---|
[48] | 148 | button.set_use_underline(True)
|
---|
[46] | 149 | if default:
|
---|
| 150 | button.set_can_default(True)
|
---|
| 151 | self._defaultButton = button
|
---|
[107] | 152 | button.set_sensitive(sensitive)
|
---|
| 153 | if tooltip is not None:
|
---|
| 154 | button.set_tooltip_text(tooltip)
|
---|
| 155 | if clicked is not None:
|
---|
| 156 | button.connect("clicked", clicked)
|
---|
[44] | 157 | return button
|
---|
| 158 |
|
---|
[208] | 159 | def addCancelFlightButton(self):
|
---|
| 160 | """Add the 'Cancel flight' button to the page."""
|
---|
[275] | 161 | self._cancelFlightButton = \
|
---|
| 162 | self.addButton(xstr("button_cancelFlight"),
|
---|
| 163 | sensitive = True,
|
---|
| 164 | tooltip = xstr("button_cancelFlight_tooltip"),
|
---|
| 165 | clicked = self._cancelFlight,
|
---|
| 166 | padding = 16)
|
---|
| 167 | return self._cancelFlightButton
|
---|
[208] | 168 |
|
---|
[107] | 169 | def addPreviousButton(self, sensitive = True, clicked = None):
|
---|
| 170 | """Add the 'Next' button to the page."""
|
---|
| 171 | return self.addButton(xstr("button_previous"),
|
---|
| 172 | sensitive = sensitive,
|
---|
| 173 | tooltip = xstr("button_previous_tooltip"),
|
---|
| 174 | clicked = clicked)
|
---|
| 175 |
|
---|
| 176 | def addNextButton(self, default = True, sensitive = True,
|
---|
| 177 | clicked = None):
|
---|
| 178 | """Add the 'Next' button to the page."""
|
---|
| 179 | return self.addButton(xstr("button_next"),
|
---|
| 180 | default = default,
|
---|
| 181 | sensitive = sensitive,
|
---|
| 182 | tooltip = xstr("button_next_tooltip"),
|
---|
| 183 | clicked = clicked)
|
---|
| 184 |
|
---|
[201] | 185 | def setStyle(self):
|
---|
| 186 | """Set the styles of some of the items on the page."""
|
---|
| 187 | style = self.get_style() if pygobject else self.rc_get_style()
|
---|
| 188 |
|
---|
| 189 | self._titleEventBox.modify_bg(0, style.bg[3])
|
---|
| 190 | self._titleLabel.modify_fg(0, style.fg[3])
|
---|
[347] | 191 |
|
---|
[94] | 192 | def initialize(self):
|
---|
| 193 | """Initialize the page.
|
---|
| 194 |
|
---|
| 195 | It sets up the primary help, and calls the activate() function."""
|
---|
| 196 | self._helpLabel.set_markup(self._help)
|
---|
| 197 | self._helpLabel.set_sensitive(True)
|
---|
| 198 | self.activate()
|
---|
| 199 |
|
---|
[48] | 200 | def activate(self):
|
---|
| 201 | """Called when this page becomes active.
|
---|
| 202 |
|
---|
| 203 | This default implementation does nothing."""
|
---|
| 204 | pass
|
---|
| 205 |
|
---|
[94] | 206 | def complete(self):
|
---|
| 207 | """Called when the page is completed.
|
---|
| 208 |
|
---|
| 209 | It greys out/changes the help text and then calls finalize()."""
|
---|
| 210 | self.finalize()
|
---|
| 211 | if self._completedHelp is None:
|
---|
| 212 | self._helpLabel.set_sensitive(False)
|
---|
| 213 | else:
|
---|
| 214 | self._helpLabel.set_markup(self._completedHelp)
|
---|
| 215 | self._completed = True
|
---|
| 216 |
|
---|
[70] | 217 | def finalize(self):
|
---|
| 218 | """Called when the page is finalized."""
|
---|
| 219 | pass
|
---|
| 220 |
|
---|
[46] | 221 | def grabDefault(self):
|
---|
| 222 | """If the page has a default button, make it the default one."""
|
---|
| 223 | if self._defaultButton is not None:
|
---|
| 224 | self._defaultButton.grab_default()
|
---|
[67] | 225 |
|
---|
| 226 | def reset(self):
|
---|
| 227 | """Reset the page if the wizard is reset."""
|
---|
[94] | 228 | self._completed = False
|
---|
[70] | 229 | self._fromPage = None
|
---|
[275] | 230 | if self._cancelFlightButton is not None:
|
---|
| 231 | self._cancelFlightButton.set_sensitive(True)
|
---|
[70] | 232 |
|
---|
| 233 | def goBack(self):
|
---|
| 234 | """Go to the page we were invoked from."""
|
---|
| 235 | assert self._fromPage is not None
|
---|
[347] | 236 |
|
---|
[70] | 237 | self._wizard.setCurrentPage(self._fromPage, finalize = False)
|
---|
[208] | 238 |
|
---|
[275] | 239 | def flightEnded(self):
|
---|
| 240 | """Called when the flight has ended.
|
---|
| 241 |
|
---|
| 242 | This default implementation disables the cancel flight button."""
|
---|
| 243 | if self._cancelFlightButton is not None:
|
---|
| 244 | self._cancelFlightButton.set_sensitive(False)
|
---|
| 245 |
|
---|
[208] | 246 | def _cancelFlight(self, button):
|
---|
| 247 | """Called when the Cancel flight button is clicked."""
|
---|
| 248 | self._wizard.gui.cancelFlight()
|
---|
[347] | 249 |
|
---|
[42] | 250 | #-----------------------------------------------------------------------------
|
---|
| 251 |
|
---|
| 252 | class LoginPage(Page):
|
---|
| 253 | """The login page."""
|
---|
| 254 | def __init__(self, wizard):
|
---|
| 255 | """Construct the login page."""
|
---|
[107] | 256 | super(LoginPage, self).__init__(wizard, xstr("login"),
|
---|
| 257 | xstr("loginHelp"))
|
---|
[42] | 258 |
|
---|
[48] | 259 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 260 | xscale = 0.0, yscale = 0.0)
|
---|
[139] | 261 |
|
---|
[184] | 262 | table = gtk.Table(4, 2)
|
---|
[42] | 263 | table.set_row_spacings(4)
|
---|
| 264 | table.set_col_spacings(32)
|
---|
[48] | 265 | alignment.add(table)
|
---|
| 266 | self.setMainWidget(alignment)
|
---|
[42] | 267 |
|
---|
[107] | 268 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 269 | xscale = 0.0, yscale = 0.0)
|
---|
| 270 | label = gtk.Label(xstr("label_pilotID"))
|
---|
[45] | 271 | label.set_use_underline(True)
|
---|
| 272 | labelAlignment.add(label)
|
---|
[42] | 273 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 274 |
|
---|
| 275 | self._pilotID = gtk.Entry()
|
---|
[184] | 276 | self._pilotID.connect("changed", self._setControls)
|
---|
[107] | 277 | self._pilotID.set_tooltip_text(xstr("login_pilotID_tooltip"))
|
---|
[42] | 278 | table.attach(self._pilotID, 1, 2, 0, 1)
|
---|
[45] | 279 | label.set_mnemonic_widget(self._pilotID)
|
---|
[42] | 280 |
|
---|
[107] | 281 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 282 | xscale = 0.0, yscale = 0.0)
|
---|
| 283 | label = gtk.Label(xstr("label_password"))
|
---|
[45] | 284 | label.set_use_underline(True)
|
---|
| 285 | labelAlignment.add(label)
|
---|
[42] | 286 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 287 |
|
---|
| 288 | self._password = gtk.Entry()
|
---|
| 289 | self._password.set_visibility(False)
|
---|
[184] | 290 | self._password.connect("changed", self._setControls)
|
---|
[107] | 291 | self._password.set_tooltip_text(xstr("login_password_tooltip"))
|
---|
[42] | 292 | table.attach(self._password, 1, 2, 1, 2)
|
---|
[45] | 293 | label.set_mnemonic_widget(self._password)
|
---|
[42] | 294 |
|
---|
[107] | 295 | self._rememberButton = gtk.CheckButton(xstr("remember_password"))
|
---|
[45] | 296 | self._rememberButton.set_use_underline(True)
|
---|
[107] | 297 | self._rememberButton.set_tooltip_text(xstr("login_remember_tooltip"))
|
---|
[45] | 298 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
| 299 |
|
---|
[184] | 300 | self._entranceExam = gtk.CheckButton(xstr("login_entranceExam"))
|
---|
| 301 | self._entranceExam.set_use_underline(True)
|
---|
| 302 | self._entranceExam.set_tooltip_text(xstr("login_entranceExam_tooltip"))
|
---|
| 303 | self._entranceExam.connect("toggled", self._setControls)
|
---|
| 304 | table.attach(self._entranceExam, 1, 2, 3, 4, ypadding = 12)
|
---|
| 305 |
|
---|
[215] | 306 | self.addButton(xstr("button_offline"),
|
---|
| 307 | clicked = self._offlineClicked,
|
---|
| 308 | tooltip = xstr("button_offline_tooltip"))
|
---|
| 309 |
|
---|
[107] | 310 | self._loginButton = self.addButton(xstr("button_login"), default = True)
|
---|
[42] | 311 | self._loginButton.connect("clicked", self._loginClicked)
|
---|
[184] | 312 | self._loginButton.set_tooltip_text(xstr("login_button_tooltip"))
|
---|
| 313 |
|
---|
| 314 |
|
---|
| 315 | @property
|
---|
| 316 | def entranceExam(self):
|
---|
| 317 | """Get whether an entrance exam is being performed."""
|
---|
| 318 | return self._entranceExam.get_active() and \
|
---|
| 319 | self._pilotID.get_text()!=""
|
---|
[92] | 320 |
|
---|
[215] | 321 | @property
|
---|
| 322 | def pilotID(self):
|
---|
| 323 | """Get the pilot ID, if given."""
|
---|
| 324 | return self._pilotID.get_text()
|
---|
| 325 |
|
---|
[92] | 326 | def activate(self):
|
---|
| 327 | """Activate the page."""
|
---|
[42] | 328 | config = self._wizard.gui.config
|
---|
| 329 | self._pilotID.set_text(config.pilotID)
|
---|
| 330 | self._password.set_text(config.password)
|
---|
[45] | 331 | self._rememberButton.set_active(config.rememberPassword)
|
---|
[347] | 332 | self._setControls(None)
|
---|
[184] | 333 |
|
---|
| 334 | def _setControls(self, entry = None):
|
---|
| 335 | """Set the sensitivity of the various controls.
|
---|
| 336 |
|
---|
| 337 | The login button is sensitive only if both the pilot ID and the
|
---|
| 338 | password fields contain values.
|
---|
| 339 |
|
---|
| 340 | The password field is sensitive only, if the entrance exam checkbox is
|
---|
| 341 | not selected.
|
---|
| 342 |
|
---|
| 343 | The remember password checkbox is sensitive only, if the password field
|
---|
| 344 | contains text.
|
---|
| 345 |
|
---|
[208] | 346 | The entrance exam checkbox is sensitive only, if the pilot ID is not
|
---|
[184] | 347 | empty."""
|
---|
| 348 | pilotID = self._pilotID.get_text()
|
---|
| 349 | password = self._password.get_text()
|
---|
| 350 | entranceExam = self._entranceExam.get_active()
|
---|
| 351 | self._password.set_sensitive(not entranceExam)
|
---|
| 352 | self._rememberButton.set_sensitive(password!="" and not entranceExam)
|
---|
| 353 | self._entranceExam.set_sensitive(pilotID!="")
|
---|
| 354 | self._loginButton.set_sensitive(pilotID!="" and
|
---|
| 355 | (password!="" or entranceExam))
|
---|
[42] | 356 |
|
---|
[215] | 357 | def _offlineClicked(self, button):
|
---|
| 358 | """Called when the offline button was clicked."""
|
---|
| 359 | self._wizard.nextPage()
|
---|
| 360 |
|
---|
[42] | 361 | def _loginClicked(self, button):
|
---|
| 362 | """Called when the login button was clicked."""
|
---|
[208] | 363 | self._wizard.login(self._handleLoginResult,
|
---|
| 364 | self._pilotID.get_text(),
|
---|
| 365 | self._password.get_text(),
|
---|
| 366 | self.entranceExam)
|
---|
[42] | 367 |
|
---|
| 368 | def _handleLoginResult(self, returned, result):
|
---|
| 369 | """Handle the login result."""
|
---|
[70] | 370 | self._loginButton.set_sensitive(True)
|
---|
[208] | 371 | if returned and result.loggedIn:
|
---|
| 372 | config = self._wizard.gui.config
|
---|
| 373 |
|
---|
| 374 | config.pilotID = self._pilotID.get_text()
|
---|
| 375 |
|
---|
[347] | 376 | rememberPassword = self._rememberButton.get_active()
|
---|
[208] | 377 | config.password = result.password if rememberPassword else ""
|
---|
| 378 |
|
---|
| 379 | config.rememberPassword = rememberPassword
|
---|
| 380 |
|
---|
| 381 | config.save()
|
---|
| 382 | self._wizard.nextPage()
|
---|
[42] | 383 |
|
---|
| 384 | #-----------------------------------------------------------------------------
|
---|
| 385 |
|
---|
| 386 | class FlightSelectionPage(Page):
|
---|
| 387 | """The page to select the flight."""
|
---|
| 388 | def __init__(self, wizard):
|
---|
| 389 | """Construct the flight selection page."""
|
---|
[347] | 390 | help = xstr("flightsel_help")
|
---|
[107] | 391 | completedHelp = xstr("flightsel_chelp")
|
---|
| 392 | super(FlightSelectionPage, self).__init__(wizard, xstr("flightsel_title"),
|
---|
[94] | 393 | help, completedHelp = completedHelp)
|
---|
[48] | 394 |
|
---|
| 395 |
|
---|
| 396 | self._listStore = gtk.ListStore(str, str, str, str)
|
---|
| 397 | self._flightList = gtk.TreeView(self._listStore)
|
---|
[107] | 398 | column = gtk.TreeViewColumn(xstr("flightsel_no"), gtk.CellRendererText(),
|
---|
[48] | 399 | text = 1)
|
---|
| 400 | column.set_expand(True)
|
---|
| 401 | self._flightList.append_column(column)
|
---|
[107] | 402 | column = gtk.TreeViewColumn(xstr("flightsel_deptime"), gtk.CellRendererText(),
|
---|
[48] | 403 | text = 0)
|
---|
| 404 | column.set_expand(True)
|
---|
| 405 | self._flightList.append_column(column)
|
---|
[107] | 406 | column = gtk.TreeViewColumn(xstr("flightsel_from"), gtk.CellRendererText(),
|
---|
[48] | 407 | text = 2)
|
---|
| 408 | column.set_expand(True)
|
---|
| 409 | self._flightList.append_column(column)
|
---|
[107] | 410 | column = gtk.TreeViewColumn(xstr("flightsel_to"), gtk.CellRendererText(),
|
---|
[48] | 411 | text = 3)
|
---|
| 412 | column.set_expand(True)
|
---|
| 413 | self._flightList.append_column(column)
|
---|
[277] | 414 | self._flightList.connect("row-activated", self._rowActivated)
|
---|
| 415 | self._flightList.connect("button-press-event", self._listButtonPressed)
|
---|
| 416 |
|
---|
| 417 | self._flightListPopupMenu = None
|
---|
[48] | 418 |
|
---|
| 419 | flightSelection = self._flightList.get_selection()
|
---|
[347] | 420 | flightSelection.connect("changed", self._selectionChanged)
|
---|
[48] | 421 |
|
---|
| 422 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 423 | scrolledWindow.add(self._flightList)
|
---|
| 424 | scrolledWindow.set_size_request(400, -1)
|
---|
[118] | 425 | # FIXME: these should be constants in common.py
|
---|
[48] | 426 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 427 | else gtk.POLICY_AUTOMATIC,
|
---|
[69] | 428 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 429 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 430 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 431 | else gtk.SHADOW_IN)
|
---|
[48] | 432 |
|
---|
| 433 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
| 434 | alignment.add(scrolledWindow)
|
---|
| 435 |
|
---|
| 436 | self.setMainWidget(alignment)
|
---|
| 437 |
|
---|
[214] | 438 | self._saveButton = self.addButton(xstr("flightsel_save"),
|
---|
| 439 | sensitive = False,
|
---|
| 440 | clicked = self._saveClicked,
|
---|
| 441 | tooltip = xstr("flightsel_save_tooltip"))
|
---|
| 442 | self._saveDialog = None
|
---|
| 443 |
|
---|
[208] | 444 | self._refreshButton = self.addButton(xstr("flightsel_refresh"),
|
---|
| 445 | sensitive = True,
|
---|
| 446 | clicked = self._refreshClicked,
|
---|
| 447 | tooltip = xstr("flightsel_refresh_tooltip"))
|
---|
| 448 |
|
---|
[184] | 449 | self._loadButton = self.addButton(xstr("flightsel_load"),
|
---|
| 450 | sensitive = True,
|
---|
| 451 | tooltip = xstr("flightsel_load_tooltip"))
|
---|
| 452 | self._loadButton.connect("clicked", self._loadButtonClicked)
|
---|
| 453 | self._loadDialog = None
|
---|
[347] | 454 |
|
---|
[107] | 455 | self._button = self.addNextButton(sensitive = False,
|
---|
| 456 | clicked = self._forwardClicked)
|
---|
[48] | 457 |
|
---|
[184] | 458 | self._flights = []
|
---|
| 459 |
|
---|
[48] | 460 | def activate(self):
|
---|
| 461 | """Fill the flight list."""
|
---|
[70] | 462 | self._flightList.set_sensitive(True)
|
---|
[208] | 463 | self._loadButton.set_sensitive(True)
|
---|
[216] | 464 | self._refreshButton.set_sensitive(self._wizard.loggedIn)
|
---|
[208] | 465 | self._buildFlights()
|
---|
[347] | 466 |
|
---|
[208] | 467 | def finalize(self):
|
---|
| 468 | """Finalize the page."""
|
---|
| 469 | self._flightList.set_sensitive(False)
|
---|
| 470 | self._loadButton.set_sensitive(False)
|
---|
| 471 | self._refreshButton.set_sensitive(False)
|
---|
| 472 |
|
---|
| 473 | def _buildFlights(self):
|
---|
| 474 | """Rebuild the flights from the login result."""
|
---|
[184] | 475 | self._flights = []
|
---|
[70] | 476 | self._listStore.clear()
|
---|
[215] | 477 | if self._wizard.loggedIn:
|
---|
| 478 | for flight in self._wizard.loginResult.flights:
|
---|
| 479 | self._addFlight(flight)
|
---|
[48] | 480 |
|
---|
[184] | 481 | def _addFlight(self, flight):
|
---|
| 482 | """Add the given file to the list of flights."""
|
---|
| 483 | self._flights.append(flight)
|
---|
| 484 | self._listStore.append([str(flight.departureTime),
|
---|
| 485 | flight.callsign,
|
---|
| 486 | flight.departureICAO,
|
---|
| 487 | flight.arrivalICAO])
|
---|
| 488 |
|
---|
[214] | 489 | def _saveClicked(self, button):
|
---|
| 490 | """Called when the Save flight button is clicked."""
|
---|
[277] | 491 | self._saveSelected()
|
---|
| 492 |
|
---|
| 493 | def _saveSelected(self):
|
---|
| 494 | """Save the selected flight."""
|
---|
[214] | 495 | flight = self._getSelectedFlight()
|
---|
| 496 | date = flight.departureTime.date()
|
---|
| 497 | name = "%04d-%02d-%02d %s %s-%s.vaflight" % \
|
---|
| 498 | (date.year, date.month, date.day, flight.callsign,
|
---|
| 499 | flight.departureICAO, flight.arrivalICAO)
|
---|
| 500 |
|
---|
| 501 | dialog = self._getSaveDialog()
|
---|
| 502 | dialog.set_current_name(name)
|
---|
| 503 | dialog.show_all()
|
---|
| 504 | response = dialog.run()
|
---|
| 505 | dialog.hide()
|
---|
| 506 |
|
---|
| 507 | if response==RESPONSETYPE_OK:
|
---|
[233] | 508 | fileName = text2unicode(dialog.get_filename())
|
---|
[214] | 509 | print "Saving", fileName
|
---|
| 510 | try:
|
---|
| 511 | with open(fileName, "wt") as f:
|
---|
| 512 | flight.writeIntoFile(f)
|
---|
| 513 | except Exception, e:
|
---|
[401] | 514 | print "Failed to save flight:", util.utf2unicode(str(e))
|
---|
[214] | 515 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 516 | type = MESSAGETYPE_ERROR,
|
---|
| 517 | message_format =
|
---|
| 518 | xstr("flightsel_save_failed"))
|
---|
| 519 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 520 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 521 | secondary = xstr("flightsel_save_failed_sec")
|
---|
| 522 | dialog.format_secondary_markup(secondary)
|
---|
| 523 | dialog.run()
|
---|
| 524 | dialog.hide()
|
---|
[347] | 525 |
|
---|
[208] | 526 | def _refreshClicked(self, button):
|
---|
| 527 | """Called when the refresh button is clicked."""
|
---|
| 528 | self._wizard.reloadFlights(self._refreshCallback)
|
---|
| 529 |
|
---|
| 530 | def _refreshCallback(self, returned, result):
|
---|
| 531 | """Callback for the refresh."""
|
---|
| 532 | if returned and result.loggedIn:
|
---|
| 533 | self._buildFlights()
|
---|
| 534 |
|
---|
[48] | 535 | def _selectionChanged(self, selection):
|
---|
| 536 | """Called when the selection is changed."""
|
---|
[214] | 537 | selected = selection.count_selected_rows()==1
|
---|
| 538 | self._saveButton.set_sensitive(selected)
|
---|
| 539 | self._button.set_sensitive(selected)
|
---|
[42] | 540 |
|
---|
[184] | 541 | def _loadButtonClicked(self, loadButton):
|
---|
| 542 | """Called when the load a flight button is clicked."""
|
---|
| 543 | dialog = self._getLoadDialog()
|
---|
| 544 | dialog.show_all()
|
---|
| 545 | response = dialog.run()
|
---|
| 546 | dialog.hide()
|
---|
| 547 |
|
---|
| 548 | if response==RESPONSETYPE_OK:
|
---|
[233] | 549 | fileName = text2unicode(dialog.get_filename())
|
---|
[184] | 550 | print "Loading", fileName
|
---|
| 551 | bookedFlight = web.BookedFlight()
|
---|
| 552 | try:
|
---|
| 553 | with open(fileName, "rt") as f:
|
---|
| 554 | bookedFlight.readFromFile(f)
|
---|
[347] | 555 | self._addFlight(bookedFlight)
|
---|
[184] | 556 | except Exception, e:
|
---|
[401] | 557 | print "Failed to load flight:", util.utf2unicode(str(e))
|
---|
[184] | 558 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 559 | type = MESSAGETYPE_ERROR,
|
---|
| 560 | message_format =
|
---|
| 561 | xstr("flightsel_load_failed"))
|
---|
| 562 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 563 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 564 | secondary = xstr("flightsel_load_failed_sec")
|
---|
| 565 | dialog.format_secondary_markup(secondary)
|
---|
| 566 | dialog.run()
|
---|
[347] | 567 | dialog.hide()
|
---|
| 568 |
|
---|
[51] | 569 | def _forwardClicked(self, button):
|
---|
| 570 | """Called when the forward button was clicked."""
|
---|
[94] | 571 | if self._completed:
|
---|
[70] | 572 | self._wizard.jumpPage(self._nextDistance, finalize = False)
|
---|
| 573 | else:
|
---|
[277] | 574 | self._flightSelected()
|
---|
| 575 |
|
---|
| 576 | def _rowActivated(self, flightList, path, column):
|
---|
| 577 | """Called when a row is activated."""
|
---|
| 578 | if not self._completed:
|
---|
| 579 | self._flightSelected()
|
---|
| 580 |
|
---|
| 581 | def _flightSelected(self):
|
---|
| 582 | """Called when a flight has been selected."""
|
---|
| 583 | flight = self._getSelectedFlight()
|
---|
| 584 | self._wizard._bookedFlight = flight
|
---|
| 585 | self._wizard.gui.enableFlightInfo()
|
---|
[347] | 586 |
|
---|
[277] | 587 | self._updateDepartureGate()
|
---|
[214] | 588 |
|
---|
| 589 | def _getSelectedFlight(self):
|
---|
| 590 | """Get the currently selected flight."""
|
---|
| 591 | selection = self._flightList.get_selection()
|
---|
| 592 | (listStore, iter) = selection.get_selected()
|
---|
| 593 | path = listStore.get_path(iter)
|
---|
| 594 | [index] = path.get_indices() if pygobject else path
|
---|
[347] | 595 |
|
---|
[214] | 596 | return self._flights[index]
|
---|
[277] | 597 |
|
---|
| 598 | def _listButtonPressed(self, widget, event):
|
---|
| 599 | """Called when a mouse button is pressed on the flight list."""
|
---|
| 600 | if event.type!=EVENT_BUTTON_PRESS or event.button!=3:
|
---|
| 601 | return
|
---|
| 602 |
|
---|
| 603 | (path, _, _, _) = self._flightList.get_path_at_pos(int(event.x),
|
---|
| 604 | int(event.y))
|
---|
| 605 | selection = self._flightList.get_selection()
|
---|
| 606 | selection.unselect_all()
|
---|
| 607 | selection.select_path(path)
|
---|
| 608 |
|
---|
| 609 | menu = self._getListPopupMenu()
|
---|
| 610 | if pygobject:
|
---|
| 611 | menu.popup(None, None, None, None, event.button, event.time)
|
---|
| 612 | else:
|
---|
| 613 | menu.popup(None, None, None, event.button, event.time)
|
---|
[347] | 614 |
|
---|
[51] | 615 | def _updateDepartureGate(self):
|
---|
| 616 | """Update the departure gate for the booked flight."""
|
---|
| 617 | flight = self._wizard._bookedFlight
|
---|
[184] | 618 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 619 | self._wizard.loggedIn and not self._wizard.entranceExam:
|
---|
[136] | 620 | if flight.departureICAO=="LHBP":
|
---|
| 621 | self._wizard.getFleet(self._fleetRetrieved)
|
---|
| 622 | else:
|
---|
| 623 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 624 | flight.tailNumber,
|
---|
| 625 | const.PLANE_AWAY)
|
---|
[51] | 626 | else:
|
---|
[136] | 627 | self._nextDistance = 2
|
---|
| 628 | self._wizard.jumpPage(2)
|
---|
[347] | 629 |
|
---|
[51] | 630 | def _fleetRetrieved(self, fleet):
|
---|
| 631 | """Called when the fleet has been retrieved."""
|
---|
| 632 | if fleet is None:
|
---|
[70] | 633 | self._nextDistance = 2
|
---|
[51] | 634 | self._wizard.jumpPage(2)
|
---|
| 635 | else:
|
---|
| 636 | plane = fleet[self._wizard._bookedFlight.tailNumber]
|
---|
| 637 | if plane is None:
|
---|
[70] | 638 | self._nextDistance = 2
|
---|
[51] | 639 | self._wizard.jumpPage(2)
|
---|
[70] | 640 | elif plane.gateNumber is not None and \
|
---|
| 641 | not fleet.isGateConflicting(plane):
|
---|
[51] | 642 | self._wizard._departureGate = plane.gateNumber
|
---|
[70] | 643 | self._nextDistance = 2
|
---|
[51] | 644 | self._wizard.jumpPage(2)
|
---|
| 645 | else:
|
---|
[70] | 646 | self._nextDistance = 1
|
---|
[51] | 647 | self._wizard.nextPage()
|
---|
[130] | 648 |
|
---|
| 649 | def _planeUpdated(self, success):
|
---|
| 650 | """Callback for the plane updating."""
|
---|
| 651 | self._nextDistance = 2
|
---|
| 652 | self._wizard.jumpPage(2)
|
---|
[184] | 653 |
|
---|
[214] | 654 | def _getSaveDialog(self):
|
---|
| 655 | """Get the dialog to load a flight file."""
|
---|
| 656 | if self._saveDialog is not None:
|
---|
| 657 | return self._saveDialog
|
---|
[347] | 658 |
|
---|
[214] | 659 | gui = self._wizard.gui
|
---|
| 660 | dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
| 661 | xstr("flightsel_save_title"),
|
---|
| 662 | action = FILE_CHOOSER_ACTION_SAVE,
|
---|
| 663 | buttons = (gtk.STOCK_CANCEL,
|
---|
| 664 | RESPONSETYPE_CANCEL,
|
---|
| 665 | gtk.STOCK_OK, RESPONSETYPE_OK),
|
---|
| 666 | parent = gui.mainWindow)
|
---|
[347] | 667 | dialog.set_modal(True)
|
---|
[214] | 668 | dialog.set_do_overwrite_confirmation(True)
|
---|
| 669 |
|
---|
| 670 | filter = gtk.FileFilter()
|
---|
| 671 | filter.set_name(xstr("flightsel_filter_flights"))
|
---|
| 672 | filter.add_pattern("*.vaflight")
|
---|
| 673 | dialog.add_filter(filter)
|
---|
[347] | 674 |
|
---|
[214] | 675 | filter = gtk.FileFilter()
|
---|
| 676 | filter.set_name(xstr("file_filter_all"))
|
---|
| 677 | filter.add_pattern("*.*")
|
---|
| 678 | dialog.add_filter(filter)
|
---|
| 679 |
|
---|
| 680 | self._saveDialog = dialog
|
---|
[347] | 681 |
|
---|
| 682 | return dialog
|
---|
| 683 |
|
---|
[184] | 684 | def _getLoadDialog(self):
|
---|
| 685 | """Get the dialog to load a flight file."""
|
---|
| 686 | if self._loadDialog is not None:
|
---|
| 687 | return self._loadDialog
|
---|
[347] | 688 |
|
---|
[184] | 689 | gui = self._wizard.gui
|
---|
| 690 | dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
| 691 | xstr("flightsel_load_title"),
|
---|
| 692 | action = FILE_CHOOSER_ACTION_OPEN,
|
---|
| 693 | buttons = (gtk.STOCK_CANCEL,
|
---|
| 694 | RESPONSETYPE_CANCEL,
|
---|
| 695 | gtk.STOCK_OK, RESPONSETYPE_OK),
|
---|
| 696 | parent = gui.mainWindow)
|
---|
[347] | 697 | dialog.set_modal(True)
|
---|
[184] | 698 |
|
---|
| 699 | filter = gtk.FileFilter()
|
---|
| 700 | filter.set_name(xstr("flightsel_filter_flights"))
|
---|
| 701 | filter.add_pattern("*.vaflight")
|
---|
| 702 | dialog.add_filter(filter)
|
---|
[347] | 703 |
|
---|
[184] | 704 | filter = gtk.FileFilter()
|
---|
| 705 | filter.set_name(xstr("file_filter_all"))
|
---|
| 706 | filter.add_pattern("*.*")
|
---|
| 707 | dialog.add_filter(filter)
|
---|
| 708 |
|
---|
| 709 | self._loadDialog = dialog
|
---|
[347] | 710 |
|
---|
| 711 | return dialog
|
---|
[277] | 712 |
|
---|
| 713 | def _getListPopupMenu(self):
|
---|
| 714 | """Get the flight list popup menu."""
|
---|
| 715 | if self._flightListPopupMenu is None:
|
---|
| 716 | menu = gtk.Menu()
|
---|
| 717 |
|
---|
| 718 | menuItem = gtk.MenuItem()
|
---|
| 719 | menuItem.set_label(xstr("flightsel_popup_select"))
|
---|
| 720 | menuItem.set_use_underline(True)
|
---|
| 721 | menuItem.connect("activate", self._popupSelect)
|
---|
| 722 | menuItem.show()
|
---|
| 723 |
|
---|
| 724 | menu.append(menuItem)
|
---|
[347] | 725 |
|
---|
[277] | 726 | menuItem = gtk.MenuItem()
|
---|
| 727 | menuItem.set_label(xstr("flightsel_popup_save"))
|
---|
| 728 | menuItem.set_use_underline(True)
|
---|
| 729 | menuItem.connect("activate", self._popupSave)
|
---|
| 730 | menuItem.show()
|
---|
| 731 |
|
---|
| 732 | menu.append(menuItem)
|
---|
| 733 |
|
---|
| 734 | self._flightListPopupMenu = menu
|
---|
| 735 |
|
---|
| 736 | return self._flightListPopupMenu
|
---|
| 737 |
|
---|
| 738 | def _popupSelect(self, menuItem):
|
---|
| 739 | """Called when the Select menu item is activated in the popup menu."""
|
---|
| 740 | if not self._completed:
|
---|
| 741 | self._flightSelected()
|
---|
[347] | 742 |
|
---|
[277] | 743 | def _popupSave(self, menuItem):
|
---|
| 744 | """Called when the Save menu item is activated in the popup menu."""
|
---|
| 745 | if not self._completed:
|
---|
| 746 | self._saveSelected()
|
---|
[347] | 747 |
|
---|
[51] | 748 | #-----------------------------------------------------------------------------
|
---|
| 749 |
|
---|
| 750 | class GateSelectionPage(Page):
|
---|
| 751 | """Page to select a free gate at LHBP.
|
---|
| 752 | This page should be displayed only if we have fleet information!."""
|
---|
| 753 | def __init__(self, wizard):
|
---|
| 754 | """Construct the gate selection page."""
|
---|
[107] | 755 | super(GateSelectionPage, self).__init__(wizard, xstr("gatesel_title"),
|
---|
| 756 | xstr("gatesel_help"))
|
---|
[347] | 757 |
|
---|
[51] | 758 | self._listStore = gtk.ListStore(str)
|
---|
| 759 | self._gateList = gtk.TreeView(self._listStore)
|
---|
| 760 | column = gtk.TreeViewColumn(None, gtk.CellRendererText(),
|
---|
| 761 | text = 0)
|
---|
| 762 | column.set_expand(True)
|
---|
| 763 | self._gateList.append_column(column)
|
---|
| 764 | self._gateList.set_headers_visible(False)
|
---|
[278] | 765 | self._gateList.connect("row-activated", self._rowActivated)
|
---|
[51] | 766 |
|
---|
| 767 | gateSelection = self._gateList.get_selection()
|
---|
| 768 | gateSelection.connect("changed", self._selectionChanged)
|
---|
| 769 |
|
---|
| 770 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 771 | scrolledWindow.add(self._gateList)
|
---|
| 772 | scrolledWindow.set_size_request(50, -1)
|
---|
| 773 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 774 | else gtk.POLICY_AUTOMATIC,
|
---|
[69] | 775 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 776 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 777 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 778 | else gtk.SHADOW_IN)
|
---|
[51] | 779 |
|
---|
| 780 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
| 781 | alignment.add(scrolledWindow)
|
---|
| 782 |
|
---|
[347] | 783 | self.setMainWidget(alignment)
|
---|
[51] | 784 |
|
---|
[208] | 785 | self.addCancelFlightButton()
|
---|
| 786 |
|
---|
[107] | 787 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[347] | 788 |
|
---|
[107] | 789 | self._button = self.addNextButton(sensitive = False,
|
---|
| 790 | clicked = self._forwardClicked)
|
---|
[51] | 791 |
|
---|
| 792 | def activate(self):
|
---|
| 793 | """Fill the gate list."""
|
---|
| 794 | self._listStore.clear()
|
---|
[70] | 795 | self._gateList.set_sensitive(True)
|
---|
[51] | 796 | occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
| 797 | for gateNumber in const.lhbpGateNumbers:
|
---|
| 798 | if gateNumber not in occupiedGateNumbers:
|
---|
| 799 | self._listStore.append([gateNumber])
|
---|
| 800 |
|
---|
[70] | 801 | def finalize(self):
|
---|
| 802 | """Finalize the page."""
|
---|
| 803 | self._gateList.set_sensitive(False)
|
---|
| 804 |
|
---|
[51] | 805 | def _selectionChanged(self, selection):
|
---|
| 806 | """Called when the selection is changed."""
|
---|
| 807 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
| 808 |
|
---|
[73] | 809 | def _backClicked(self, button):
|
---|
| 810 | """Called when the Back button is pressed."""
|
---|
| 811 | self.goBack()
|
---|
| 812 |
|
---|
[51] | 813 | def _forwardClicked(self, button):
|
---|
| 814 | """Called when the forward button is clicked."""
|
---|
[94] | 815 | if not self._completed:
|
---|
[278] | 816 | self._gateSelected()
|
---|
[130] | 817 | else:
|
---|
| 818 | self._wizard.nextPage()
|
---|
[51] | 819 |
|
---|
[278] | 820 | def _rowActivated(self, flightList, path, column):
|
---|
| 821 | """Called when a row is activated."""
|
---|
| 822 | if not self._completed:
|
---|
| 823 | self._gateSelected()
|
---|
| 824 |
|
---|
| 825 | def _gateSelected(self):
|
---|
| 826 | """Called when a gate has been selected."""
|
---|
| 827 | selection = self._gateList.get_selection()
|
---|
| 828 | (listStore, iter) = selection.get_selected()
|
---|
| 829 | (gateNumber,) = listStore.get(iter, 0)
|
---|
| 830 |
|
---|
| 831 | self._wizard._departureGate = gateNumber
|
---|
| 832 |
|
---|
| 833 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 834 | self._wizard._bookedFlight.tailNumber,
|
---|
[347] | 835 | const.PLANE_HOME, gateNumber)
|
---|
[278] | 836 |
|
---|
[51] | 837 | def _planeUpdated(self, success):
|
---|
| 838 | """Callback for the plane updating call."""
|
---|
| 839 | if success is None or success:
|
---|
| 840 | self._wizard.nextPage()
|
---|
| 841 | else:
|
---|
[105] | 842 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 843 | type = MESSAGETYPE_ERROR,
|
---|
[107] | 844 | message_format = xstr("gatesel_conflict"))
|
---|
[124] | 845 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
[105] | 846 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
[107] | 847 | dialog.format_secondary_markup(xstr("gatesel_conflict_sec"))
|
---|
[51] | 848 | dialog.run()
|
---|
| 849 | dialog.hide()
|
---|
| 850 |
|
---|
[126] | 851 | self._wizard.getFleet(self._fleetRetrieved)
|
---|
[51] | 852 |
|
---|
| 853 | def _fleetRetrieved(self, fleet):
|
---|
| 854 | """Called when the fleet has been retrieved."""
|
---|
| 855 | if fleet is None:
|
---|
| 856 | self._wizard.nextPage()
|
---|
| 857 | else:
|
---|
| 858 | self.activate()
|
---|
[347] | 859 |
|
---|
[51] | 860 | #-----------------------------------------------------------------------------
|
---|
| 861 |
|
---|
| 862 | class ConnectPage(Page):
|
---|
| 863 | """Page which displays the departure airport and gate (if at LHBP)."""
|
---|
| 864 | def __init__(self, wizard):
|
---|
| 865 | """Construct the connect page."""
|
---|
[78] | 866 | help = "Load the aircraft below into the simulator and park it\n" \
|
---|
| 867 | "at the given airport, at the gate below, if present.\n\n" \
|
---|
[51] | 868 | "Then press the Connect button to connect to the simulator."
|
---|
[94] | 869 | completedHelp = "The basic data of your flight can be read below."
|
---|
[107] | 870 | super(ConnectPage, self).__init__(wizard, xstr("connect_title"),
|
---|
| 871 | xstr("connect_help"),
|
---|
| 872 | completedHelp = xstr("connect_chelp"))
|
---|
[347] | 873 |
|
---|
[51] | 874 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 875 | xscale = 0.0, yscale = 0.0)
|
---|
| 876 |
|
---|
[78] | 877 | table = gtk.Table(5, 2)
|
---|
[51] | 878 | table.set_row_spacings(4)
|
---|
| 879 | table.set_col_spacings(16)
|
---|
| 880 | table.set_homogeneous(True)
|
---|
| 881 | alignment.add(table)
|
---|
| 882 | self.setMainWidget(alignment)
|
---|
| 883 |
|
---|
| 884 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 885 | label = gtk.Label(xstr("connect_flightno"))
|
---|
[51] | 886 | labelAlignment.add(label)
|
---|
| 887 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 888 |
|
---|
| 889 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[78] | 890 | self._flightNumber = gtk.Label()
|
---|
[191] | 891 | self._flightNumber.set_width_chars(9)
|
---|
[78] | 892 | self._flightNumber.set_alignment(0.0, 0.5)
|
---|
| 893 | labelAlignment.add(self._flightNumber)
|
---|
| 894 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
| 895 |
|
---|
| 896 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 897 | label = gtk.Label(xstr("connect_acft"))
|
---|
[78] | 898 | labelAlignment.add(label)
|
---|
| 899 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 900 |
|
---|
| 901 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 902 | self._aircraft = gtk.Label()
|
---|
| 903 | self._aircraft.set_width_chars(25)
|
---|
| 904 | self._aircraft.set_alignment(0.0, 0.5)
|
---|
| 905 | labelAlignment.add(self._aircraft)
|
---|
| 906 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
| 907 |
|
---|
| 908 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 909 | label = gtk.Label(xstr("connect_tailno"))
|
---|
[78] | 910 | labelAlignment.add(label)
|
---|
| 911 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
| 912 |
|
---|
| 913 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 914 | self._tailNumber = gtk.Label()
|
---|
[80] | 915 | self._tailNumber.set_width_chars(10)
|
---|
[78] | 916 | self._tailNumber.set_alignment(0.0, 0.5)
|
---|
| 917 | labelAlignment.add(self._tailNumber)
|
---|
| 918 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
| 919 |
|
---|
| 920 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 921 | label = gtk.Label(xstr("connect_airport"))
|
---|
[78] | 922 | labelAlignment.add(label)
|
---|
| 923 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
| 924 |
|
---|
| 925 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[51] | 926 | self._departureICAO = gtk.Label()
|
---|
[80] | 927 | self._departureICAO.set_width_chars(6)
|
---|
[51] | 928 | self._departureICAO.set_alignment(0.0, 0.5)
|
---|
| 929 | labelAlignment.add(self._departureICAO)
|
---|
[78] | 930 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
[51] | 931 |
|
---|
| 932 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 933 | label = gtk.Label(xstr("connect_gate"))
|
---|
[51] | 934 | labelAlignment.add(label)
|
---|
[78] | 935 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
[51] | 936 |
|
---|
| 937 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 938 | self._departureGate = gtk.Label()
|
---|
| 939 | self._departureGate.set_width_chars(5)
|
---|
| 940 | self._departureGate.set_alignment(0.0, 0.5)
|
---|
| 941 | labelAlignment.add(self._departureGate)
|
---|
[78] | 942 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
[51] | 943 |
|
---|
[208] | 944 | self.addCancelFlightButton()
|
---|
| 945 |
|
---|
[107] | 946 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[70] | 947 |
|
---|
[107] | 948 | self._button = self.addButton(xstr("button_connect"), default = True,
|
---|
| 949 | tooltip = xstr("button_connect_tooltip"))
|
---|
[70] | 950 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[51] | 951 |
|
---|
| 952 | def activate(self):
|
---|
[60] | 953 | """Setup the departure information."""
|
---|
[107] | 954 | self._button.set_label(xstr("button_connect"))
|
---|
[70] | 955 | self._button.set_use_underline(True)
|
---|
[107] | 956 | self._button.set_tooltip_text(xstr("button_connect_tooltip"))
|
---|
[70] | 957 | self._button.disconnect(self._clickedID)
|
---|
| 958 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[78] | 959 |
|
---|
| 960 | bookedFlight = self._wizard._bookedFlight
|
---|
| 961 |
|
---|
| 962 | self._flightNumber.set_markup("<b>" + bookedFlight.callsign + "</b>")
|
---|
| 963 |
|
---|
[191] | 964 | aircraftType = aircraftNames[bookedFlight.aircraftType]
|
---|
[78] | 965 | self._aircraft.set_markup("<b>" + aircraftType + "</b>")
|
---|
[347] | 966 |
|
---|
[78] | 967 | self._tailNumber.set_markup("<b>" + bookedFlight.tailNumber + "</b>")
|
---|
| 968 |
|
---|
| 969 | icao = bookedFlight.departureICAO
|
---|
[51] | 970 | self._departureICAO.set_markup("<b>" + icao + "</b>")
|
---|
| 971 | gate = self._wizard._departureGate
|
---|
| 972 | if gate!="-":
|
---|
| 973 | gate = "<b>" + gate + "</b>"
|
---|
| 974 | self._departureGate.set_markup(gate)
|
---|
| 975 |
|
---|
[70] | 976 | def finalize(self):
|
---|
| 977 | """Finalize the page."""
|
---|
[107] | 978 | self._button.set_label(xstr("button_next"))
|
---|
| 979 | self._button.set_use_underline(True)
|
---|
| 980 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
[70] | 981 | self._button.disconnect(self._clickedID)
|
---|
| 982 | self._clickedID = self._button.connect("clicked", self._forwardClicked)
|
---|
| 983 |
|
---|
| 984 | def _backClicked(self, button):
|
---|
| 985 | """Called when the Back button is pressed."""
|
---|
| 986 | self.goBack()
|
---|
| 987 |
|
---|
[51] | 988 | def _connectClicked(self, button):
|
---|
| 989 | """Called when the Connect button is pressed."""
|
---|
| 990 | self._wizard._connectSimulator()
|
---|
| 991 |
|
---|
[70] | 992 | def _forwardClicked(self, button):
|
---|
| 993 | """Called when the Forward button is pressed."""
|
---|
| 994 | self._wizard.nextPage()
|
---|
| 995 |
|
---|
[42] | 996 | #-----------------------------------------------------------------------------
|
---|
| 997 |
|
---|
[59] | 998 | class PayloadPage(Page):
|
---|
| 999 | """Page to allow setting up the payload."""
|
---|
| 1000 | def __init__(self, wizard):
|
---|
| 1001 | """Construct the page."""
|
---|
[107] | 1002 | super(PayloadPage, self).__init__(wizard, xstr("payload_title"),
|
---|
| 1003 | xstr("payload_help"),
|
---|
| 1004 | completedHelp = xstr("payload_chelp"))
|
---|
[59] | 1005 |
|
---|
[60] | 1006 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1007 | xscale = 0.0, yscale = 0.0)
|
---|
| 1008 |
|
---|
| 1009 | table = gtk.Table(7, 3)
|
---|
| 1010 | table.set_row_spacings(4)
|
---|
| 1011 | table.set_col_spacings(16)
|
---|
| 1012 | table.set_homogeneous(False)
|
---|
| 1013 | alignment.add(table)
|
---|
| 1014 | self.setMainWidget(alignment)
|
---|
| 1015 |
|
---|
[107] | 1016 | label = gtk.Label(xstr("payload_crew"))
|
---|
[309] | 1017 | label.set_use_underline(True)
|
---|
[60] | 1018 | label.set_alignment(0.0, 0.5)
|
---|
| 1019 | table.attach(label, 0, 1, 0, 1)
|
---|
| 1020 |
|
---|
[303] | 1021 | self._numCrew = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1022 | self._numCrew.set_width_chars(6)
|
---|
[303] | 1023 | self._numCrew.connect("integer-changed", self._weightChanged)
|
---|
| 1024 | self._numCrew.set_tooltip_text(xstr("payload_crew_tooltip"))
|
---|
[60] | 1025 | table.attach(self._numCrew, 1, 2, 0, 1)
|
---|
[303] | 1026 | label.set_mnemonic_widget(self._numCrew)
|
---|
[347] | 1027 |
|
---|
[107] | 1028 | label = gtk.Label(xstr("payload_pax"))
|
---|
[309] | 1029 | label.set_use_underline(True)
|
---|
[60] | 1030 | label.set_alignment(0.0, 0.5)
|
---|
| 1031 | table.attach(label, 0, 1, 1, 2)
|
---|
| 1032 |
|
---|
[347] | 1033 | self._numPassengers = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1034 | self._numPassengers.set_width_chars(6)
|
---|
[303] | 1035 | self._numPassengers.connect("integer-changed", self._weightChanged)
|
---|
| 1036 | self._numPassengers.set_tooltip_text(xstr("payload_pax_tooltip"))
|
---|
[60] | 1037 | table.attach(self._numPassengers, 1, 2, 1, 2)
|
---|
[303] | 1038 | label.set_mnemonic_widget(self._numPassengers)
|
---|
[347] | 1039 |
|
---|
[107] | 1040 | label = gtk.Label(xstr("payload_bag"))
|
---|
[309] | 1041 | label.set_use_underline(True)
|
---|
[60] | 1042 | label.set_alignment(0.0, 0.5)
|
---|
| 1043 | table.attach(label, 0, 1, 2, 3)
|
---|
| 1044 |
|
---|
[303] | 1045 | self._bagWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1046 | self._bagWeight.set_width_chars(6)
|
---|
[303] | 1047 | self._bagWeight.connect("integer-changed", self._weightChanged)
|
---|
| 1048 | self._bagWeight.set_tooltip_text(xstr("payload_bag_tooltip"))
|
---|
[60] | 1049 | table.attach(self._bagWeight, 1, 2, 2, 3)
|
---|
[303] | 1050 | label.set_mnemonic_widget(self._bagWeight)
|
---|
[60] | 1051 |
|
---|
| 1052 | table.attach(gtk.Label("kg"), 2, 3, 2, 3)
|
---|
[347] | 1053 |
|
---|
[107] | 1054 | label = gtk.Label(xstr("payload_cargo"))
|
---|
[60] | 1055 | label.set_use_underline(True)
|
---|
| 1056 | label.set_alignment(0.0, 0.5)
|
---|
| 1057 | table.attach(label, 0, 1, 3, 4)
|
---|
| 1058 |
|
---|
[84] | 1059 | self._cargoWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1060 | self._cargoWeight.set_width_chars(6)
|
---|
[303] | 1061 | self._cargoWeight.connect("integer-changed", self._weightChanged)
|
---|
[107] | 1062 | self._cargoWeight.set_tooltip_text(xstr("payload_cargo_tooltip"))
|
---|
[60] | 1063 | table.attach(self._cargoWeight, 1, 2, 3, 4)
|
---|
| 1064 | label.set_mnemonic_widget(self._cargoWeight)
|
---|
| 1065 |
|
---|
| 1066 | table.attach(gtk.Label("kg"), 2, 3, 3, 4)
|
---|
[347] | 1067 |
|
---|
[107] | 1068 | label = gtk.Label(xstr("payload_mail"))
|
---|
[309] | 1069 | label.set_use_underline(True)
|
---|
[60] | 1070 | label.set_alignment(0.0, 0.5)
|
---|
| 1071 | table.attach(label, 0, 1, 4, 5)
|
---|
| 1072 |
|
---|
[303] | 1073 | self._mailWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 1074 | self._mailWeight.set_width_chars(6)
|
---|
[303] | 1075 | self._mailWeight.connect("integer-changed", self._weightChanged)
|
---|
| 1076 | self._mailWeight.set_tooltip_text(xstr("payload_mail_tooltip"))
|
---|
[60] | 1077 | table.attach(self._mailWeight, 1, 2, 4, 5)
|
---|
[303] | 1078 | label.set_mnemonic_widget(self._mailWeight)
|
---|
[60] | 1079 |
|
---|
| 1080 | table.attach(gtk.Label("kg"), 2, 3, 4, 5)
|
---|
[347] | 1081 |
|
---|
[107] | 1082 | label = gtk.Label("<b>" + xstr("payload_zfw") + "</b>")
|
---|
[60] | 1083 | label.set_alignment(0.0, 0.5)
|
---|
| 1084 | label.set_use_markup(True)
|
---|
| 1085 | table.attach(label, 0, 1, 5, 6)
|
---|
| 1086 |
|
---|
| 1087 | self._calculatedZFW = gtk.Label()
|
---|
| 1088 | self._calculatedZFW.set_width_chars(6)
|
---|
| 1089 | self._calculatedZFW.set_alignment(1.0, 0.5)
|
---|
| 1090 | table.attach(self._calculatedZFW, 1, 2, 5, 6)
|
---|
| 1091 |
|
---|
| 1092 | table.attach(gtk.Label("kg"), 2, 3, 5, 6)
|
---|
| 1093 |
|
---|
[107] | 1094 | self._zfwButton = gtk.Button(xstr("payload_fszfw"))
|
---|
[70] | 1095 | self._zfwButton.set_use_underline(True)
|
---|
| 1096 | self._zfwButton.connect("clicked", self._zfwRequested)
|
---|
[107] | 1097 | self._zfwButton.set_tooltip_text(xstr("payload_fszfw_tooltip"))
|
---|
[70] | 1098 | table.attach(self._zfwButton, 0, 1, 6, 7)
|
---|
[60] | 1099 |
|
---|
| 1100 | self._simulatorZFW = gtk.Label("-")
|
---|
| 1101 | self._simulatorZFW.set_width_chars(6)
|
---|
| 1102 | self._simulatorZFW.set_alignment(1.0, 0.5)
|
---|
| 1103 | table.attach(self._simulatorZFW, 1, 2, 6, 7)
|
---|
| 1104 | self._simulatorZFWValue = None
|
---|
| 1105 |
|
---|
| 1106 | table.attach(gtk.Label("kg"), 2, 3, 6, 7)
|
---|
| 1107 |
|
---|
[208] | 1108 | self.addCancelFlightButton()
|
---|
[107] | 1109 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1110 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[60] | 1111 |
|
---|
[97] | 1112 | @property
|
---|
[303] | 1113 | def numCrew(self):
|
---|
| 1114 | """The number of the crew members on the flight."""
|
---|
| 1115 | return self._numCrew.get_int()
|
---|
[347] | 1116 |
|
---|
[303] | 1117 | @property
|
---|
| 1118 | def numPassengers(self):
|
---|
| 1119 | """The number of the passengers on the flight."""
|
---|
| 1120 | return self._numPassengers.get_int()
|
---|
[347] | 1121 |
|
---|
[303] | 1122 | @property
|
---|
| 1123 | def bagWeight(self):
|
---|
| 1124 | """Get the bag weight entered."""
|
---|
| 1125 | return self._bagWeight.get_int()
|
---|
| 1126 |
|
---|
| 1127 | @property
|
---|
[97] | 1128 | def cargoWeight(self):
|
---|
| 1129 | """Get the cargo weight entered."""
|
---|
| 1130 | return self._cargoWeight.get_int()
|
---|
| 1131 |
|
---|
[303] | 1132 | @property
|
---|
| 1133 | def mailWeight(self):
|
---|
| 1134 | """Get the bag weight entered."""
|
---|
| 1135 | return self._mailWeight.get_int()
|
---|
| 1136 |
|
---|
[60] | 1137 | def activate(self):
|
---|
| 1138 | """Setup the information."""
|
---|
| 1139 | bookedFlight = self._wizard._bookedFlight
|
---|
[303] | 1140 |
|
---|
| 1141 | self._numCrew.set_int(bookedFlight.numCrew)
|
---|
| 1142 | self._numCrew.set_sensitive(True)
|
---|
| 1143 | self._numPassengers.set_int(bookedFlight.numPassengers)
|
---|
| 1144 | self._numPassengers.set_sensitive(True)
|
---|
| 1145 |
|
---|
| 1146 | self._bagWeight.set_int(bookedFlight.bagWeight)
|
---|
| 1147 | self._bagWeight.set_sensitive(True)
|
---|
[84] | 1148 | self._cargoWeight.set_int(bookedFlight.cargoWeight)
|
---|
[70] | 1149 | self._cargoWeight.set_sensitive(True)
|
---|
[303] | 1150 | self._mailWeight.set_int(bookedFlight.mailWeight)
|
---|
| 1151 | self._mailWeight.set_sensitive(True)
|
---|
[347] | 1152 |
|
---|
[92] | 1153 | self._simulatorZFW.set_text("-")
|
---|
| 1154 | self._simulatorZFWValue = None
|
---|
[70] | 1155 | self._zfwButton.set_sensitive(True)
|
---|
[60] | 1156 | self._updateCalculatedZFW()
|
---|
[59] | 1157 |
|
---|
[70] | 1158 | def finalize(self):
|
---|
| 1159 | """Finalize the payload page."""
|
---|
[303] | 1160 | self._numCrew.set_sensitive(False)
|
---|
| 1161 | self._numPassengers.set_sensitive(False)
|
---|
| 1162 | self._bagWeight.set_sensitive(False)
|
---|
[70] | 1163 | self._cargoWeight.set_sensitive(False)
|
---|
[303] | 1164 | self._mailWeight.set_sensitive(False)
|
---|
[117] | 1165 | self._wizard.gui.initializeWeightHelp()
|
---|
[70] | 1166 |
|
---|
[84] | 1167 | def calculateZFW(self):
|
---|
[60] | 1168 | """Calculate the ZFW value."""
|
---|
| 1169 | zfw = self._wizard.gui._flight.aircraft.dow
|
---|
[303] | 1170 | zfw += (self._numCrew.get_int() + self._numPassengers.get_int()) * 82
|
---|
| 1171 | zfw += self._bagWeight.get_int()
|
---|
[84] | 1172 | zfw += self._cargoWeight.get_int()
|
---|
[303] | 1173 | zfw += self._mailWeight.get_int()
|
---|
[60] | 1174 | return zfw
|
---|
[347] | 1175 |
|
---|
[60] | 1176 | def _updateCalculatedZFW(self):
|
---|
| 1177 | """Update the calculated ZFW"""
|
---|
[84] | 1178 | zfw = self.calculateZFW()
|
---|
[60] | 1179 |
|
---|
| 1180 | markupBegin = "<b>"
|
---|
| 1181 | markupEnd = "</b>"
|
---|
| 1182 | if self._simulatorZFWValue is not None and \
|
---|
| 1183 | PayloadChecker.isZFWFaulty(self._simulatorZFWValue, zfw):
|
---|
| 1184 | markupBegin += '<span foreground="red">'
|
---|
| 1185 | markupEnd = "</span>" + markupEnd
|
---|
| 1186 | self._calculatedZFW.set_markup(markupBegin + str(zfw) + markupEnd)
|
---|
| 1187 |
|
---|
[303] | 1188 | def _weightChanged(self, entry, weight):
|
---|
| 1189 | """Called when one of the weight values or humanm counts has changed."""
|
---|
[60] | 1190 | self._updateCalculatedZFW()
|
---|
[347] | 1191 |
|
---|
[59] | 1192 | def _zfwRequested(self, button):
|
---|
| 1193 | """Called when the ZFW is requested from the simulator."""
|
---|
[70] | 1194 | self._zfwButton.set_sensitive(False)
|
---|
| 1195 | self._backButton.set_sensitive(False)
|
---|
| 1196 | self._button.set_sensitive(False)
|
---|
| 1197 | gui = self._wizard.gui
|
---|
[107] | 1198 | gui.beginBusy(xstr("payload_zfw_busy"))
|
---|
[70] | 1199 | gui.simulator.requestZFW(self._handleZFW)
|
---|
[59] | 1200 |
|
---|
| 1201 | def _handleZFW(self, zfw):
|
---|
| 1202 | """Called when the ZFW value is retrieved."""
|
---|
[60] | 1203 | gobject.idle_add(self._processZFW, zfw)
|
---|
[59] | 1204 |
|
---|
[60] | 1205 | def _processZFW(self, zfw):
|
---|
| 1206 | """Process the given ZFW value received from the simulator."""
|
---|
[61] | 1207 | self._wizard.gui.endBusy()
|
---|
[70] | 1208 | self._zfwButton.set_sensitive(True)
|
---|
| 1209 | self._backButton.set_sensitive(True)
|
---|
| 1210 | self._button.set_sensitive(True)
|
---|
[60] | 1211 | self._simulatorZFWValue = zfw
|
---|
| 1212 | self._simulatorZFW.set_text("%.0f" % (zfw,))
|
---|
| 1213 | self._updateCalculatedZFW()
|
---|
| 1214 |
|
---|
| 1215 | def _forwardClicked(self, button):
|
---|
| 1216 | """Called when the forward button is clicked."""
|
---|
| 1217 | self._wizard.nextPage()
|
---|
[70] | 1218 |
|
---|
| 1219 | def _backClicked(self, button):
|
---|
| 1220 | """Called when the Back button is pressed."""
|
---|
| 1221 | self.goBack()
|
---|
[347] | 1222 |
|
---|
[59] | 1223 | #-----------------------------------------------------------------------------
|
---|
| 1224 |
|
---|
[61] | 1225 | class TimePage(Page):
|
---|
| 1226 | """Page displaying the departure and arrival times and allows querying the
|
---|
| 1227 | current time from the flight simulator."""
|
---|
| 1228 | def __init__(self, wizard):
|
---|
[107] | 1229 | super(TimePage, self).__init__(wizard, xstr("time_title"),
|
---|
| 1230 | xstr("time_help"),
|
---|
| 1231 | completedHelp = xstr("time_chelp"))
|
---|
[61] | 1232 |
|
---|
| 1233 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1234 | xscale = 0.0, yscale = 0.0)
|
---|
| 1235 |
|
---|
| 1236 | table = gtk.Table(3, 2)
|
---|
| 1237 | table.set_row_spacings(4)
|
---|
| 1238 | table.set_col_spacings(16)
|
---|
| 1239 | table.set_homogeneous(False)
|
---|
| 1240 | alignment.add(table)
|
---|
| 1241 | self.setMainWidget(alignment)
|
---|
| 1242 |
|
---|
[107] | 1243 | label = gtk.Label(xstr("time_departure"))
|
---|
[61] | 1244 | label.set_alignment(0.0, 0.5)
|
---|
| 1245 | table.attach(label, 0, 1, 0, 1)
|
---|
| 1246 |
|
---|
| 1247 | self._departure = gtk.Label()
|
---|
| 1248 | self._departure.set_alignment(0.0, 0.5)
|
---|
| 1249 | table.attach(self._departure, 1, 2, 0, 1)
|
---|
[347] | 1250 |
|
---|
[107] | 1251 | label = gtk.Label(xstr("time_arrival"))
|
---|
[61] | 1252 | label.set_alignment(0.0, 0.5)
|
---|
| 1253 | table.attach(label, 0, 1, 1, 2)
|
---|
| 1254 |
|
---|
| 1255 | self._arrival = gtk.Label()
|
---|
| 1256 | self._arrival.set_alignment(0.0, 0.5)
|
---|
| 1257 | table.attach(self._arrival, 1, 2, 1, 2)
|
---|
| 1258 |
|
---|
[107] | 1259 | self._timeButton = gtk.Button(xstr("time_fs"))
|
---|
[70] | 1260 | self._timeButton.set_use_underline(True)
|
---|
[107] | 1261 | self._timeButton.set_tooltip_text(xstr("time_fs_tooltip"))
|
---|
[70] | 1262 | self._timeButton.connect("clicked", self._timeRequested)
|
---|
| 1263 | table.attach(self._timeButton, 0, 1, 2, 3)
|
---|
[61] | 1264 |
|
---|
| 1265 | self._simulatorTime = gtk.Label("-")
|
---|
| 1266 | self._simulatorTime.set_alignment(0.0, 0.5)
|
---|
| 1267 | table.attach(self._simulatorTime, 1, 2, 2, 3)
|
---|
| 1268 |
|
---|
[208] | 1269 | self.addCancelFlightButton()
|
---|
| 1270 |
|
---|
[107] | 1271 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1272 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[61] | 1273 |
|
---|
| 1274 | def activate(self):
|
---|
| 1275 | """Activate the page."""
|
---|
[70] | 1276 | self._timeButton.set_sensitive(True)
|
---|
[61] | 1277 | bookedFlight = self._wizard._bookedFlight
|
---|
| 1278 | self._departure.set_text(str(bookedFlight.departureTime.time()))
|
---|
| 1279 | self._arrival.set_text(str(bookedFlight.arrivalTime.time()))
|
---|
[92] | 1280 | self._simulatorTime.set_text("-")
|
---|
[61] | 1281 |
|
---|
| 1282 | def _timeRequested(self, button):
|
---|
| 1283 | """Request the time from the simulator."""
|
---|
[70] | 1284 | self._timeButton.set_sensitive(False)
|
---|
| 1285 | self._backButton.set_sensitive(False)
|
---|
| 1286 | self._button.set_sensitive(False)
|
---|
[107] | 1287 | self._wizard.gui.beginBusy(xstr("time_busy"))
|
---|
[61] | 1288 | self._wizard.gui.simulator.requestTime(self._handleTime)
|
---|
| 1289 |
|
---|
| 1290 | def _handleTime(self, timestamp):
|
---|
| 1291 | """Handle the result of a time retrieval."""
|
---|
| 1292 | gobject.idle_add(self._processTime, timestamp)
|
---|
| 1293 |
|
---|
| 1294 | def _processTime(self, timestamp):
|
---|
| 1295 | """Process the given time."""
|
---|
| 1296 | self._wizard.gui.endBusy()
|
---|
[70] | 1297 | self._timeButton.set_sensitive(True)
|
---|
| 1298 | self._backButton.set_sensitive(True)
|
---|
| 1299 | self._button.set_sensitive(True)
|
---|
[61] | 1300 | tm = time.gmtime(timestamp)
|
---|
| 1301 | t = datetime.time(tm.tm_hour, tm.tm_min, tm.tm_sec)
|
---|
| 1302 | self._simulatorTime.set_text(str(t))
|
---|
| 1303 |
|
---|
| 1304 | ts = tm.tm_hour * 3600 + tm.tm_min * 60 + tm.tm_sec
|
---|
| 1305 | dt = self._wizard._bookedFlight.departureTime.time()
|
---|
| 1306 | dts = dt.hour * 3600 + dt.minute * 60 + dt.second
|
---|
| 1307 | diff = dts-ts
|
---|
| 1308 |
|
---|
| 1309 | markupBegin = ""
|
---|
| 1310 | markupEnd = ""
|
---|
| 1311 | if diff < 0:
|
---|
| 1312 | markupBegin = '<b><span foreground="red">'
|
---|
| 1313 | markupEnd = '</span></b>'
|
---|
| 1314 | elif diff < 3*60 or diff > 30*60:
|
---|
| 1315 | markupBegin = '<b><span foreground="orange">'
|
---|
| 1316 | markupEnd = '</span></b>'
|
---|
| 1317 |
|
---|
| 1318 | self._departure.set_markup(markupBegin + str(dt) + markupEnd)
|
---|
| 1319 |
|
---|
[70] | 1320 | def _backClicked(self, button):
|
---|
| 1321 | """Called when the Back button is pressed."""
|
---|
| 1322 | self.goBack()
|
---|
[347] | 1323 |
|
---|
[61] | 1324 | def _forwardClicked(self, button):
|
---|
| 1325 | """Called when the forward button is clicked."""
|
---|
[141] | 1326 | if not self._completed:
|
---|
| 1327 | gui = self._wizard.gui
|
---|
| 1328 | gui.beginBusy(xstr("fuel_get_busy"))
|
---|
[347] | 1329 |
|
---|
[274] | 1330 | gui.simulator.getFuel(self._handleFuel)
|
---|
[141] | 1331 | else:
|
---|
| 1332 | self._wizard.nextPage()
|
---|
| 1333 |
|
---|
| 1334 | def _handleFuel(self, fuelData):
|
---|
| 1335 | """Callback for the fuel query operation."""
|
---|
| 1336 | gobject.idle_add(self._processFuel, fuelData)
|
---|
| 1337 |
|
---|
| 1338 | def _processFuel(self, fuelData):
|
---|
| 1339 | """Process the given fuel data."""
|
---|
| 1340 | self._wizard.gui.endBusy()
|
---|
| 1341 | self._wizard._fuelData = fuelData
|
---|
[61] | 1342 | self._wizard.nextPage()
|
---|
[347] | 1343 |
|
---|
[61] | 1344 | #-----------------------------------------------------------------------------
|
---|
| 1345 |
|
---|
[141] | 1346 | class FuelTank(gtk.VBox):
|
---|
| 1347 | """Widget for the fuel tank."""
|
---|
| 1348 | def __init__(self, fuelTank, name, capacity, currentWeight):
|
---|
| 1349 | """Construct the widget for the tank with the given name."""
|
---|
| 1350 | super(FuelTank, self).__init__()
|
---|
| 1351 |
|
---|
[146] | 1352 | self._enabled = True
|
---|
[141] | 1353 | self.fuelTank = fuelTank
|
---|
| 1354 | self.capacity = capacity
|
---|
| 1355 | self.currentWeight = currentWeight
|
---|
| 1356 | self.expectedWeight = currentWeight
|
---|
| 1357 |
|
---|
| 1358 | label = gtk.Label("<b>" + name + "</b>")
|
---|
| 1359 | label.set_use_markup(True)
|
---|
[145] | 1360 | label.set_use_underline(True)
|
---|
[141] | 1361 | label.set_justify(JUSTIFY_CENTER)
|
---|
| 1362 | label.set_alignment(0.5, 1.0)
|
---|
| 1363 | self.pack_start(label, False, False, 4)
|
---|
| 1364 |
|
---|
[142] | 1365 | self._tankFigure = gtk.EventBox()
|
---|
[141] | 1366 | self._tankFigure.set_size_request(38, -1)
|
---|
[142] | 1367 | self._tankFigure.set_visible_window(False)
|
---|
[144] | 1368 | self._tankFigure.set_tooltip_markup(xstr("fuel_tank_tooltip"))
|
---|
[141] | 1369 |
|
---|
| 1370 | if pygobject:
|
---|
| 1371 | self._tankFigure.connect("draw", self._drawTankFigure)
|
---|
| 1372 | else:
|
---|
| 1373 | self._tankFigure.connect("expose_event", self._drawTankFigure)
|
---|
[144] | 1374 | self._tankFigure.connect("button_press_event", self._buttonPressed)
|
---|
| 1375 | self._tankFigure.connect("motion_notify_event", self._motionNotify)
|
---|
| 1376 | self._tankFigure.connect("scroll-event", self._scrolled)
|
---|
[347] | 1377 |
|
---|
[141] | 1378 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1379 | xscale = 0.0, yscale = 1.0)
|
---|
[142] | 1380 | alignment.add(self._tankFigure)
|
---|
[141] | 1381 |
|
---|
| 1382 | self.pack_start(alignment, True, True, 4)
|
---|
| 1383 |
|
---|
| 1384 | self._expectedButton = gtk.SpinButton()
|
---|
| 1385 | self._expectedButton.set_numeric(True)
|
---|
| 1386 | self._expectedButton.set_range(0, self.capacity)
|
---|
| 1387 | self._expectedButton.set_increments(10, 100)
|
---|
| 1388 | self._expectedButton.set_value(currentWeight)
|
---|
| 1389 | self._expectedButton.set_alignment(1.0)
|
---|
| 1390 | self._expectedButton.set_width_chars(5)
|
---|
| 1391 | self._expectedButton.connect("value-changed", self._expectedChanged)
|
---|
| 1392 |
|
---|
[145] | 1393 | label.set_mnemonic_widget(self._expectedButton)
|
---|
| 1394 |
|
---|
[141] | 1395 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1396 | xscale = 0.0, yscale = 1.0)
|
---|
[347] | 1397 | alignment.add(self._expectedButton)
|
---|
[141] | 1398 | self.pack_start(alignment, False, False, 4)
|
---|
| 1399 |
|
---|
| 1400 | def setCurrent(self, currentWeight):
|
---|
| 1401 | """Set the current weight."""
|
---|
| 1402 | self.currentWeight = currentWeight
|
---|
| 1403 | self._redraw()
|
---|
| 1404 |
|
---|
| 1405 | def isCorrect(self):
|
---|
| 1406 | """Determine if the contents of the fuel tank are as expected"""
|
---|
| 1407 | return abs(self.expectedWeight - self.currentWeight)<=1
|
---|
| 1408 |
|
---|
| 1409 | def disable(self):
|
---|
| 1410 | """Disable the fuel tank."""
|
---|
| 1411 | self._expectedButton.set_sensitive(False)
|
---|
[146] | 1412 | self._enabled = False
|
---|
[141] | 1413 |
|
---|
| 1414 | def _redraw(self):
|
---|
| 1415 | """Redraw the tank figure."""
|
---|
| 1416 | self._tankFigure.queue_draw()
|
---|
| 1417 |
|
---|
[142] | 1418 | def _drawTankFigure(self, tankFigure, eventOrContext):
|
---|
[141] | 1419 | """Draw the tank figure."""
|
---|
| 1420 | triangleSize = 5
|
---|
[142] | 1421 |
|
---|
| 1422 | context = eventOrContext if pygobject else tankFigure.window.cairo_create()
|
---|
| 1423 | (xOffset, yOffset) = (0, 0) if pygobject \
|
---|
| 1424 | else (tankFigure.allocation.x, tankFigure.allocation.y)
|
---|
[347] | 1425 |
|
---|
[142] | 1426 | width = tankFigure.get_allocated_width() if pygobject \
|
---|
| 1427 | else tankFigure.allocation.width
|
---|
| 1428 | height = tankFigure.get_allocated_height() if pygobject \
|
---|
| 1429 | else tankFigure.allocation.height
|
---|
[141] | 1430 |
|
---|
| 1431 | rectangleX0 = triangleSize
|
---|
| 1432 | rectangleY0 = triangleSize
|
---|
| 1433 | rectangleX1 = width - 1 - triangleSize
|
---|
| 1434 | rectangleY1 = height - 1 - triangleSize
|
---|
| 1435 | rectangleLineWidth = 2.0
|
---|
| 1436 |
|
---|
| 1437 | context.set_source_rgb(0.0, 0.0, 0.0)
|
---|
| 1438 | context.set_line_width(rectangleLineWidth)
|
---|
[142] | 1439 | context.rectangle(xOffset + rectangleX0 + rectangleLineWidth/2,
|
---|
| 1440 | yOffset + rectangleY0 + rectangleLineWidth/2,
|
---|
[141] | 1441 | rectangleX1 - rectangleX0 - rectangleLineWidth,
|
---|
| 1442 | rectangleY1 - rectangleY0 - rectangleLineWidth)
|
---|
| 1443 | context.stroke()
|
---|
| 1444 |
|
---|
| 1445 | rectangleInnerLeft = rectangleX0 + rectangleLineWidth
|
---|
| 1446 | rectangleInnerRight = rectangleX1 - rectangleLineWidth
|
---|
[144] | 1447 | self._rectangleInnerTop = rectangleInnerTop = rectangleY0 + rectangleLineWidth
|
---|
| 1448 | self._rectangleInnerBottom = rectangleInnerBottom = rectangleY1 - rectangleLineWidth
|
---|
[141] | 1449 |
|
---|
| 1450 | rectangleInnerWidth = rectangleInnerRight - rectangleInnerLeft
|
---|
| 1451 | rectangleInnerHeight = rectangleInnerBottom - rectangleInnerTop
|
---|
| 1452 |
|
---|
| 1453 | context.set_source_rgb(1.0, 0.9, 0.6)
|
---|
| 1454 | currentHeight = self.currentWeight * rectangleInnerHeight / self.capacity
|
---|
| 1455 | currentX = rectangleInnerTop + rectangleInnerHeight - currentHeight
|
---|
[142] | 1456 | context.rectangle(xOffset + rectangleInnerLeft,
|
---|
| 1457 | yOffset + rectangleInnerTop +
|
---|
| 1458 | rectangleInnerHeight - currentHeight,
|
---|
[141] | 1459 | rectangleInnerWidth, currentHeight)
|
---|
| 1460 | context.fill()
|
---|
| 1461 |
|
---|
| 1462 | expectedHeight = self.expectedWeight * rectangleInnerHeight / self.capacity
|
---|
| 1463 | expectedY = rectangleInnerTop + rectangleInnerHeight - expectedHeight
|
---|
| 1464 |
|
---|
| 1465 | context.set_line_width(1.5)
|
---|
| 1466 | context.set_source_rgb(0.0, 0.85, 0.85)
|
---|
[142] | 1467 | context.move_to(xOffset + rectangleX0, yOffset + expectedY)
|
---|
| 1468 | context.line_to(xOffset + rectangleX1, yOffset + expectedY)
|
---|
[141] | 1469 | context.stroke()
|
---|
| 1470 |
|
---|
| 1471 | context.set_line_width(0.0)
|
---|
[142] | 1472 | context.move_to(xOffset + 0, yOffset + expectedY - triangleSize)
|
---|
| 1473 | context.line_to(xOffset + 0, yOffset + expectedY + triangleSize)
|
---|
| 1474 | context.line_to(xOffset + rectangleX0 + 1, yOffset + expectedY)
|
---|
| 1475 | context.line_to(xOffset + 0, yOffset + expectedY - triangleSize)
|
---|
[141] | 1476 | context.fill()
|
---|
| 1477 |
|
---|
| 1478 | context.set_line_width(0.0)
|
---|
[142] | 1479 | context.move_to(xOffset + width, yOffset + expectedY - triangleSize)
|
---|
| 1480 | context.line_to(xOffset + width, yOffset + expectedY + triangleSize)
|
---|
| 1481 | context.line_to(xOffset + rectangleX1 - 1, yOffset + expectedY)
|
---|
| 1482 | context.line_to(xOffset + width, yOffset + expectedY - triangleSize)
|
---|
[141] | 1483 | context.fill()
|
---|
| 1484 |
|
---|
[142] | 1485 | return True
|
---|
| 1486 |
|
---|
[144] | 1487 | def _setExpectedFromY(self, y):
|
---|
| 1488 | """Set the expected weight from the given Y-coordinate."""
|
---|
| 1489 | level = (self._rectangleInnerBottom - y) / \
|
---|
| 1490 | (self._rectangleInnerBottom - self._rectangleInnerTop)
|
---|
| 1491 | level = min(1.0, max(0.0, level))
|
---|
| 1492 | self._expectedButton.set_value(level * self.capacity)
|
---|
[347] | 1493 |
|
---|
[144] | 1494 | def _buttonPressed(self, tankFigure, event):
|
---|
| 1495 | """Called when a button is pressed in the figure.
|
---|
| 1496 |
|
---|
| 1497 | The expected level will be set there."""
|
---|
[146] | 1498 | if self._enabled and event.button==1:
|
---|
[144] | 1499 | self._setExpectedFromY(event.y)
|
---|
[347] | 1500 |
|
---|
[144] | 1501 | def _motionNotify(self, tankFigure, event):
|
---|
| 1502 | """Called when the mouse pointer moves within the area of a tank figure."""
|
---|
[347] | 1503 | if self._enabled and event.state==BUTTON1_MASK:
|
---|
[144] | 1504 | self._setExpectedFromY(event.y)
|
---|
| 1505 |
|
---|
| 1506 | def _scrolled(self, tankFigure, event):
|
---|
| 1507 | """Called when a scroll event is received."""
|
---|
[146] | 1508 | if self._enabled:
|
---|
| 1509 | increment = 1 if event.state==CONTROL_MASK \
|
---|
| 1510 | else 100 if event.state==SHIFT_MASK \
|
---|
| 1511 | else 10 if event.state==0 else 0
|
---|
| 1512 | if increment!=0:
|
---|
| 1513 | if event.direction==SCROLL_DOWN:
|
---|
| 1514 | increment *= -1
|
---|
| 1515 | self._expectedButton.spin(SPIN_USER_DEFINED, increment)
|
---|
[347] | 1516 |
|
---|
[141] | 1517 | def _expectedChanged(self, spinButton):
|
---|
| 1518 | """Called when the expected value has changed."""
|
---|
| 1519 | self.expectedWeight = spinButton.get_value_as_int()
|
---|
[347] | 1520 | self._redraw()
|
---|
[141] | 1521 |
|
---|
| 1522 | #-----------------------------------------------------------------------------
|
---|
| 1523 |
|
---|
| 1524 | class FuelPage(Page):
|
---|
| 1525 | """The page containing the fuel tank filling."""
|
---|
| 1526 | _pumpStep = 0.02
|
---|
[347] | 1527 |
|
---|
[141] | 1528 | def __init__(self, wizard):
|
---|
| 1529 | """Construct the page."""
|
---|
| 1530 | super(FuelPage, self).__init__(wizard, xstr("fuel_title"),
|
---|
| 1531 | xstr("fuel_help"),
|
---|
| 1532 | completedHelp = xstr("fuel_chelp"))
|
---|
| 1533 |
|
---|
| 1534 | self._fuelTanks = []
|
---|
| 1535 | self._fuelTable = None
|
---|
| 1536 | self._fuelAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1537 | xscale = 0.0, yscale = 1.0)
|
---|
| 1538 | self.setMainWidget(self._fuelAlignment)
|
---|
| 1539 |
|
---|
[274] | 1540 | tankData = [(tank, 2500, 3900) for tank in acft.mostFuelTanks]
|
---|
| 1541 | self._setupTanks(tankData)
|
---|
[141] | 1542 |
|
---|
[208] | 1543 | self.addCancelFlightButton()
|
---|
| 1544 |
|
---|
[141] | 1545 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1546 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 1547 |
|
---|
| 1548 | self._pumpIndex = 0
|
---|
| 1549 |
|
---|
[145] | 1550 | def activate(self):
|
---|
| 1551 | """Activate the page."""
|
---|
[274] | 1552 | self._setupTanks(self._wizard._fuelData)
|
---|
[141] | 1553 |
|
---|
| 1554 | def finalize(self):
|
---|
| 1555 | """Finalize the page."""
|
---|
| 1556 | for fuelTank in self._fuelTanks:
|
---|
| 1557 | fuelTank.disable()
|
---|
| 1558 |
|
---|
| 1559 | def _backClicked(self, button):
|
---|
| 1560 | """Called when the Back button is pressed."""
|
---|
| 1561 | self.goBack()
|
---|
[347] | 1562 |
|
---|
[141] | 1563 | def _forwardClicked(self, button):
|
---|
| 1564 | """Called when the forward button is clicked."""
|
---|
| 1565 | if not self._completed:
|
---|
| 1566 | self._pumpIndex = 0
|
---|
| 1567 | self._wizard.gui.beginBusy(xstr("fuel_pump_busy"))
|
---|
| 1568 | self._pump()
|
---|
| 1569 | else:
|
---|
[347] | 1570 | self._wizard.nextPage()
|
---|
[141] | 1571 |
|
---|
[274] | 1572 | def _setupTanks(self, tankData):
|
---|
[141] | 1573 | """Setup the tanks for the given data."""
|
---|
[274] | 1574 | numTanks = len(tankData)
|
---|
[141] | 1575 | if self._fuelTable is not None:
|
---|
| 1576 | self._fuelAlignment.remove(self._fuelTable)
|
---|
| 1577 |
|
---|
| 1578 | self._fuelTanks = []
|
---|
| 1579 | self._fuelTable = gtk.Table(numTanks, 1)
|
---|
| 1580 | self._fuelTable.set_col_spacings(16)
|
---|
[274] | 1581 | index = 0
|
---|
| 1582 | for (tank, current, capacity) in tankData:
|
---|
[141] | 1583 | fuelTank = FuelTank(tank,
|
---|
| 1584 | xstr("fuel_tank_" +
|
---|
| 1585 | const.fuelTank2string(tank)),
|
---|
| 1586 | capacity, current)
|
---|
[274] | 1587 | self._fuelTable.attach(fuelTank, index, index+1, 0, 1)
|
---|
[141] | 1588 | self._fuelTanks.append(fuelTank)
|
---|
[274] | 1589 | index += 1
|
---|
[347] | 1590 |
|
---|
[141] | 1591 | self._fuelAlignment.add(self._fuelTable)
|
---|
| 1592 | self.show_all()
|
---|
| 1593 |
|
---|
| 1594 | def _pump(self):
|
---|
| 1595 | """Perform one step of pumping.
|
---|
| 1596 |
|
---|
| 1597 | It is checked, if the current tank's contents are of the right
|
---|
| 1598 | quantity. If not, it is filled one step further to the desired
|
---|
| 1599 | contents. Otherwise the next tank is started. If all tanks are are
|
---|
| 1600 | filled, the next page is selected."""
|
---|
| 1601 | numTanks = len(self._fuelTanks)
|
---|
| 1602 |
|
---|
| 1603 | fuelTank = None
|
---|
| 1604 | while self._pumpIndex < numTanks:
|
---|
| 1605 | fuelTank = self._fuelTanks[self._pumpIndex]
|
---|
| 1606 | if fuelTank.isCorrect():
|
---|
| 1607 | self._pumpIndex += 1
|
---|
| 1608 | fuelTank = None
|
---|
| 1609 | else:
|
---|
| 1610 | break
|
---|
| 1611 |
|
---|
| 1612 | if fuelTank is None:
|
---|
| 1613 | self._wizard.gui.endBusy()
|
---|
| 1614 | self._wizard.nextPage()
|
---|
| 1615 | else:
|
---|
| 1616 | currentLevel = fuelTank.currentWeight / fuelTank.capacity
|
---|
| 1617 | expectedLevel = fuelTank.expectedWeight / fuelTank.capacity
|
---|
| 1618 | if currentLevel<expectedLevel:
|
---|
| 1619 | currentLevel += FuelPage._pumpStep
|
---|
| 1620 | if currentLevel>expectedLevel: currentLevel = expectedLevel
|
---|
| 1621 | else:
|
---|
| 1622 | currentLevel -= FuelPage._pumpStep
|
---|
| 1623 | if currentLevel<expectedLevel: currentLevel = expectedLevel
|
---|
| 1624 | fuelTank.setCurrent(currentLevel * fuelTank.capacity)
|
---|
| 1625 | self._wizard.gui.simulator.setFuelLevel([(fuelTank.fuelTank,
|
---|
| 1626 | currentLevel)])
|
---|
| 1627 | gobject.timeout_add(50, self._pump)
|
---|
[347] | 1628 |
|
---|
[141] | 1629 | #-----------------------------------------------------------------------------
|
---|
| 1630 |
|
---|
[62] | 1631 | class RoutePage(Page):
|
---|
| 1632 | """The page containing the route and the flight level."""
|
---|
| 1633 | def __init__(self, wizard):
|
---|
[141] | 1634 | """Construct the page."""
|
---|
[107] | 1635 | super(RoutePage, self).__init__(wizard, xstr("route_title"),
|
---|
| 1636 | xstr("route_help"),
|
---|
| 1637 | completedHelp = xstr("route_chelp"))
|
---|
[62] | 1638 |
|
---|
| 1639 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1640 | xscale = 0.0, yscale = 0.0)
|
---|
| 1641 |
|
---|
| 1642 | mainBox = gtk.VBox()
|
---|
| 1643 | alignment.add(mainBox)
|
---|
| 1644 | self.setMainWidget(alignment)
|
---|
| 1645 |
|
---|
| 1646 | levelBox = gtk.HBox()
|
---|
| 1647 |
|
---|
[107] | 1648 | label = gtk.Label(xstr("route_level"))
|
---|
[62] | 1649 | label.set_use_underline(True)
|
---|
| 1650 | levelBox.pack_start(label, True, True, 0)
|
---|
| 1651 |
|
---|
| 1652 | self._cruiseLevel = gtk.SpinButton()
|
---|
| 1653 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
| 1654 | self._cruiseLevel.set_range(min = 50, max = 500)
|
---|
[107] | 1655 | self._cruiseLevel.set_tooltip_text(xstr("route_level_tooltip"))
|
---|
[62] | 1656 | self._cruiseLevel.set_numeric(True)
|
---|
| 1657 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
[97] | 1658 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
[62] | 1659 |
|
---|
| 1660 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
| 1661 |
|
---|
| 1662 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 1663 | xscale = 0.0, yscale = 0.0)
|
---|
| 1664 | alignment.add(levelBox)
|
---|
| 1665 |
|
---|
| 1666 | mainBox.pack_start(alignment, False, False, 0)
|
---|
| 1667 |
|
---|
| 1668 |
|
---|
| 1669 | routeBox = gtk.VBox()
|
---|
| 1670 |
|
---|
| 1671 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 1672 | xscale = 0.0, yscale = 0.0)
|
---|
[107] | 1673 | label = gtk.Label(xstr("route_route"))
|
---|
[62] | 1674 | label.set_use_underline(True)
|
---|
| 1675 | alignment.add(label)
|
---|
| 1676 | routeBox.pack_start(alignment, True, True, 0)
|
---|
| 1677 |
|
---|
| 1678 | routeWindow = gtk.ScrolledWindow()
|
---|
| 1679 | routeWindow.set_size_request(400, 80)
|
---|
| 1680 | routeWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 1681 | else gtk.SHADOW_IN)
|
---|
[69] | 1682 | routeWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1683 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1684 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1685 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 1686 |
|
---|
[138] | 1687 | self._uppercasingRoute = False
|
---|
| 1688 |
|
---|
[62] | 1689 | self._route = gtk.TextView()
|
---|
[107] | 1690 | self._route.set_tooltip_text(xstr("route_route_tooltip"))
|
---|
[138] | 1691 | self._route.set_wrap_mode(WRAP_WORD)
|
---|
[62] | 1692 | self._route.get_buffer().connect("changed", self._routeChanged)
|
---|
[138] | 1693 | self._route.get_buffer().connect_after("insert-text", self._routeInserted)
|
---|
[62] | 1694 | routeWindow.add(self._route)
|
---|
| 1695 |
|
---|
| 1696 | label.set_mnemonic_widget(self._route)
|
---|
[347] | 1697 | routeBox.pack_start(routeWindow, True, True, 0)
|
---|
[62] | 1698 |
|
---|
| 1699 | mainBox.pack_start(routeBox, True, True, 8)
|
---|
| 1700 |
|
---|
[208] | 1701 | self.addCancelFlightButton()
|
---|
| 1702 |
|
---|
[347] | 1703 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
[107] | 1704 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[62] | 1705 |
|
---|
[84] | 1706 | @property
|
---|
[97] | 1707 | def filedCruiseLevel(self):
|
---|
| 1708 | """Get the filed cruise level."""
|
---|
[84] | 1709 | return self._cruiseLevel.get_value_as_int()
|
---|
| 1710 |
|
---|
[97] | 1711 | @property
|
---|
| 1712 | def route(self):
|
---|
| 1713 | """Get the route."""
|
---|
| 1714 | return self._getRoute()
|
---|
| 1715 |
|
---|
[62] | 1716 | def activate(self):
|
---|
| 1717 | """Setup the route from the booked flight."""
|
---|
[92] | 1718 | self._cruiseLevel.set_value(240)
|
---|
[62] | 1719 | self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
|
---|
| 1720 | self._updateForwardButton()
|
---|
| 1721 |
|
---|
| 1722 | def _getRoute(self):
|
---|
| 1723 | """Get the text of the route."""
|
---|
| 1724 | buffer = self._route.get_buffer()
|
---|
| 1725 | return buffer.get_text(buffer.get_start_iter(),
|
---|
| 1726 | buffer.get_end_iter(), True)
|
---|
| 1727 |
|
---|
| 1728 | def _updateForwardButton(self):
|
---|
| 1729 | """Update the sensitivity of the forward button."""
|
---|
| 1730 | self._button.set_sensitive(self._cruiseLevel.get_value_as_int()>=50 and \
|
---|
[68] | 1731 | self._getRoute()!="")
|
---|
[347] | 1732 |
|
---|
[62] | 1733 | def _cruiseLevelChanged(self, spinButton):
|
---|
| 1734 | """Called when the cruise level has changed."""
|
---|
| 1735 | self._updateForwardButton()
|
---|
| 1736 |
|
---|
| 1737 | def _routeChanged(self, textBuffer):
|
---|
| 1738 | """Called when the route has changed."""
|
---|
[138] | 1739 | if not self._uppercasingRoute:
|
---|
| 1740 | self._updateForwardButton()
|
---|
| 1741 |
|
---|
| 1742 | def _routeInserted(self, textBuffer, iter, text, length):
|
---|
| 1743 | """Called when new characters are inserted into the route.
|
---|
| 1744 |
|
---|
| 1745 | It uppercases all characters."""
|
---|
| 1746 | if not self._uppercasingRoute:
|
---|
| 1747 | self._uppercasingRoute = True
|
---|
| 1748 |
|
---|
| 1749 | iter1 = iter.copy()
|
---|
| 1750 | iter1.backward_chars(length)
|
---|
| 1751 | textBuffer.delete(iter, iter1)
|
---|
| 1752 |
|
---|
| 1753 | textBuffer.insert(iter, text.upper())
|
---|
| 1754 |
|
---|
| 1755 | self._uppercasingRoute = False
|
---|
[62] | 1756 |
|
---|
[70] | 1757 | def _backClicked(self, button):
|
---|
| 1758 | """Called when the Back button is pressed."""
|
---|
| 1759 | self.goBack()
|
---|
[347] | 1760 |
|
---|
[62] | 1761 | def _forwardClicked(self, button):
|
---|
| 1762 | """Called when the Forward button is clicked."""
|
---|
[94] | 1763 | if self._completed:
|
---|
[70] | 1764 | self._wizard.nextPage()
|
---|
| 1765 | else:
|
---|
| 1766 | bookedFlight = self._wizard._bookedFlight
|
---|
[107] | 1767 | self._wizard.gui.beginBusy(xstr("route_down_notams"))
|
---|
[70] | 1768 | self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback,
|
---|
| 1769 | bookedFlight.departureICAO,
|
---|
| 1770 | bookedFlight.arrivalICAO)
|
---|
[170] | 1771 | startSound(const.SOUND_NOTAM)
|
---|
[64] | 1772 |
|
---|
| 1773 | def _notamsCallback(self, returned, result):
|
---|
| 1774 | """Callback for the NOTAMs."""
|
---|
| 1775 | gobject.idle_add(self._handleNOTAMs, returned, result)
|
---|
| 1776 |
|
---|
| 1777 | def _handleNOTAMs(self, returned, result):
|
---|
| 1778 | """Handle the NOTAMs."""
|
---|
| 1779 | if returned:
|
---|
| 1780 | self._wizard._departureNOTAMs = result.departureNOTAMs
|
---|
| 1781 | self._wizard._arrivalNOTAMs = result.arrivalNOTAMs
|
---|
[67] | 1782 | else:
|
---|
| 1783 | self._wizard._departureNOTAMs = None
|
---|
| 1784 | self._wizard._arrivalNOTAMs = None
|
---|
[64] | 1785 |
|
---|
[67] | 1786 | bookedFlight = self._wizard._bookedFlight
|
---|
[107] | 1787 | self._wizard.gui.beginBusy(xstr("route_down_metars"))
|
---|
[67] | 1788 | self._wizard.gui.webHandler.getMETARs(self._metarsCallback,
|
---|
| 1789 | [bookedFlight.departureICAO,
|
---|
| 1790 | bookedFlight.arrivalICAO])
|
---|
| 1791 |
|
---|
| 1792 | def _metarsCallback(self, returned, result):
|
---|
| 1793 | """Callback for the METARs."""
|
---|
| 1794 | gobject.idle_add(self._handleMETARs, returned, result)
|
---|
| 1795 |
|
---|
| 1796 | def _handleMETARs(self, returned, result):
|
---|
| 1797 | """Handle the METARs."""
|
---|
| 1798 | self._wizard._departureMETAR = None
|
---|
| 1799 | self._wizard._arrivalMETAR = None
|
---|
| 1800 | bookedFlight = self._wizard._bookedFlight
|
---|
| 1801 | if returned:
|
---|
| 1802 | if bookedFlight.departureICAO in result.metars:
|
---|
| 1803 | self._wizard._departureMETAR = result.metars[bookedFlight.departureICAO]
|
---|
| 1804 | if bookedFlight.arrivalICAO in result.metars:
|
---|
| 1805 | self._wizard._arrivalMETAR = result.metars[bookedFlight.arrivalICAO]
|
---|
| 1806 |
|
---|
| 1807 | self._wizard.gui.endBusy()
|
---|
[70] | 1808 | self._backButton.set_sensitive(True)
|
---|
| 1809 | self._button.set_sensitive(True)
|
---|
[62] | 1810 | self._wizard.nextPage()
|
---|
| 1811 |
|
---|
| 1812 | #-----------------------------------------------------------------------------
|
---|
| 1813 |
|
---|
[67] | 1814 | class BriefingPage(Page):
|
---|
| 1815 | """Page for the briefing."""
|
---|
| 1816 | def __init__(self, wizard, departure):
|
---|
| 1817 | """Construct the briefing page."""
|
---|
| 1818 | self._departure = departure
|
---|
[347] | 1819 |
|
---|
[107] | 1820 | title = xstr("briefing_title") % (1 if departure else 2,
|
---|
| 1821 | xstr("briefing_departure")
|
---|
| 1822 | if departure
|
---|
| 1823 | else xstr("briefing_arrival"))
|
---|
| 1824 | super(BriefingPage, self).__init__(wizard, title, xstr("briefing_help"),
|
---|
| 1825 | completedHelp = xstr("briefing_chelp"))
|
---|
[64] | 1826 |
|
---|
| 1827 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1828 | xscale = 1.0, yscale = 1.0)
|
---|
| 1829 |
|
---|
| 1830 | mainBox = gtk.VBox()
|
---|
| 1831 | alignment.add(mainBox)
|
---|
| 1832 | self.setMainWidget(alignment)
|
---|
| 1833 |
|
---|
[67] | 1834 | self._notamsFrame = gtk.Frame()
|
---|
[107] | 1835 | self._notamsFrame.set_label(xstr("briefing_notams_init"))
|
---|
[64] | 1836 | scrolledWindow = gtk.ScrolledWindow()
|
---|
[67] | 1837 | scrolledWindow.set_size_request(-1, 128)
|
---|
[94] | 1838 | # FIXME: these constants should be in common
|
---|
[69] | 1839 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1840 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1841 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1842 | else gtk.POLICY_AUTOMATIC)
|
---|
[67] | 1843 | self._notams = gtk.TextView()
|
---|
| 1844 | self._notams.set_editable(False)
|
---|
| 1845 | self._notams.set_accepts_tab(False)
|
---|
| 1846 | self._notams.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
| 1847 | scrolledWindow.add(self._notams)
|
---|
| 1848 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1849 | xscale = 1.0, yscale = 1.0)
|
---|
| 1850 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 1851 | padding_left = 0, padding_right = 0)
|
---|
| 1852 | alignment.add(scrolledWindow)
|
---|
| 1853 | self._notamsFrame.add(alignment)
|
---|
| 1854 | mainBox.pack_start(self._notamsFrame, True, True, 4)
|
---|
[347] | 1855 |
|
---|
[67] | 1856 | self._metarFrame = gtk.Frame()
|
---|
[107] | 1857 | self._metarFrame.set_label(xstr("briefing_metar_init"))
|
---|
[67] | 1858 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 1859 | scrolledWindow.set_size_request(-1, 32)
|
---|
[69] | 1860 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1861 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1862 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1863 | else gtk.POLICY_AUTOMATIC)
|
---|
[138] | 1864 |
|
---|
| 1865 | self._uppercasingMETAR = False
|
---|
| 1866 |
|
---|
[67] | 1867 | self._metar = gtk.TextView()
|
---|
| 1868 | self._metar.set_accepts_tab(False)
|
---|
| 1869 | self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
[106] | 1870 | self._metar.get_buffer().connect("changed", self._metarChanged)
|
---|
[138] | 1871 | self._metar.get_buffer().connect_after("insert-text", self._metarInserted)
|
---|
[67] | 1872 | scrolledWindow.add(self._metar)
|
---|
| 1873 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1874 | xscale = 1.0, yscale = 1.0)
|
---|
| 1875 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 1876 | padding_left = 0, padding_right = 0)
|
---|
| 1877 | alignment.add(scrolledWindow)
|
---|
| 1878 | self._metarFrame.add(alignment)
|
---|
| 1879 | mainBox.pack_start(self._metarFrame, True, True, 4)
|
---|
[106] | 1880 | self.metarEdited = False
|
---|
[64] | 1881 |
|
---|
[208] | 1882 | self.addCancelFlightButton()
|
---|
| 1883 |
|
---|
[107] | 1884 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1885 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[64] | 1886 |
|
---|
[97] | 1887 | @property
|
---|
| 1888 | def metar(self):
|
---|
| 1889 | """Get the METAR on the page."""
|
---|
| 1890 | buffer = self._metar.get_buffer()
|
---|
| 1891 | return buffer.get_text(buffer.get_start_iter(),
|
---|
[347] | 1892 | buffer.get_end_iter(), True)
|
---|
[97] | 1893 |
|
---|
[106] | 1894 | def setMETAR(self, metar):
|
---|
| 1895 | """Set the metar."""
|
---|
| 1896 | self._metar.get_buffer().set_text(metar)
|
---|
| 1897 | self.metarEdited = False
|
---|
| 1898 |
|
---|
[64] | 1899 | def activate(self):
|
---|
| 1900 | """Activate the page."""
|
---|
[70] | 1901 | if not self._departure:
|
---|
[107] | 1902 | self._button.set_label(xstr("briefing_button"))
|
---|
| 1903 | self._button.set_has_tooltip(False)
|
---|
[70] | 1904 | self._button.set_use_stock(False)
|
---|
| 1905 |
|
---|
| 1906 | bookedFlight = self._wizard._bookedFlight
|
---|
[67] | 1907 |
|
---|
[70] | 1908 | icao = bookedFlight.departureICAO if self._departure \
|
---|
| 1909 | else bookedFlight.arrivalICAO
|
---|
| 1910 | notams = self._wizard._departureNOTAMs if self._departure \
|
---|
| 1911 | else self._wizard._arrivalNOTAMs
|
---|
| 1912 | metar = self._wizard._departureMETAR if self._departure \
|
---|
| 1913 | else self._wizard._arrivalMETAR
|
---|
[64] | 1914 |
|
---|
[107] | 1915 | self._notamsFrame.set_label(xstr("briefing_notams_template") % (icao,))
|
---|
[70] | 1916 | buffer = self._notams.get_buffer()
|
---|
| 1917 | if notams is None:
|
---|
[107] | 1918 | buffer.set_text(xstr("briefing_notams_failed"))
|
---|
[92] | 1919 | elif not notams:
|
---|
[107] | 1920 | buffer.set_text(xstr("briefing_notams_missing"))
|
---|
[70] | 1921 | else:
|
---|
| 1922 | s = ""
|
---|
| 1923 | for notam in notams:
|
---|
| 1924 | s += str(notam.begin)
|
---|
| 1925 | if notam.end is not None:
|
---|
| 1926 | s += " - " + str(notam.end)
|
---|
| 1927 | elif notam.permanent:
|
---|
| 1928 | s += " - PERMANENT"
|
---|
| 1929 | s += "\n"
|
---|
| 1930 | if notam.repeatCycle:
|
---|
| 1931 | s += "Repeat cycle: " + notam.repeatCycle + "\n"
|
---|
| 1932 | s += notam.notice + "\n"
|
---|
| 1933 | s += "-------------------- * --------------------\n"
|
---|
| 1934 | buffer.set_text(s)
|
---|
[67] | 1935 |
|
---|
[107] | 1936 | self._metarFrame.set_label(xstr("briefing_metar_template") % (icao,))
|
---|
[70] | 1937 | buffer = self._metar.get_buffer()
|
---|
| 1938 | if metar is None:
|
---|
[107] | 1939 | buffer.set_text(xstr("briefing_metar_failed"))
|
---|
[70] | 1940 | else:
|
---|
| 1941 | buffer.set_text(metar)
|
---|
[67] | 1942 |
|
---|
[107] | 1943 | label = self._metarFrame.get_label_widget()
|
---|
| 1944 | label.set_use_underline(True)
|
---|
| 1945 | label.set_mnemonic_widget(self._metar)
|
---|
| 1946 |
|
---|
[106] | 1947 | self.metarEdited = False
|
---|
| 1948 |
|
---|
[70] | 1949 | def _backClicked(self, button):
|
---|
| 1950 | """Called when the Back button is pressed."""
|
---|
| 1951 | self.goBack()
|
---|
[347] | 1952 |
|
---|
[67] | 1953 | def _forwardClicked(self, button):
|
---|
[64] | 1954 | """Called when the forward button is clicked."""
|
---|
[70] | 1955 | if not self._departure:
|
---|
[94] | 1956 | if not self._completed:
|
---|
[70] | 1957 | self._wizard.gui.startMonitoring()
|
---|
[107] | 1958 | self._button.set_label(xstr("button_next"))
|
---|
| 1959 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
[94] | 1960 | self.complete()
|
---|
[71] | 1961 |
|
---|
| 1962 | self._wizard.nextPage()
|
---|
| 1963 |
|
---|
[106] | 1964 | def _metarChanged(self, buffer):
|
---|
| 1965 | """Called when the METAR has changed."""
|
---|
[138] | 1966 | if not self._uppercasingMETAR:
|
---|
| 1967 | self.metarEdited = True
|
---|
| 1968 | self._button.set_sensitive(buffer.get_text(buffer.get_start_iter(),
|
---|
| 1969 | buffer.get_end_iter(),
|
---|
| 1970 | True)!="")
|
---|
| 1971 |
|
---|
| 1972 | def _metarInserted(self, textBuffer, iter, text, length):
|
---|
| 1973 | """Called when new characters are inserted into the METAR.
|
---|
| 1974 |
|
---|
| 1975 | It uppercases all characters."""
|
---|
| 1976 | if not self._uppercasingMETAR:
|
---|
| 1977 | self._uppercasingMETAR = True
|
---|
| 1978 |
|
---|
| 1979 | iter1 = iter.copy()
|
---|
| 1980 | iter1.backward_chars(length)
|
---|
| 1981 | textBuffer.delete(iter, iter1)
|
---|
| 1982 |
|
---|
| 1983 | textBuffer.insert(iter, text.upper())
|
---|
| 1984 |
|
---|
| 1985 | self._uppercasingMETAR = False
|
---|
[106] | 1986 |
|
---|
[71] | 1987 | #-----------------------------------------------------------------------------
|
---|
| 1988 |
|
---|
| 1989 | class TakeoffPage(Page):
|
---|
| 1990 | """Page for entering the takeoff data."""
|
---|
| 1991 | def __init__(self, wizard):
|
---|
| 1992 | """Construct the takeoff page."""
|
---|
[107] | 1993 | super(TakeoffPage, self).__init__(wizard, xstr("takeoff_title"),
|
---|
| 1994 | xstr("takeoff_help"),
|
---|
| 1995 | completedHelp = xstr("takeoff_chelp"))
|
---|
[71] | 1996 |
|
---|
[101] | 1997 | self._forwardAllowed = False
|
---|
| 1998 |
|
---|
[71] | 1999 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2000 | xscale = 0.0, yscale = 0.0)
|
---|
| 2001 |
|
---|
[391] | 2002 | table = gtk.Table(8, 4)
|
---|
[71] | 2003 | table.set_row_spacings(4)
|
---|
| 2004 | table.set_col_spacings(16)
|
---|
| 2005 | table.set_homogeneous(False)
|
---|
| 2006 | alignment.add(table)
|
---|
| 2007 | self.setMainWidget(alignment)
|
---|
| 2008 |
|
---|
[107] | 2009 | label = gtk.Label(xstr("takeoff_runway"))
|
---|
[71] | 2010 | label.set_use_underline(True)
|
---|
| 2011 | label.set_alignment(0.0, 0.5)
|
---|
| 2012 | table.attach(label, 0, 1, 0, 1)
|
---|
| 2013 |
|
---|
| 2014 | self._runway = gtk.Entry()
|
---|
| 2015 | self._runway.set_width_chars(10)
|
---|
[107] | 2016 | self._runway.set_tooltip_text(xstr("takeoff_runway_tooltip"))
|
---|
[138] | 2017 | self._runway.connect("changed", self._upperChanged)
|
---|
[84] | 2018 | table.attach(self._runway, 1, 3, 0, 1)
|
---|
[71] | 2019 | label.set_mnemonic_widget(self._runway)
|
---|
[347] | 2020 |
|
---|
[107] | 2021 | label = gtk.Label(xstr("takeoff_sid"))
|
---|
[71] | 2022 | label.set_use_underline(True)
|
---|
| 2023 | label.set_alignment(0.0, 0.5)
|
---|
| 2024 | table.attach(label, 0, 1, 1, 2)
|
---|
| 2025 |
|
---|
| 2026 | self._sid = gtk.Entry()
|
---|
| 2027 | self._sid.set_width_chars(10)
|
---|
[107] | 2028 | self._sid.set_tooltip_text(xstr("takeoff_sid_tooltip"))
|
---|
[138] | 2029 | self._sid.connect("changed", self._upperChanged)
|
---|
[84] | 2030 | table.attach(self._sid, 1, 3, 1, 2)
|
---|
[71] | 2031 | label.set_mnemonic_widget(self._sid)
|
---|
[347] | 2032 |
|
---|
[107] | 2033 | label = gtk.Label(xstr("takeoff_v1"))
|
---|
[71] | 2034 | label.set_use_markup(True)
|
---|
| 2035 | label.set_use_underline(True)
|
---|
| 2036 | label.set_alignment(0.0, 0.5)
|
---|
| 2037 | table.attach(label, 0, 1, 2, 3)
|
---|
| 2038 |
|
---|
[84] | 2039 | self._v1 = IntegerEntry()
|
---|
[86] | 2040 | self._v1.set_width_chars(4)
|
---|
[241] | 2041 | self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip_knots"))
|
---|
[101] | 2042 | self._v1.connect("integer-changed", self._valueChanged)
|
---|
[84] | 2043 | table.attach(self._v1, 2, 3, 2, 3)
|
---|
[71] | 2044 | label.set_mnemonic_widget(self._v1)
|
---|
[241] | 2045 |
|
---|
| 2046 | self._v1Unit = gtk.Label(xstr("label_knots"))
|
---|
[384] | 2047 | self._v1Unit.set_alignment(0.0, 0.5)
|
---|
[241] | 2048 | table.attach(self._v1Unit, 3, 4, 2, 3)
|
---|
[347] | 2049 |
|
---|
[107] | 2050 | label = gtk.Label(xstr("takeoff_vr"))
|
---|
[71] | 2051 | label.set_use_markup(True)
|
---|
| 2052 | label.set_use_underline(True)
|
---|
| 2053 | label.set_alignment(0.0, 0.5)
|
---|
| 2054 | table.attach(label, 0, 1, 3, 4)
|
---|
| 2055 |
|
---|
[84] | 2056 | self._vr = IntegerEntry()
|
---|
[86] | 2057 | self._vr.set_width_chars(4)
|
---|
[241] | 2058 | self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip_knots"))
|
---|
[101] | 2059 | self._vr.connect("integer-changed", self._valueChanged)
|
---|
[84] | 2060 | table.attach(self._vr, 2, 3, 3, 4)
|
---|
[71] | 2061 | label.set_mnemonic_widget(self._vr)
|
---|
[347] | 2062 |
|
---|
[241] | 2063 | self._vrUnit = gtk.Label(xstr("label_knots"))
|
---|
[384] | 2064 | self._vrUnit.set_alignment(0.0, 0.5)
|
---|
[241] | 2065 | table.attach(self._vrUnit, 3, 4, 3, 4)
|
---|
[347] | 2066 |
|
---|
[107] | 2067 | label = gtk.Label(xstr("takeoff_v2"))
|
---|
[71] | 2068 | label.set_use_markup(True)
|
---|
| 2069 | label.set_use_underline(True)
|
---|
| 2070 | label.set_alignment(0.0, 0.5)
|
---|
| 2071 | table.attach(label, 0, 1, 4, 5)
|
---|
| 2072 |
|
---|
[84] | 2073 | self._v2 = IntegerEntry()
|
---|
[86] | 2074 | self._v2.set_width_chars(4)
|
---|
[241] | 2075 | self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip_knots"))
|
---|
[101] | 2076 | self._v2.connect("integer-changed", self._valueChanged)
|
---|
[84] | 2077 | table.attach(self._v2, 2, 3, 4, 5)
|
---|
[71] | 2078 | label.set_mnemonic_widget(self._v2)
|
---|
[347] | 2079 |
|
---|
[241] | 2080 | self._v2Unit = gtk.Label(xstr("label_knots"))
|
---|
[384] | 2081 | self._v2Unit.set_alignment(0.0, 0.5)
|
---|
[241] | 2082 | table.attach(self._v2Unit, 3, 4, 4, 5)
|
---|
[71] | 2083 |
|
---|
[384] | 2084 | self._hasDerate = False
|
---|
| 2085 |
|
---|
| 2086 | self._derateLabel = gtk.Label()
|
---|
| 2087 | self._derateLabel.set_use_underline(True)
|
---|
| 2088 | self._derateLabel.set_markup(xstr("takeoff_derate_tupolev"))
|
---|
| 2089 | self._derateLabel.set_alignment(0.0, 0.5)
|
---|
| 2090 | table.attach(self._derateLabel, 0, 1, 5, 6)
|
---|
| 2091 |
|
---|
| 2092 | self._derate = gtk.Entry()
|
---|
| 2093 | self._derate.set_width_chars(10)
|
---|
| 2094 | self._derate.set_tooltip_text(xstr("takeoff_derate_tooltip"))
|
---|
| 2095 | self._derate.set_alignment(1.0)
|
---|
| 2096 | self._derate.connect("changed", self._derateChanged)
|
---|
| 2097 | table.attach(self._derate, 1, 3, 5, 6)
|
---|
| 2098 | self._derateLabel.set_mnemonic_widget(self._derate)
|
---|
| 2099 |
|
---|
| 2100 | self._derateUnit = gtk.Label("")
|
---|
| 2101 | self._derateUnit.set_use_markup(True)
|
---|
| 2102 | self._derateUnit.set_alignment(0.0, 0.5)
|
---|
| 2103 | table.attach(self._derateUnit, 3, 4, 5, 6)
|
---|
| 2104 |
|
---|
[391] | 2105 | self._antiIceOn = gtk.CheckButton(xstr("takeoff_antiice"))
|
---|
| 2106 | self._antiIceOn.set_use_underline(True)
|
---|
| 2107 | self._antiIceOn.set_tooltip_text(xstr("takeoff_antiice_tooltip"))
|
---|
| 2108 | table.attach(self._antiIceOn, 2, 4, 6, 7)
|
---|
| 2109 |
|
---|
[349] | 2110 | self._rto = gtk.CheckButton(xstr("takeoff_rto"))
|
---|
| 2111 | self._rto.set_use_underline(True)
|
---|
| 2112 | self._rto.set_tooltip_text(xstr("takeoff_rto_tooltip"))
|
---|
| 2113 | self._rto.connect("toggled", self._rtoToggled)
|
---|
[391] | 2114 | table.attach(self._rto, 2, 4, 7, 8, ypadding = 8)
|
---|
[349] | 2115 |
|
---|
[208] | 2116 | self.addCancelFlightButton()
|
---|
| 2117 |
|
---|
[107] | 2118 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2119 |
|
---|
| 2120 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[71] | 2121 |
|
---|
[84] | 2122 | @property
|
---|
[97] | 2123 | def runway(self):
|
---|
| 2124 | """Get the runway."""
|
---|
| 2125 | return self._runway.get_text()
|
---|
| 2126 |
|
---|
| 2127 | @property
|
---|
| 2128 | def sid(self):
|
---|
| 2129 | """Get the SID."""
|
---|
| 2130 | return self._sid.get_text()
|
---|
| 2131 |
|
---|
| 2132 | @property
|
---|
[84] | 2133 | def v1(self):
|
---|
| 2134 | """Get the v1 speed."""
|
---|
| 2135 | return self._v1.get_int()
|
---|
| 2136 |
|
---|
| 2137 | @property
|
---|
| 2138 | def vr(self):
|
---|
| 2139 | """Get the vr speed."""
|
---|
| 2140 | return self._vr.get_int()
|
---|
| 2141 |
|
---|
| 2142 | @property
|
---|
| 2143 | def v2(self):
|
---|
| 2144 | """Get the v2 speed."""
|
---|
| 2145 | return self._v2.get_int()
|
---|
| 2146 |
|
---|
[349] | 2147 | @property
|
---|
[384] | 2148 | def derate(self):
|
---|
| 2149 | """Get the derate value, if any."""
|
---|
| 2150 | if self._hasDerate:
|
---|
| 2151 | derate = self._derate.get_text()
|
---|
| 2152 | return derate if derate else None
|
---|
| 2153 | else:
|
---|
| 2154 | return None
|
---|
| 2155 |
|
---|
| 2156 | @property
|
---|
[391] | 2157 | def antiIceOn(self):
|
---|
| 2158 | """Get whether the anti-ice system has been turned on."""
|
---|
| 2159 | return self._antiIceOn.get_active()
|
---|
| 2160 |
|
---|
| 2161 | @antiIceOn.setter
|
---|
| 2162 | def antiIceOn(self, value):
|
---|
| 2163 | """Set the anti-ice indicator."""
|
---|
| 2164 | self._antiIceOn.set_active(value)
|
---|
| 2165 |
|
---|
| 2166 | @property
|
---|
[349] | 2167 | def rtoIndicated(self):
|
---|
| 2168 | """Get whether the pilot has indicated if there was an RTO."""
|
---|
| 2169 | return self._rto.get_active()
|
---|
| 2170 |
|
---|
[71] | 2171 | def activate(self):
|
---|
| 2172 | """Activate the page."""
|
---|
[72] | 2173 | self._runway.set_text("")
|
---|
[71] | 2174 | self._runway.set_sensitive(True)
|
---|
[72] | 2175 | self._sid.set_text("")
|
---|
[71] | 2176 | self._sid.set_sensitive(True)
|
---|
[84] | 2177 | self._v1.set_int(None)
|
---|
[71] | 2178 | self._v1.set_sensitive(True)
|
---|
[86] | 2179 | self._vr.set_int(None)
|
---|
[71] | 2180 | self._vr.set_sensitive(True)
|
---|
[86] | 2181 | self._v2.set_int(None)
|
---|
[71] | 2182 | self._v2.set_sensitive(True)
|
---|
[241] | 2183 |
|
---|
| 2184 | i18nSpeedUnit = self._wizard.gui.flight.getI18NSpeedUnit()
|
---|
| 2185 | speedUnit = xstr("label" + i18nSpeedUnit)
|
---|
| 2186 | self._v1Unit.set_text(speedUnit)
|
---|
| 2187 | self._vrUnit.set_text(speedUnit)
|
---|
| 2188 | self._v2Unit.set_text(speedUnit)
|
---|
| 2189 |
|
---|
| 2190 | self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip" + i18nSpeedUnit))
|
---|
| 2191 | self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip" + i18nSpeedUnit))
|
---|
| 2192 | self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip" + i18nSpeedUnit))
|
---|
| 2193 |
|
---|
[384] | 2194 | (derateLabel, derateUnit) = \
|
---|
| 2195 | self._wizard.gui.flight.aircraft.derateLabels
|
---|
| 2196 |
|
---|
| 2197 | self._hasDerate = derateLabel is not None
|
---|
| 2198 |
|
---|
| 2199 | if self._hasDerate:
|
---|
| 2200 | self._derateLabel.set_markup(derateLabel)
|
---|
| 2201 | self._derateLabel.set_use_underline(True)
|
---|
| 2202 | self._derateUnit.set_markup("" if derateUnit is None
|
---|
| 2203 | else derateUnit)
|
---|
| 2204 | else:
|
---|
| 2205 | self._derateLabel.set_markup(xstr("takeoff_derate"))
|
---|
| 2206 | self._derateUnit.set_text("")
|
---|
| 2207 |
|
---|
| 2208 | self._derate.set_text("")
|
---|
| 2209 |
|
---|
| 2210 | self._derateLabel.set_sensitive(self._hasDerate)
|
---|
| 2211 | self._derate.set_sensitive(self._hasDerate)
|
---|
| 2212 | self._derateUnit.set_sensitive(self._hasDerate)
|
---|
| 2213 |
|
---|
[349] | 2214 | self._rto.set_active(False)
|
---|
| 2215 | self._rto.set_sensitive(False)
|
---|
| 2216 |
|
---|
[84] | 2217 | self._button.set_sensitive(False)
|
---|
[218] | 2218 | self._forwardAllowed = False
|
---|
[347] | 2219 |
|
---|
[101] | 2220 | def allowForward(self):
|
---|
| 2221 | """Allow going to the next page."""
|
---|
| 2222 | self._forwardAllowed = True
|
---|
| 2223 | self._updateForwardButton()
|
---|
| 2224 |
|
---|
[241] | 2225 | def reset(self):
|
---|
| 2226 | """Reset the page if the wizard is reset."""
|
---|
| 2227 | super(TakeoffPage, self).reset()
|
---|
| 2228 | self._v1.reset()
|
---|
| 2229 | self._vr.reset()
|
---|
| 2230 | self._v2.reset()
|
---|
[384] | 2231 | self._hasDerate = False
|
---|
[391] | 2232 | self._antiIceOn.set_active(False)
|
---|
[384] | 2233 |
|
---|
[349] | 2234 | def setRTOEnabled(self, enabled):
|
---|
| 2235 | """Set the RTO checkbox enabled or disabled."""
|
---|
| 2236 | if not enabled:
|
---|
| 2237 | self._rto.set_active(False)
|
---|
| 2238 | self._rto.set_sensitive(enabled)
|
---|
| 2239 |
|
---|
[101] | 2240 | def _updateForwardButton(self):
|
---|
| 2241 | """Update the sensitivity of the forward button based on some conditions."""
|
---|
| 2242 | sensitive = self._forwardAllowed and \
|
---|
| 2243 | self._runway.get_text()!="" and \
|
---|
| 2244 | self._sid.get_text()!="" and \
|
---|
| 2245 | self.v1 is not None and \
|
---|
| 2246 | self.vr is not None and \
|
---|
| 2247 | self.v2 is not None and \
|
---|
| 2248 | self.v1 <= self.vr and \
|
---|
[384] | 2249 | self.vr <= self.v2 and \
|
---|
| 2250 | (not self._hasDerate or self._derate.get_text()!="")
|
---|
[101] | 2251 | self._button.set_sensitive(sensitive)
|
---|
| 2252 |
|
---|
| 2253 | def _valueChanged(self, widget, arg = None):
|
---|
| 2254 | """Called when the value of some widget has changed."""
|
---|
| 2255 | self._updateForwardButton()
|
---|
[347] | 2256 |
|
---|
[138] | 2257 | def _upperChanged(self, entry, arg = None):
|
---|
| 2258 | """Called when the value of some entry widget has changed and the value
|
---|
| 2259 | should be converted to uppercase."""
|
---|
| 2260 | entry.set_text(entry.get_text().upper())
|
---|
| 2261 | self._valueChanged(entry, arg)
|
---|
[347] | 2262 |
|
---|
[384] | 2263 | def _derateChanged(self, entry):
|
---|
| 2264 | """Called when the value of the derate is changed."""
|
---|
| 2265 | self._updateForwardButton()
|
---|
| 2266 |
|
---|
[349] | 2267 | def _rtoToggled(self, button):
|
---|
| 2268 | """Called when the RTO check button is toggled."""
|
---|
| 2269 | self._wizard.rtoToggled(button.get_active())
|
---|
| 2270 |
|
---|
[71] | 2271 | def _backClicked(self, button):
|
---|
| 2272 | """Called when the Back button is pressed."""
|
---|
| 2273 | self.goBack()
|
---|
[347] | 2274 |
|
---|
[71] | 2275 | def _forwardClicked(self, button):
|
---|
| 2276 | """Called when the forward button is clicked."""
|
---|
[391] | 2277 | aircraft = self._wizard.gui.flight.aircraft
|
---|
| 2278 | aircraft.updateV1R2()
|
---|
[384] | 2279 | if self._hasDerate:
|
---|
[391] | 2280 | aircraft.updateDerate()
|
---|
| 2281 | aircraft.updateTakeoffAntiIce()
|
---|
[75] | 2282 | self._wizard.nextPage()
|
---|
| 2283 |
|
---|
| 2284 | #-----------------------------------------------------------------------------
|
---|
| 2285 |
|
---|
[383] | 2286 | class CruisePage(Page):
|
---|
| 2287 | """The page containing the flight level that might change during flight."""
|
---|
| 2288 | def __init__(self, wizard):
|
---|
| 2289 | """Construct the page."""
|
---|
| 2290 | super(CruisePage, self).__init__(wizard, xstr("cruise_title"),
|
---|
| 2291 | xstr("cruise_help"))
|
---|
| 2292 |
|
---|
| 2293 | self._loggable = False
|
---|
| 2294 | self._loggedCruiseLevel = 240
|
---|
| 2295 | self._activated = False
|
---|
| 2296 |
|
---|
| 2297 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
| 2298 | xscale = 0.0, yscale = 1.0)
|
---|
| 2299 |
|
---|
| 2300 | mainBox = gtk.VBox()
|
---|
| 2301 | alignment.add(mainBox)
|
---|
| 2302 | self.setMainWidget(alignment)
|
---|
| 2303 |
|
---|
| 2304 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 2305 | xscale = 0.0, yscale = 0.0)
|
---|
| 2306 | mainBox.pack_start(alignment, False, False, 16)
|
---|
| 2307 |
|
---|
| 2308 | levelBox = gtk.HBox()
|
---|
| 2309 |
|
---|
| 2310 | label = gtk.Label(xstr("route_level"))
|
---|
| 2311 | label.set_use_underline(True)
|
---|
| 2312 | levelBox.pack_start(label, True, True, 0)
|
---|
| 2313 |
|
---|
| 2314 | self._cruiseLevel = gtk.SpinButton()
|
---|
| 2315 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
| 2316 | self._cruiseLevel.set_range(min = 50, max = 500)
|
---|
| 2317 | self._cruiseLevel.set_tooltip_text(xstr("cruise_route_level_tooltip"))
|
---|
| 2318 | self._cruiseLevel.set_numeric(True)
|
---|
| 2319 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
| 2320 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
| 2321 |
|
---|
| 2322 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
| 2323 |
|
---|
| 2324 | self._updateButton = gtk.Button(xstr("cruise_route_level_update"));
|
---|
| 2325 | self._updateButton.set_use_underline(True)
|
---|
| 2326 | self._updateButton.set_tooltip_text(xstr("cruise_route_level_update_tooltip"))
|
---|
| 2327 | self._updateButton.connect("clicked", self._updateButtonClicked)
|
---|
| 2328 |
|
---|
| 2329 | levelBox.pack_start(self._updateButton, False, False, 16)
|
---|
| 2330 |
|
---|
| 2331 | mainBox.pack_start(levelBox, False, False, 0)
|
---|
| 2332 |
|
---|
| 2333 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 2334 | xscale = 0.0, yscale = 1.0)
|
---|
| 2335 | mainBox.pack_start(alignment, True, True, 0)
|
---|
| 2336 |
|
---|
| 2337 | self.addCancelFlightButton()
|
---|
| 2338 |
|
---|
| 2339 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2340 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 2341 |
|
---|
| 2342 | @property
|
---|
| 2343 | def activated(self):
|
---|
| 2344 | """Determine if the page is already activated or not."""
|
---|
| 2345 | return self._activated
|
---|
| 2346 |
|
---|
| 2347 | @property
|
---|
| 2348 | def cruiseLevel(self):
|
---|
| 2349 | """Get the cruise level."""
|
---|
| 2350 | return self._loggedCruiseLevel
|
---|
| 2351 |
|
---|
| 2352 | @property
|
---|
| 2353 | def loggableCruiseLevel(self):
|
---|
| 2354 | """Get the cruise level which should be logged."""
|
---|
| 2355 | return self._cruiseLevel.get_value_as_int()
|
---|
| 2356 |
|
---|
| 2357 | def setLoggable(self, loggable):
|
---|
| 2358 | """Set whether the cruise altitude can be logged."""
|
---|
| 2359 | self._loggable = loggable
|
---|
| 2360 | self._updateButtons()
|
---|
| 2361 |
|
---|
| 2362 | def activate(self):
|
---|
| 2363 | """Setup the route from the booked flight."""
|
---|
| 2364 | self._loggedCruiseLevel = self._wizard.filedCruiseLevel
|
---|
| 2365 | self._cruiseLevel.set_value(self._loggedCruiseLevel)
|
---|
| 2366 | self._activated = True
|
---|
| 2367 |
|
---|
| 2368 | def reset(self):
|
---|
| 2369 | """Reset the page."""
|
---|
| 2370 | self._loggable = False
|
---|
| 2371 | self._activated = False
|
---|
| 2372 | super(CruisePage, self).reset()
|
---|
| 2373 |
|
---|
| 2374 | def _updateButtons(self):
|
---|
| 2375 | """Update the sensitivity of the buttons."""
|
---|
| 2376 | self._updateButton.set_sensitive(self._loggable and
|
---|
| 2377 | self.loggableCruiseLevel!=
|
---|
| 2378 | self._loggedCruiseLevel)
|
---|
| 2379 |
|
---|
| 2380 | def _cruiseLevelChanged(self, spinButton):
|
---|
| 2381 | """Called when the cruise level has changed."""
|
---|
| 2382 | self._updateButtons()
|
---|
| 2383 |
|
---|
| 2384 | def _updateButtonClicked(self, button):
|
---|
| 2385 | """Called when the update button is clicked."""
|
---|
| 2386 | if self._wizard.cruiseLevelChanged():
|
---|
| 2387 | self._loggedCruiseLevel = self.loggableCruiseLevel
|
---|
| 2388 | self._updateButtons()
|
---|
| 2389 |
|
---|
| 2390 | def _backClicked(self, button):
|
---|
| 2391 | """Called when the Back button is pressed."""
|
---|
| 2392 | self.goBack()
|
---|
| 2393 |
|
---|
| 2394 | def _forwardClicked(self, button):
|
---|
| 2395 | """Called when the Forward button is clicked."""
|
---|
| 2396 | self._wizard.nextPage()
|
---|
| 2397 |
|
---|
| 2398 | #-----------------------------------------------------------------------------
|
---|
| 2399 |
|
---|
[75] | 2400 | class LandingPage(Page):
|
---|
| 2401 | """Page for entering landing data."""
|
---|
| 2402 | def __init__(self, wizard):
|
---|
| 2403 | """Construct the landing page."""
|
---|
[107] | 2404 | super(LandingPage, self).__init__(wizard, xstr("landing_title"),
|
---|
| 2405 | xstr("landing_help"),
|
---|
| 2406 | completedHelp = xstr("landing_chelp"))
|
---|
[75] | 2407 |
|
---|
[88] | 2408 | self._flightEnded = False
|
---|
| 2409 |
|
---|
[75] | 2410 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2411 | xscale = 0.0, yscale = 0.0)
|
---|
| 2412 |
|
---|
[391] | 2413 | table = gtk.Table(6, 5)
|
---|
[75] | 2414 | table.set_row_spacings(4)
|
---|
| 2415 | table.set_col_spacings(16)
|
---|
| 2416 | table.set_homogeneous(False)
|
---|
| 2417 | alignment.add(table)
|
---|
| 2418 | self.setMainWidget(alignment)
|
---|
| 2419 |
|
---|
| 2420 | self._starButton = gtk.CheckButton()
|
---|
| 2421 | self._starButton.connect("clicked", self._starButtonClicked)
|
---|
| 2422 | table.attach(self._starButton, 0, 1, 0, 1)
|
---|
| 2423 |
|
---|
[107] | 2424 | label = gtk.Label(xstr("landing_star"))
|
---|
[75] | 2425 | label.set_use_underline(True)
|
---|
| 2426 | label.set_alignment(0.0, 0.5)
|
---|
| 2427 | table.attach(label, 1, 2, 0, 1)
|
---|
| 2428 |
|
---|
| 2429 | self._star = gtk.Entry()
|
---|
| 2430 | self._star.set_width_chars(10)
|
---|
[107] | 2431 | self._star.set_tooltip_text(xstr("landing_star_tooltip"))
|
---|
[138] | 2432 | self._star.connect("changed", self._upperChanged)
|
---|
[75] | 2433 | self._star.set_sensitive(False)
|
---|
[86] | 2434 | table.attach(self._star, 2, 4, 0, 1)
|
---|
[75] | 2435 | label.set_mnemonic_widget(self._starButton)
|
---|
| 2436 |
|
---|
| 2437 | self._transitionButton = gtk.CheckButton()
|
---|
| 2438 | self._transitionButton.connect("clicked", self._transitionButtonClicked)
|
---|
| 2439 | table.attach(self._transitionButton, 0, 1, 1, 2)
|
---|
| 2440 |
|
---|
[107] | 2441 | label = gtk.Label(xstr("landing_transition"))
|
---|
[75] | 2442 | label.set_use_underline(True)
|
---|
| 2443 | label.set_alignment(0.0, 0.5)
|
---|
| 2444 | table.attach(label, 1, 2, 1, 2)
|
---|
| 2445 |
|
---|
| 2446 | self._transition = gtk.Entry()
|
---|
| 2447 | self._transition.set_width_chars(10)
|
---|
[107] | 2448 | self._transition.set_tooltip_text(xstr("landing_transition_tooltip"))
|
---|
[138] | 2449 | self._transition.connect("changed", self._upperChanged)
|
---|
[75] | 2450 | self._transition.set_sensitive(False)
|
---|
[86] | 2451 | table.attach(self._transition, 2, 4, 1, 2)
|
---|
[75] | 2452 | label.set_mnemonic_widget(self._transitionButton)
|
---|
| 2453 |
|
---|
[107] | 2454 | label = gtk.Label(xstr("landing_runway"))
|
---|
[75] | 2455 | label.set_use_underline(True)
|
---|
| 2456 | label.set_alignment(0.0, 0.5)
|
---|
| 2457 | table.attach(label, 1, 2, 2, 3)
|
---|
| 2458 |
|
---|
| 2459 | self._runway = gtk.Entry()
|
---|
| 2460 | self._runway.set_width_chars(10)
|
---|
[107] | 2461 | self._runway.set_tooltip_text(xstr("landing_runway_tooltip"))
|
---|
[138] | 2462 | self._runway.connect("changed", self._upperChanged)
|
---|
[86] | 2463 | table.attach(self._runway, 2, 4, 2, 3)
|
---|
[75] | 2464 | label.set_mnemonic_widget(self._runway)
|
---|
| 2465 |
|
---|
[107] | 2466 | label = gtk.Label(xstr("landing_approach"))
|
---|
[75] | 2467 | label.set_use_underline(True)
|
---|
| 2468 | label.set_alignment(0.0, 0.5)
|
---|
| 2469 | table.attach(label, 1, 2, 3, 4)
|
---|
| 2470 |
|
---|
| 2471 | self._approachType = gtk.Entry()
|
---|
| 2472 | self._approachType.set_width_chars(10)
|
---|
[107] | 2473 | self._approachType.set_tooltip_text(xstr("landing_approach_tooltip"))
|
---|
[138] | 2474 | self._approachType.connect("changed", self._upperChanged)
|
---|
[86] | 2475 | table.attach(self._approachType, 2, 4, 3, 4)
|
---|
[75] | 2476 | label.set_mnemonic_widget(self._approachType)
|
---|
| 2477 |
|
---|
[107] | 2478 | label = gtk.Label(xstr("landing_vref"))
|
---|
[75] | 2479 | label.set_use_markup(True)
|
---|
| 2480 | label.set_use_underline(True)
|
---|
| 2481 | label.set_alignment(0.0, 0.5)
|
---|
[391] | 2482 | table.attach(label, 1, 2, 4, 5)
|
---|
[75] | 2483 |
|
---|
[86] | 2484 | self._vref = IntegerEntry()
|
---|
| 2485 | self._vref.set_width_chars(5)
|
---|
[241] | 2486 | self._vref.set_tooltip_markup(xstr("landing_vref_tooltip_knots"))
|
---|
[86] | 2487 | self._vref.connect("integer-changed", self._vrefChanged)
|
---|
[391] | 2488 | table.attach(self._vref, 3, 4, 4, 5)
|
---|
[75] | 2489 | label.set_mnemonic_widget(self._vref)
|
---|
[241] | 2490 |
|
---|
| 2491 | self._vrefUnit = gtk.Label(xstr("label_knots"))
|
---|
[391] | 2492 | table.attach(self._vrefUnit, 4, 5, 4, 5)
|
---|
| 2493 |
|
---|
| 2494 | self._antiIceOn = gtk.CheckButton(xstr("landing_antiice"))
|
---|
| 2495 | self._antiIceOn.set_use_underline(True)
|
---|
| 2496 | self._antiIceOn.set_tooltip_text(xstr("landing_antiice_tooltip"))
|
---|
| 2497 | table.attach(self._antiIceOn, 3, 5, 5, 6)
|
---|
[75] | 2498 |
|
---|
[208] | 2499 | self.addCancelFlightButton()
|
---|
| 2500 |
|
---|
[107] | 2501 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 2502 |
|
---|
| 2503 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[75] | 2504 |
|
---|
[76] | 2505 | # These are needed for correct size calculations
|
---|
| 2506 | self._starButton.set_active(True)
|
---|
| 2507 | self._transitionButton.set_active(True)
|
---|
| 2508 |
|
---|
[86] | 2509 | @property
|
---|
[97] | 2510 | def star(self):
|
---|
| 2511 | """Get the STAR or None if none entered."""
|
---|
| 2512 | return self._star.get_text() if self._starButton.get_active() else None
|
---|
| 2513 |
|
---|
| 2514 | @property
|
---|
| 2515 | def transition(self):
|
---|
| 2516 | """Get the transition or None if none entered."""
|
---|
| 2517 | return self._transition.get_text() \
|
---|
| 2518 | if self._transitionButton.get_active() else None
|
---|
| 2519 |
|
---|
| 2520 | @property
|
---|
| 2521 | def approachType(self):
|
---|
| 2522 | """Get the approach type."""
|
---|
| 2523 | return self._approachType.get_text()
|
---|
| 2524 |
|
---|
| 2525 | @property
|
---|
| 2526 | def runway(self):
|
---|
| 2527 | """Get the runway."""
|
---|
| 2528 | return self._runway.get_text()
|
---|
| 2529 |
|
---|
| 2530 | @property
|
---|
[86] | 2531 | def vref(self):
|
---|
| 2532 | """Return the landing reference speed."""
|
---|
| 2533 | return self._vref.get_int()
|
---|
| 2534 |
|
---|
[391] | 2535 | @property
|
---|
| 2536 | def antiIceOn(self):
|
---|
| 2537 | """Get whether the anti-ice system has been turned on."""
|
---|
| 2538 | return self._antiIceOn.get_active()
|
---|
| 2539 |
|
---|
| 2540 | @antiIceOn.setter
|
---|
| 2541 | def antiIceOn(self, value):
|
---|
| 2542 | """Set the anti-ice indicator."""
|
---|
| 2543 | self._antiIceOn.set_active(value)
|
---|
| 2544 |
|
---|
[218] | 2545 | def reset(self):
|
---|
| 2546 | """Reset the page if the wizard is reset."""
|
---|
| 2547 | super(LandingPage, self).reset()
|
---|
[241] | 2548 | self._vref.reset()
|
---|
[391] | 2549 | self._antiIceOn.set_active(False)
|
---|
[218] | 2550 | self._flightEnded = False
|
---|
[347] | 2551 |
|
---|
[75] | 2552 | def activate(self):
|
---|
| 2553 | """Called when the page is activated."""
|
---|
| 2554 | self._starButton.set_sensitive(True)
|
---|
| 2555 | self._starButton.set_active(False)
|
---|
| 2556 | self._star.set_text("")
|
---|
| 2557 |
|
---|
| 2558 | self._transitionButton.set_sensitive(True)
|
---|
| 2559 | self._transitionButton.set_active(False)
|
---|
| 2560 | self._transition.set_text("")
|
---|
| 2561 |
|
---|
| 2562 | self._runway.set_text("")
|
---|
| 2563 | self._runway.set_sensitive(True)
|
---|
| 2564 |
|
---|
| 2565 | self._approachType.set_text("")
|
---|
| 2566 | self._approachType.set_sensitive(True)
|
---|
| 2567 |
|
---|
[86] | 2568 | self._vref.set_int(None)
|
---|
[75] | 2569 | self._vref.set_sensitive(True)
|
---|
| 2570 |
|
---|
[241] | 2571 | i18nSpeedUnit = self._wizard.gui.flight.getI18NSpeedUnit()
|
---|
| 2572 | speedUnit = xstr("label" + i18nSpeedUnit)
|
---|
| 2573 | self._vrefUnit.set_text(speedUnit)
|
---|
| 2574 |
|
---|
| 2575 | self._vref.set_tooltip_markup(xstr("landing_vref_tooltip" +
|
---|
| 2576 | i18nSpeedUnit))
|
---|
| 2577 |
|
---|
[75] | 2578 | self._updateForwardButton()
|
---|
| 2579 |
|
---|
[88] | 2580 | def flightEnded(self):
|
---|
| 2581 | """Called when the flight has ended."""
|
---|
[275] | 2582 | super(LandingPage, self).flightEnded()
|
---|
[88] | 2583 | self._flightEnded = True
|
---|
| 2584 | self._updateForwardButton()
|
---|
| 2585 |
|
---|
[75] | 2586 | def _starButtonClicked(self, button):
|
---|
| 2587 | """Called when the STAR button is clicked."""
|
---|
| 2588 | active = button.get_active()
|
---|
| 2589 | self._star.set_sensitive(active)
|
---|
| 2590 | if active:
|
---|
| 2591 | self._star.grab_focus()
|
---|
| 2592 | self._updateForwardButton()
|
---|
| 2593 |
|
---|
| 2594 | def _transitionButtonClicked(self, button):
|
---|
| 2595 | """Called when the Transition button is clicked."""
|
---|
| 2596 | active = button.get_active()
|
---|
| 2597 | self._transition.set_sensitive(active)
|
---|
| 2598 | if active:
|
---|
[347] | 2599 | self._transition.grab_focus()
|
---|
| 2600 | self._updateForwardButton()
|
---|
[75] | 2601 |
|
---|
[138] | 2602 | def _updateForwardButton(self):
|
---|
[75] | 2603 | """Update the sensitivity of the forward button."""
|
---|
[88] | 2604 | sensitive = self._flightEnded and \
|
---|
| 2605 | (self._starButton.get_active() or \
|
---|
[75] | 2606 | self._transitionButton.get_active()) and \
|
---|
| 2607 | (self._star.get_text()!="" or
|
---|
| 2608 | not self._starButton.get_active()) and \
|
---|
| 2609 | (self._transition.get_text()!="" or
|
---|
| 2610 | not self._transitionButton.get_active()) and \
|
---|
| 2611 | self._runway.get_text()!="" and \
|
---|
[86] | 2612 | self._approachType.get_text()!="" and \
|
---|
| 2613 | self.vref is not None
|
---|
[75] | 2614 | self._button.set_sensitive(sensitive)
|
---|
| 2615 |
|
---|
[138] | 2616 | def _upperChanged(self, entry):
|
---|
| 2617 | """Called for entry widgets that must be converted to uppercase."""
|
---|
| 2618 | entry.set_text(entry.get_text().upper())
|
---|
| 2619 | self._updateForwardButton()
|
---|
| 2620 |
|
---|
[86] | 2621 | def _vrefChanged(self, widget, value):
|
---|
| 2622 | """Called when the Vref has changed."""
|
---|
| 2623 | self._updateForwardButton()
|
---|
| 2624 |
|
---|
[75] | 2625 | def _backClicked(self, button):
|
---|
| 2626 | """Called when the Back button is pressed."""
|
---|
| 2627 | self.goBack()
|
---|
[347] | 2628 |
|
---|
[75] | 2629 | def _forwardClicked(self, button):
|
---|
| 2630 | """Called when the forward button is clicked."""
|
---|
[391] | 2631 | aircraft = self._wizard.gui.flight.aircraft
|
---|
| 2632 | aircraft.updateVRef()
|
---|
| 2633 | aircraft.updateLandingAntiIce()
|
---|
[136] | 2634 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 2635 | self._wizard.loggedIn and not self._completed and \
|
---|
[184] | 2636 | self._wizard.bookedFlight.arrivalICAO=="LHBP" and \
|
---|
| 2637 | not self._wizard.entranceExam:
|
---|
[130] | 2638 | self._wizard.getFleet(callback = self._fleetRetrieved,
|
---|
| 2639 | force = True)
|
---|
| 2640 | else:
|
---|
| 2641 | self._wizard.nextPage()
|
---|
| 2642 |
|
---|
| 2643 | def _fleetRetrieved(self, fleet):
|
---|
| 2644 | """Callback for the fleet retrieval."""
|
---|
[89] | 2645 | self._wizard.nextPage()
|
---|
| 2646 |
|
---|
| 2647 | #-----------------------------------------------------------------------------
|
---|
| 2648 |
|
---|
| 2649 | class FinishPage(Page):
|
---|
| 2650 | """Flight finish page."""
|
---|
[107] | 2651 | _flightTypes = [ ("flighttype_scheduled", const.FLIGHTTYPE_SCHEDULED),
|
---|
| 2652 | ("flighttype_ot", const.FLIGHTTYPE_OLDTIMER),
|
---|
| 2653 | ("flighttype_vip", const.FLIGHTTYPE_VIP),
|
---|
| 2654 | ("flighttype_charter", const.FLIGHTTYPE_CHARTER) ]
|
---|
[347] | 2655 |
|
---|
[89] | 2656 | def __init__(self, wizard):
|
---|
| 2657 | """Construct the finish page."""
|
---|
[107] | 2658 | super(FinishPage, self).__init__(wizard, xstr("finish_title"),
|
---|
| 2659 | xstr("finish_help"))
|
---|
[347] | 2660 |
|
---|
[89] | 2661 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2662 | xscale = 0.0, yscale = 0.0)
|
---|
| 2663 |
|
---|
[130] | 2664 | table = gtk.Table(8, 2)
|
---|
[89] | 2665 | table.set_row_spacings(4)
|
---|
| 2666 | table.set_col_spacings(16)
|
---|
[96] | 2667 | table.set_homogeneous(False)
|
---|
[89] | 2668 | alignment.add(table)
|
---|
| 2669 | self.setMainWidget(alignment)
|
---|
| 2670 |
|
---|
| 2671 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2672 | label = gtk.Label(xstr("finish_rating"))
|
---|
[89] | 2673 | labelAlignment.add(label)
|
---|
| 2674 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 2675 |
|
---|
| 2676 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2677 | self._flightRating = gtk.Label()
|
---|
[154] | 2678 | self._flightRating.set_width_chars(8)
|
---|
[89] | 2679 | self._flightRating.set_alignment(0.0, 0.5)
|
---|
| 2680 | self._flightRating.set_use_markup(True)
|
---|
| 2681 | labelAlignment.add(self._flightRating)
|
---|
| 2682 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
| 2683 |
|
---|
| 2684 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2685 | label = gtk.Label(xstr("finish_flight_time"))
|
---|
[89] | 2686 | labelAlignment.add(label)
|
---|
| 2687 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 2688 |
|
---|
| 2689 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2690 | self._flightTime = gtk.Label()
|
---|
| 2691 | self._flightTime.set_width_chars(10)
|
---|
| 2692 | self._flightTime.set_alignment(0.0, 0.5)
|
---|
| 2693 | self._flightTime.set_use_markup(True)
|
---|
| 2694 | labelAlignment.add(self._flightTime)
|
---|
| 2695 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
| 2696 |
|
---|
| 2697 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2698 | label = gtk.Label(xstr("finish_block_time"))
|
---|
[89] | 2699 | labelAlignment.add(label)
|
---|
| 2700 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
| 2701 |
|
---|
| 2702 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2703 | self._blockTime = gtk.Label()
|
---|
| 2704 | self._blockTime.set_width_chars(10)
|
---|
| 2705 | self._blockTime.set_alignment(0.0, 0.5)
|
---|
| 2706 | self._blockTime.set_use_markup(True)
|
---|
| 2707 | labelAlignment.add(self._blockTime)
|
---|
| 2708 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
| 2709 |
|
---|
| 2710 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2711 | label = gtk.Label(xstr("finish_distance"))
|
---|
[89] | 2712 | labelAlignment.add(label)
|
---|
| 2713 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
| 2714 |
|
---|
| 2715 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2716 | self._distanceFlown = gtk.Label()
|
---|
| 2717 | self._distanceFlown.set_width_chars(10)
|
---|
| 2718 | self._distanceFlown.set_alignment(0.0, 0.5)
|
---|
| 2719 | self._distanceFlown.set_use_markup(True)
|
---|
| 2720 | labelAlignment.add(self._distanceFlown)
|
---|
| 2721 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
[347] | 2722 |
|
---|
[89] | 2723 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2724 | label = gtk.Label(xstr("finish_fuel"))
|
---|
[89] | 2725 | labelAlignment.add(label)
|
---|
| 2726 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
| 2727 |
|
---|
| 2728 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2729 | self._fuelUsed = gtk.Label()
|
---|
| 2730 | self._fuelUsed.set_width_chars(10)
|
---|
| 2731 | self._fuelUsed.set_alignment(0.0, 0.5)
|
---|
| 2732 | self._fuelUsed.set_use_markup(True)
|
---|
| 2733 | labelAlignment.add(self._fuelUsed)
|
---|
| 2734 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
| 2735 |
|
---|
[107] | 2736 | labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0,
|
---|
| 2737 | yalign = 0.5, yscale = 0.0)
|
---|
| 2738 | label = gtk.Label(xstr("finish_type"))
|
---|
[96] | 2739 | label.set_use_underline(True)
|
---|
| 2740 | labelAlignment.add(label)
|
---|
| 2741 | table.attach(labelAlignment, 0, 1, 5, 6)
|
---|
| 2742 |
|
---|
| 2743 | flightTypeModel = gtk.ListStore(str, int)
|
---|
[97] | 2744 | for (name, type) in FinishPage._flightTypes:
|
---|
[107] | 2745 | flightTypeModel.append([xstr(name), type])
|
---|
[96] | 2746 |
|
---|
| 2747 | self._flightType = gtk.ComboBox(model = flightTypeModel)
|
---|
| 2748 | renderer = gtk.CellRendererText()
|
---|
| 2749 | self._flightType.pack_start(renderer, True)
|
---|
| 2750 | self._flightType.add_attribute(renderer, "text", 0)
|
---|
[107] | 2751 | self._flightType.set_tooltip_text(xstr("finish_type_tooltip"))
|
---|
[96] | 2752 | self._flightType.set_active(0)
|
---|
| 2753 | self._flightType.connect("changed", self._flightTypeChanged)
|
---|
| 2754 | flightTypeAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2755 | flightTypeAlignment.add(self._flightType)
|
---|
| 2756 | table.attach(flightTypeAlignment, 1, 2, 5, 6)
|
---|
[347] | 2757 | label.set_mnemonic_widget(self._flightType)
|
---|
[96] | 2758 |
|
---|
[107] | 2759 | self._onlineFlight = gtk.CheckButton(xstr("finish_online"))
|
---|
[96] | 2760 | self._onlineFlight.set_use_underline(True)
|
---|
[107] | 2761 | self._onlineFlight.set_tooltip_text(xstr("finish_online_tooltip"))
|
---|
[96] | 2762 | onlineFlightAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2763 | onlineFlightAlignment.add(self._onlineFlight)
|
---|
| 2764 | table.attach(onlineFlightAlignment, 1, 2, 6, 7)
|
---|
| 2765 |
|
---|
[130] | 2766 | labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0,
|
---|
| 2767 | yalign = 0.5, yscale = 0.0)
|
---|
| 2768 | self._gateLabel = gtk.Label(xstr("finish_gate"))
|
---|
| 2769 | self._gateLabel.set_use_underline(True)
|
---|
| 2770 | labelAlignment.add(self._gateLabel)
|
---|
| 2771 | table.attach(labelAlignment, 0, 1, 7, 8)
|
---|
| 2772 |
|
---|
| 2773 | self._gatesModel = gtk.ListStore(str)
|
---|
| 2774 |
|
---|
| 2775 | self._gate = gtk.ComboBox(model = self._gatesModel)
|
---|
| 2776 | renderer = gtk.CellRendererText()
|
---|
| 2777 | self._gate.pack_start(renderer, True)
|
---|
| 2778 | self._gate.add_attribute(renderer, "text", 0)
|
---|
| 2779 | self._gate.set_tooltip_text(xstr("finish_gate_tooltip"))
|
---|
[347] | 2780 | self._gate.connect("changed", self._gateChanged)
|
---|
[130] | 2781 | gateAlignment = gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 2782 | gateAlignment.add(self._gate)
|
---|
| 2783 | table.attach(gateAlignment, 1, 2, 7, 8)
|
---|
| 2784 | self._gateLabel.set_mnemonic_widget(self._gate)
|
---|
| 2785 |
|
---|
[208] | 2786 | self.addButton(xstr("finish_newFlight"),
|
---|
| 2787 | sensitive = True,
|
---|
| 2788 | clicked = self._newFlightClicked,
|
---|
| 2789 | tooltip = xstr("finish_newFlight_tooltip"),
|
---|
| 2790 | padding = 16)
|
---|
| 2791 |
|
---|
[107] | 2792 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[94] | 2793 |
|
---|
[107] | 2794 | self._saveButton = self.addButton(xstr("finish_save"),
|
---|
| 2795 | sensitive = False,
|
---|
[151] | 2796 | clicked = self._saveClicked,
|
---|
| 2797 | tooltip = xstr("finish_save_tooltip"))
|
---|
| 2798 | self._savePIREPDialog = None
|
---|
| 2799 | self._lastSavePath = None
|
---|
[208] | 2800 |
|
---|
| 2801 | self._pirepSaved = False
|
---|
| 2802 | self._pirepSent = False
|
---|
[347] | 2803 |
|
---|
[151] | 2804 | self._sendButton = self.addButton(xstr("sendPIREP"), default = True,
|
---|
[107] | 2805 | sensitive = False,
|
---|
| 2806 | clicked = self._sendClicked,
|
---|
[151] | 2807 | tooltip = xstr("sendPIREP_tooltip"))
|
---|
[347] | 2808 |
|
---|
[97] | 2809 | @property
|
---|
| 2810 | def flightType(self):
|
---|
| 2811 | """Get the flight type."""
|
---|
| 2812 | index = self._flightType.get_active()
|
---|
| 2813 | return None if index<0 else self._flightType.get_model()[index][1]
|
---|
| 2814 |
|
---|
| 2815 | @property
|
---|
| 2816 | def online(self):
|
---|
| 2817 | """Get whether the flight was an online flight or not."""
|
---|
| 2818 | return self._onlineFlight.get_active()
|
---|
[89] | 2819 |
|
---|
| 2820 | def activate(self):
|
---|
| 2821 | """Activate the page."""
|
---|
[208] | 2822 | self._pirepSaved = False
|
---|
| 2823 | self._pirepSent = False
|
---|
| 2824 |
|
---|
[89] | 2825 | flight = self._wizard.gui._flight
|
---|
| 2826 | rating = flight.logger.getRating()
|
---|
| 2827 | if rating<0:
|
---|
| 2828 | self._flightRating.set_markup('<b><span foreground="red">NO GO</span></b>')
|
---|
| 2829 | else:
|
---|
| 2830 | self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
|
---|
| 2831 |
|
---|
| 2832 | flightLength = flight.flightTimeEnd - flight.flightTimeStart
|
---|
| 2833 | self._flightTime.set_markup("<b>%s</b>" % \
|
---|
| 2834 | (util.getTimeIntervalString(flightLength),))
|
---|
[347] | 2835 |
|
---|
[89] | 2836 | blockLength = flight.blockTimeEnd - flight.blockTimeStart
|
---|
| 2837 | self._blockTime.set_markup("<b>%s</b>" % \
|
---|
| 2838 | (util.getTimeIntervalString(blockLength),))
|
---|
| 2839 |
|
---|
| 2840 | self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
|
---|
| 2841 | (flight.flownDistance,))
|
---|
[347] | 2842 |
|
---|
[89] | 2843 | self._fuelUsed.set_markup("<b>%.0f kg</b>" % \
|
---|
[102] | 2844 | (flight.startFuel - flight.endFuel,))
|
---|
[64] | 2845 |
|
---|
[96] | 2846 | self._flightType.set_active(-1)
|
---|
[215] | 2847 | self._onlineFlight.set_active(self._wizard.loggedIn)
|
---|
[96] | 2848 |
|
---|
[130] | 2849 | self._gatesModel.clear()
|
---|
[136] | 2850 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 2851 | self._wizard.loggedIn and \
|
---|
[184] | 2852 | self._wizard.bookedFlight.arrivalICAO=="LHBP" and \
|
---|
| 2853 | not self._wizard.entranceExam:
|
---|
[130] | 2854 | occupiedGates = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
| 2855 | for gateNumber in const.lhbpGateNumbers:
|
---|
| 2856 | if gateNumber not in occupiedGates:
|
---|
| 2857 | self._gatesModel.append([gateNumber])
|
---|
| 2858 | self._gateLabel.set_sensitive(True)
|
---|
| 2859 | self._gate.set_sensitive(True)
|
---|
| 2860 | self._gate.set_active(-1)
|
---|
| 2861 | else:
|
---|
| 2862 | self._gateLabel.set_sensitive(False)
|
---|
| 2863 | self._gate.set_sensitive(False)
|
---|
| 2864 |
|
---|
[94] | 2865 | def _backClicked(self, button):
|
---|
| 2866 | """Called when the Back button is pressed."""
|
---|
| 2867 | self.goBack()
|
---|
[96] | 2868 |
|
---|
[130] | 2869 | def _updateButtons(self):
|
---|
| 2870 | """Update the sensitivity state of the buttons."""
|
---|
| 2871 | sensitive = self._flightType.get_active()>=0 and \
|
---|
| 2872 | (self._gatesModel.get_iter_first() is None or
|
---|
| 2873 | self._gate.get_active()>=0)
|
---|
[347] | 2874 |
|
---|
[393] | 2875 | wasSensitive = self._saveButton.get_sensitive()
|
---|
| 2876 |
|
---|
| 2877 | gui = self._wizard.gui
|
---|
| 2878 | config = gui.config
|
---|
| 2879 | if config.pirepAutoSave and sensitive and not wasSensitive:
|
---|
| 2880 | self._lastSavePath = os.path.join(config.pirepDirectory,
|
---|
| 2881 | self._getDefaultPIREPName())
|
---|
| 2882 | self._lastSavePath = text2unicode(self._lastSavePath)
|
---|
| 2883 | self._savePIREP(automatic = True)
|
---|
| 2884 |
|
---|
[151] | 2885 | self._saveButton.set_sensitive(sensitive)
|
---|
[184] | 2886 | self._sendButton.set_sensitive(sensitive and
|
---|
| 2887 | self._wizard.bookedFlight.id is not None)
|
---|
[130] | 2888 |
|
---|
[96] | 2889 | def _flightTypeChanged(self, comboBox):
|
---|
| 2890 | """Called when the flight type has changed."""
|
---|
[130] | 2891 | self._updateButtons()
|
---|
| 2892 |
|
---|
| 2893 | def _gateChanged(self, comboBox):
|
---|
| 2894 | """Called when the arrival gate has changed."""
|
---|
| 2895 | self._updateButtons()
|
---|
[97] | 2896 |
|
---|
[208] | 2897 | def _newFlightClicked(self, button):
|
---|
| 2898 | """Called when the new flight button is clicked."""
|
---|
| 2899 | gui = self._wizard.gui
|
---|
| 2900 | if not self._pirepSent and not self._pirepSaved:
|
---|
| 2901 | dialog = gtk.MessageDialog(parent = gui.mainWindow,
|
---|
| 2902 | type = MESSAGETYPE_QUESTION,
|
---|
| 2903 | message_format = xstr("finish_newFlight_question"))
|
---|
| 2904 |
|
---|
| 2905 | dialog.add_button(xstr("button_no"), RESPONSETYPE_NO)
|
---|
| 2906 | dialog.add_button(xstr("button_yes"), RESPONSETYPE_YES)
|
---|
| 2907 |
|
---|
| 2908 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 2909 | result = dialog.run()
|
---|
| 2910 | dialog.hide()
|
---|
| 2911 | if result!=RESPONSETYPE_YES:
|
---|
| 2912 | return
|
---|
[347] | 2913 |
|
---|
[208] | 2914 | gui.reset()
|
---|
| 2915 |
|
---|
[393] | 2916 | def _getDefaultPIREPName(self):
|
---|
| 2917 | """Get the default name of the PIREP."""
|
---|
[151] | 2918 | gui = self._wizard.gui
|
---|
| 2919 |
|
---|
| 2920 | bookedFlight = gui.bookedFlight
|
---|
| 2921 | tm = time.gmtime()
|
---|
[215] | 2922 |
|
---|
| 2923 | pilotID = self._wizard.pilotID
|
---|
| 2924 | if pilotID: pilotID += " "
|
---|
[393] | 2925 | return "%s%s %02d%02d %s-%s.pirep" % \
|
---|
| 2926 | (pilotID, str(bookedFlight.departureTime.date()),
|
---|
| 2927 | tm.tm_hour, tm.tm_min,
|
---|
| 2928 | bookedFlight.departureICAO, bookedFlight.arrivalICAO)
|
---|
| 2929 |
|
---|
| 2930 |
|
---|
| 2931 | def _saveClicked(self, button):
|
---|
| 2932 | """Called when the Save PIREP button is clicked."""
|
---|
| 2933 | gui = self._wizard.gui
|
---|
| 2934 |
|
---|
| 2935 | fileName = self._getDefaultPIREPName()
|
---|
[151] | 2936 |
|
---|
| 2937 | dialog = self._getSaveDialog()
|
---|
| 2938 |
|
---|
| 2939 | if self._lastSavePath is None:
|
---|
| 2940 | pirepDirectory = gui.config.pirepDirectory
|
---|
| 2941 | if pirepDirectory is not None:
|
---|
| 2942 | dialog.set_current_folder(pirepDirectory)
|
---|
| 2943 | else:
|
---|
| 2944 | dialog.set_current_folder(os.path.dirname(self._lastSavePath))
|
---|
[347] | 2945 |
|
---|
[151] | 2946 | dialog.set_current_name(fileName)
|
---|
| 2947 | result = dialog.run()
|
---|
| 2948 | dialog.hide()
|
---|
| 2949 |
|
---|
| 2950 | if result==RESPONSETYPE_OK:
|
---|
[164] | 2951 | self._lastSavePath = text2unicode(dialog.get_filename())
|
---|
[393] | 2952 | self._savePIREP()
|
---|
| 2953 |
|
---|
| 2954 | def _savePIREP(self, automatic = False):
|
---|
| 2955 | """Perform the saving of the PIREP."""
|
---|
| 2956 |
|
---|
| 2957 | gui = self._wizard.gui
|
---|
| 2958 |
|
---|
| 2959 | if automatic:
|
---|
| 2960 | gui.beginBusy(xstr("finish_autosave_busy"))
|
---|
| 2961 |
|
---|
| 2962 | pirep = PIREP(gui.flight)
|
---|
| 2963 | error = pirep.save(self._lastSavePath)
|
---|
| 2964 |
|
---|
| 2965 | if automatic:
|
---|
| 2966 | gui.endBusy()
|
---|
| 2967 |
|
---|
| 2968 | if error:
|
---|
| 2969 | type = MESSAGETYPE_ERROR
|
---|
| 2970 | message = xstr("finish_save_failed")
|
---|
| 2971 | secondary = xstr("finish_save_failed_sec") % (text2unicode(error),)
|
---|
| 2972 | else:
|
---|
| 2973 | type = MESSAGETYPE_INFO
|
---|
| 2974 | message = xstr("finish_save_done")
|
---|
| 2975 | if automatic:
|
---|
| 2976 | secondary = xstr("finish_save_done_sec") % (self._lastSavePath,)
|
---|
[151] | 2977 | else:
|
---|
[393] | 2978 | secondary = None
|
---|
| 2979 | self._pirepSaved = True
|
---|
| 2980 |
|
---|
| 2981 | dialog = gtk.MessageDialog(parent = gui.mainWindow,
|
---|
| 2982 | type = type, message_format = message)
|
---|
| 2983 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 2984 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 2985 | if secondary is not None:
|
---|
| 2986 | dialog.format_secondary_markup(secondary)
|
---|
| 2987 |
|
---|
| 2988 | dialog.run()
|
---|
| 2989 | dialog.hide()
|
---|
[151] | 2990 |
|
---|
| 2991 | def _getSaveDialog(self):
|
---|
| 2992 | """Get the PIREP saving dialog.
|
---|
| 2993 |
|
---|
| 2994 | If it does not exist yet, create it."""
|
---|
| 2995 | if self._savePIREPDialog is None:
|
---|
| 2996 | gui = self._wizard.gui
|
---|
| 2997 | dialog = gtk.FileChooserDialog(title = WINDOW_TITLE_BASE + " - " +
|
---|
| 2998 | xstr("finish_save_title"),
|
---|
| 2999 | action = FILE_CHOOSER_ACTION_SAVE,
|
---|
| 3000 | buttons = (gtk.STOCK_CANCEL,
|
---|
| 3001 | RESPONSETYPE_CANCEL,
|
---|
| 3002 | gtk.STOCK_OK, RESPONSETYPE_OK),
|
---|
| 3003 | parent = gui.mainWindow)
|
---|
| 3004 | dialog.set_modal(True)
|
---|
| 3005 | dialog.set_do_overwrite_confirmation(True)
|
---|
[347] | 3006 |
|
---|
[151] | 3007 | filter = gtk.FileFilter()
|
---|
[184] | 3008 | filter.set_name(xstr("file_filter_pireps"))
|
---|
[151] | 3009 | filter.add_pattern("*.pirep")
|
---|
| 3010 | dialog.add_filter(filter)
|
---|
[347] | 3011 |
|
---|
[151] | 3012 | filter = gtk.FileFilter()
|
---|
[184] | 3013 | filter.set_name(xstr("file_filter_all"))
|
---|
[151] | 3014 | filter.add_pattern("*.*")
|
---|
| 3015 | dialog.add_filter(filter)
|
---|
| 3016 |
|
---|
| 3017 | self._savePIREPDialog = dialog
|
---|
| 3018 |
|
---|
| 3019 | return self._savePIREPDialog
|
---|
[347] | 3020 |
|
---|
[151] | 3021 |
|
---|
[97] | 3022 | def _sendClicked(self, button):
|
---|
| 3023 | """Called when the Send button is clicked."""
|
---|
[262] | 3024 | pirep = PIREP(self._wizard.gui.flight)
|
---|
[151] | 3025 | self._wizard.gui.sendPIREP(pirep,
|
---|
| 3026 | callback = self._handlePIREPSent)
|
---|
[97] | 3027 |
|
---|
| 3028 | def _handlePIREPSent(self, returned, result):
|
---|
| 3029 | """Callback for the PIREP sending result."""
|
---|
[208] | 3030 | self._pirepSent = returned and result.success
|
---|
[184] | 3031 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
[215] | 3032 | self._wizard.loggedIn and not self._wizard.entranceExam and \
|
---|
[184] | 3033 | returned and result.success:
|
---|
[130] | 3034 | bookedFlight = self._wizard.bookedFlight
|
---|
| 3035 | if bookedFlight.arrivalICAO=="LHBP":
|
---|
[347] | 3036 | iter = self._gate.get_active_iter()
|
---|
[130] | 3037 | gateNumber = None if iter is None \
|
---|
| 3038 | else self._gatesModel.get_value(iter, 0)
|
---|
[347] | 3039 |
|
---|
[130] | 3040 | status = const.PLANE_PARKING if gateNumber is None \
|
---|
| 3041 | else const.PLANE_HOME
|
---|
| 3042 | else:
|
---|
| 3043 | gateNumber = None
|
---|
| 3044 | status = const.PLANE_AWAY
|
---|
| 3045 |
|
---|
| 3046 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 3047 | bookedFlight.tailNumber,
|
---|
| 3048 | status, gateNumber = gateNumber)
|
---|
| 3049 |
|
---|
| 3050 | def _planeUpdated(self, success):
|
---|
| 3051 | """Callback for the plane updating."""
|
---|
| 3052 | pass
|
---|
[347] | 3053 |
|
---|
[64] | 3054 | #-----------------------------------------------------------------------------
|
---|
| 3055 |
|
---|
[42] | 3056 | class Wizard(gtk.VBox):
|
---|
| 3057 | """The flight wizard."""
|
---|
| 3058 | def __init__(self, gui):
|
---|
| 3059 | """Construct the wizard."""
|
---|
| 3060 | super(Wizard, self).__init__()
|
---|
| 3061 |
|
---|
| 3062 | self.gui = gui
|
---|
| 3063 |
|
---|
| 3064 | self._pages = []
|
---|
| 3065 | self._currentPage = None
|
---|
[184] | 3066 |
|
---|
| 3067 | self._loginPage = LoginPage(self)
|
---|
| 3068 | self._pages.append(self._loginPage)
|
---|
[42] | 3069 | self._pages.append(FlightSelectionPage(self))
|
---|
[51] | 3070 | self._pages.append(GateSelectionPage(self))
|
---|
| 3071 | self._pages.append(ConnectPage(self))
|
---|
[347] | 3072 | self._payloadPage = PayloadPage(self)
|
---|
[84] | 3073 | self._pages.append(self._payloadPage)
|
---|
[117] | 3074 | self._payloadIndex = len(self._pages)
|
---|
[61] | 3075 | self._pages.append(TimePage(self))
|
---|
[141] | 3076 | self._pages.append(FuelPage(self))
|
---|
[84] | 3077 | self._routePage = RoutePage(self)
|
---|
| 3078 | self._pages.append(self._routePage)
|
---|
[97] | 3079 | self._departureBriefingPage = BriefingPage(self, True)
|
---|
| 3080 | self._pages.append(self._departureBriefingPage)
|
---|
| 3081 | self._arrivalBriefingPage = BriefingPage(self, False)
|
---|
| 3082 | self._pages.append(self._arrivalBriefingPage)
|
---|
[117] | 3083 | self._arrivalBriefingIndex = len(self._pages)
|
---|
[347] | 3084 | self._takeoffPage = TakeoffPage(self)
|
---|
[84] | 3085 | self._pages.append(self._takeoffPage)
|
---|
[383] | 3086 | self._cruisePage = CruisePage(self)
|
---|
| 3087 | self._pages.append(self._cruisePage)
|
---|
[347] | 3088 | self._landingPage = LandingPage(self)
|
---|
[86] | 3089 | self._pages.append(self._landingPage)
|
---|
[97] | 3090 | self._finishPage = FinishPage(self)
|
---|
| 3091 | self._pages.append(self._finishPage)
|
---|
[201] | 3092 |
|
---|
[51] | 3093 | maxWidth = 0
|
---|
| 3094 | maxHeight = 0
|
---|
| 3095 | for page in self._pages:
|
---|
| 3096 | page.show_all()
|
---|
| 3097 | pageSizeRequest = page.size_request()
|
---|
| 3098 | width = pageSizeRequest.width if pygobject else pageSizeRequest[0]
|
---|
| 3099 | height = pageSizeRequest.height if pygobject else pageSizeRequest[1]
|
---|
| 3100 | maxWidth = max(maxWidth, width)
|
---|
| 3101 | maxHeight = max(maxHeight, height)
|
---|
[201] | 3102 | page.setStyle()
|
---|
[51] | 3103 | maxWidth += 16
|
---|
| 3104 | maxHeight += 32
|
---|
| 3105 | self.set_size_request(maxWidth, maxHeight)
|
---|
| 3106 |
|
---|
[59] | 3107 | self._initialize()
|
---|
[184] | 3108 |
|
---|
| 3109 | @property
|
---|
[215] | 3110 | def pilotID(self):
|
---|
| 3111 | """Get the pilot ID, if given."""
|
---|
| 3112 | return self._loginPage.pilotID
|
---|
| 3113 |
|
---|
| 3114 | @property
|
---|
[184] | 3115 | def entranceExam(self):
|
---|
| 3116 | """Get whether an entrance exam is about to be taken."""
|
---|
| 3117 | return self._loginPage.entranceExam
|
---|
[215] | 3118 |
|
---|
| 3119 | @property
|
---|
| 3120 | def loggedIn(self):
|
---|
| 3121 | """Indicate if there was a successful login."""
|
---|
| 3122 | return self._loginResult is not None
|
---|
[347] | 3123 |
|
---|
[48] | 3124 | @property
|
---|
| 3125 | def loginResult(self):
|
---|
| 3126 | """Get the login result."""
|
---|
| 3127 | return self._loginResult
|
---|
| 3128 |
|
---|
[70] | 3129 | def setCurrentPage(self, index, finalize = False):
|
---|
[42] | 3130 | """Set the current page to the one with the given index."""
|
---|
| 3131 | assert index < len(self._pages)
|
---|
[70] | 3132 |
|
---|
| 3133 | fromPage = self._currentPage
|
---|
| 3134 | if fromPage is not None:
|
---|
| 3135 | page = self._pages[fromPage]
|
---|
[94] | 3136 | if finalize and not page._completed:
|
---|
| 3137 | page.complete()
|
---|
[70] | 3138 | self.remove(page)
|
---|
[42] | 3139 |
|
---|
| 3140 | self._currentPage = index
|
---|
[70] | 3141 | page = self._pages[index]
|
---|
| 3142 | self.add(page)
|
---|
| 3143 | if page._fromPage is None:
|
---|
| 3144 | page._fromPage = fromPage
|
---|
[94] | 3145 | page.initialize()
|
---|
[42] | 3146 | self.show_all()
|
---|
[72] | 3147 | if fromPage is not None:
|
---|
| 3148 | self.grabDefault()
|
---|
[42] | 3149 |
|
---|
[84] | 3150 | @property
|
---|
[97] | 3151 | def bookedFlight(self):
|
---|
| 3152 | """Get the booked flight selected."""
|
---|
| 3153 | return self._bookedFlight
|
---|
| 3154 |
|
---|
| 3155 | @property
|
---|
[303] | 3156 | def numCrew(self):
|
---|
| 3157 | """Get the number of crew members."""
|
---|
| 3158 | return self._payloadPage.numCrew
|
---|
| 3159 |
|
---|
| 3160 | @property
|
---|
| 3161 | def numPassengers(self):
|
---|
| 3162 | """Get the number of passengers."""
|
---|
| 3163 | return self._payloadPage.numPassengers
|
---|
| 3164 |
|
---|
| 3165 | @property
|
---|
| 3166 | def bagWeight(self):
|
---|
| 3167 | """Get the baggage weight."""
|
---|
| 3168 | return self._payloadPage.bagWeight
|
---|
| 3169 |
|
---|
| 3170 | @property
|
---|
[97] | 3171 | def cargoWeight(self):
|
---|
[303] | 3172 | """Get the cargo weight."""
|
---|
[97] | 3173 | return self._payloadPage.cargoWeight
|
---|
| 3174 |
|
---|
| 3175 | @property
|
---|
[303] | 3176 | def mailWeight(self):
|
---|
| 3177 | """Get the mail weight."""
|
---|
| 3178 | return self._payloadPage.mailWeight
|
---|
| 3179 |
|
---|
| 3180 | @property
|
---|
[84] | 3181 | def zfw(self):
|
---|
| 3182 | """Get the calculated ZFW value."""
|
---|
| 3183 | return 0 if self._bookedFlight is None \
|
---|
| 3184 | else self._payloadPage.calculateZFW()
|
---|
| 3185 |
|
---|
| 3186 | @property
|
---|
[383] | 3187 | def filedCruiseLevel(self):
|
---|
| 3188 | """Get the filed cruise level."""
|
---|
| 3189 | return self._routePage.filedCruiseLevel
|
---|
| 3190 |
|
---|
| 3191 | @property
|
---|
[97] | 3192 | def filedCruiseAltitude(self):
|
---|
| 3193 | """Get the filed cruise altitude."""
|
---|
| 3194 | return self._routePage.filedCruiseLevel * 100
|
---|
| 3195 |
|
---|
| 3196 | @property
|
---|
[84] | 3197 | def cruiseAltitude(self):
|
---|
| 3198 | """Get the cruise altitude."""
|
---|
[383] | 3199 | level = self._cruisePage.cruiseLevel if self._cruisePage.activated \
|
---|
| 3200 | else self._routePage.filedCruiseLevel
|
---|
| 3201 | return level * 100
|
---|
| 3202 |
|
---|
| 3203 | @property
|
---|
| 3204 | def loggableCruiseAltitude(self):
|
---|
| 3205 | """Get the cruise altitude that can be logged."""
|
---|
| 3206 | if self._cruisePage.activated:
|
---|
| 3207 | return self._cruisePage.loggableCruiseLevel * 100
|
---|
| 3208 | else:
|
---|
| 3209 | return 0
|
---|
[84] | 3210 |
|
---|
| 3211 | @property
|
---|
[97] | 3212 | def route(self):
|
---|
| 3213 | """Get the route."""
|
---|
| 3214 | return self._routePage.route
|
---|
| 3215 |
|
---|
| 3216 | @property
|
---|
| 3217 | def departureMETAR(self):
|
---|
| 3218 | """Get the METAR of the departure airport."""
|
---|
| 3219 | return self._departureBriefingPage.metar
|
---|
| 3220 |
|
---|
| 3221 | @property
|
---|
| 3222 | def arrivalMETAR(self):
|
---|
| 3223 | """Get the METAR of the arrival airport."""
|
---|
| 3224 | return self._arrivalBriefingPage.metar
|
---|
| 3225 |
|
---|
| 3226 | @property
|
---|
| 3227 | def departureRunway(self):
|
---|
| 3228 | """Get the departure runway."""
|
---|
| 3229 | return self._takeoffPage.runway
|
---|
| 3230 |
|
---|
| 3231 | @property
|
---|
| 3232 | def sid(self):
|
---|
| 3233 | """Get the SID."""
|
---|
| 3234 | return self._takeoffPage.sid
|
---|
| 3235 |
|
---|
| 3236 | @property
|
---|
[84] | 3237 | def v1(self):
|
---|
| 3238 | """Get the V1 speed."""
|
---|
[86] | 3239 | return self._takeoffPage.v1
|
---|
[84] | 3240 |
|
---|
| 3241 | @property
|
---|
| 3242 | def vr(self):
|
---|
| 3243 | """Get the Vr speed."""
|
---|
[86] | 3244 | return self._takeoffPage.vr
|
---|
[84] | 3245 |
|
---|
| 3246 | @property
|
---|
| 3247 | def v2(self):
|
---|
| 3248 | """Get the V2 speed."""
|
---|
[86] | 3249 | return self._takeoffPage.v2
|
---|
| 3250 |
|
---|
| 3251 | @property
|
---|
[384] | 3252 | def derate(self):
|
---|
| 3253 | """Get the derate value."""
|
---|
| 3254 | return self._takeoffPage.derate
|
---|
| 3255 |
|
---|
| 3256 | @property
|
---|
[391] | 3257 | def takeoffAntiIceOn(self):
|
---|
| 3258 | """Get whether the anti-ice system was on during take-off."""
|
---|
| 3259 | return self._takeoffPage.antiIceOn
|
---|
| 3260 |
|
---|
| 3261 | @takeoffAntiIceOn.setter
|
---|
| 3262 | def takeoffAntiIceOn(self, value):
|
---|
| 3263 | """Set anti-ice on indicator."""
|
---|
| 3264 | self._takeoffPage.antiIceOn = value
|
---|
| 3265 |
|
---|
| 3266 | @property
|
---|
[349] | 3267 | def rtoIndicated(self):
|
---|
| 3268 | """Get whether the pilot has indicated that an RTO has occured."""
|
---|
| 3269 | return self._takeoffPage.rtoIndicated
|
---|
| 3270 |
|
---|
| 3271 | @property
|
---|
[97] | 3272 | def arrivalRunway(self):
|
---|
| 3273 | """Get the arrival runway."""
|
---|
| 3274 | return self._landingPage.runway
|
---|
| 3275 |
|
---|
| 3276 | @property
|
---|
| 3277 | def star(self):
|
---|
| 3278 | """Get the STAR."""
|
---|
| 3279 | return self._landingPage.star
|
---|
| 3280 |
|
---|
| 3281 | @property
|
---|
| 3282 | def transition(self):
|
---|
| 3283 | """Get the transition."""
|
---|
| 3284 | return self._landingPage.transition
|
---|
| 3285 |
|
---|
| 3286 | @property
|
---|
| 3287 | def approachType(self):
|
---|
| 3288 | """Get the approach type."""
|
---|
| 3289 | return self._landingPage.approachType
|
---|
| 3290 |
|
---|
| 3291 | @property
|
---|
[86] | 3292 | def vref(self):
|
---|
| 3293 | """Get the Vref speed."""
|
---|
| 3294 | return self._landingPage.vref
|
---|
[84] | 3295 |
|
---|
[97] | 3296 | @property
|
---|
[391] | 3297 | def landingAntiIceOn(self):
|
---|
| 3298 | """Get whether the anti-ice system was on during landing."""
|
---|
| 3299 | return self._landingPage.antiIceOn
|
---|
| 3300 |
|
---|
| 3301 | @landingAntiIceOn.setter
|
---|
| 3302 | def landingAntiIceOn(self, value):
|
---|
| 3303 | """Set anti-ice on indicator."""
|
---|
| 3304 | self._landingPage.antiIceOn = value
|
---|
| 3305 |
|
---|
| 3306 | @property
|
---|
[97] | 3307 | def flightType(self):
|
---|
| 3308 | """Get the flight type."""
|
---|
| 3309 | return self._finishPage.flightType
|
---|
| 3310 |
|
---|
| 3311 | @property
|
---|
| 3312 | def online(self):
|
---|
| 3313 | """Get whether the flight was online or not."""
|
---|
| 3314 | return self._finishPage.online
|
---|
| 3315 |
|
---|
[70] | 3316 | def nextPage(self, finalize = True):
|
---|
[42] | 3317 | """Go to the next page."""
|
---|
[70] | 3318 | self.jumpPage(1, finalize)
|
---|
[51] | 3319 |
|
---|
[70] | 3320 | def jumpPage(self, count, finalize = True):
|
---|
[51] | 3321 | """Go to the page which is 'count' pages after the current one."""
|
---|
[70] | 3322 | self.setCurrentPage(self._currentPage + count, finalize = finalize)
|
---|
[46] | 3323 |
|
---|
| 3324 | def grabDefault(self):
|
---|
| 3325 | """Make the default button of the current page the default."""
|
---|
| 3326 | self._pages[self._currentPage].grabDefault()
|
---|
[51] | 3327 |
|
---|
[59] | 3328 | def connected(self, fsType, descriptor):
|
---|
| 3329 | """Called when the connection could be made to the simulator."""
|
---|
| 3330 | self.nextPage()
|
---|
| 3331 |
|
---|
[208] | 3332 | def reset(self, loginResult):
|
---|
[91] | 3333 | """Resets the wizard to go back to the login page."""
|
---|
[208] | 3334 | self._initialize(keepLoginResult = loginResult is None,
|
---|
| 3335 | loginResult = loginResult)
|
---|
[59] | 3336 |
|
---|
[84] | 3337 | def setStage(self, stage):
|
---|
| 3338 | """Set the flight stage to the given one."""
|
---|
[383] | 3339 | if stage!=const.STAGE_END:
|
---|
| 3340 | self._cruisePage.setLoggable(Flight.canLogCruiseAltitude(stage))
|
---|
| 3341 |
|
---|
[84] | 3342 | if stage==const.STAGE_TAKEOFF:
|
---|
[101] | 3343 | self._takeoffPage.allowForward()
|
---|
[106] | 3344 | elif stage==const.STAGE_LANDING:
|
---|
| 3345 | if not self._arrivalBriefingPage.metarEdited:
|
---|
| 3346 | print "Downloading arrival METAR again"
|
---|
| 3347 | self.gui.webHandler.getMETARs(self._arrivalMETARCallback,
|
---|
| 3348 | [self._bookedFlight.arrivalICAO])
|
---|
[347] | 3349 |
|
---|
[88] | 3350 | elif stage==const.STAGE_END:
|
---|
[275] | 3351 | for page in self._pages:
|
---|
| 3352 | page.flightEnded()
|
---|
[84] | 3353 |
|
---|
[208] | 3354 | def _initialize(self, keepLoginResult = False, loginResult = None):
|
---|
[59] | 3355 | """Initialize the wizard."""
|
---|
[208] | 3356 | if not keepLoginResult:
|
---|
| 3357 | self._loginResult = loginResult
|
---|
| 3358 |
|
---|
| 3359 | self._loginCallback = None
|
---|
| 3360 |
|
---|
[59] | 3361 | self._fleet = None
|
---|
| 3362 | self._fleetCallback = None
|
---|
[347] | 3363 |
|
---|
[59] | 3364 | self._bookedFlight = None
|
---|
| 3365 | self._departureGate = "-"
|
---|
[141] | 3366 | self._fuelData = None
|
---|
[64] | 3367 | self._departureNOTAMs = None
|
---|
[67] | 3368 | self._departureMETAR = None
|
---|
[64] | 3369 | self._arrivalNOTAMs = None
|
---|
[67] | 3370 | self._arrivalMETAR = None
|
---|
| 3371 |
|
---|
[208] | 3372 | firstPage = 0 if self._loginResult is None else 1
|
---|
| 3373 | for page in self._pages[firstPage:]:
|
---|
[67] | 3374 | page.reset()
|
---|
[347] | 3375 |
|
---|
[208] | 3376 | self.setCurrentPage(firstPage)
|
---|
| 3377 |
|
---|
| 3378 | def login(self, callback, pilotID, password, entranceExam):
|
---|
| 3379 | """Called when the login button was clicked."""
|
---|
| 3380 | self._loginCallback = callback
|
---|
| 3381 | if pilotID is None:
|
---|
| 3382 | loginResult = self._loginResult
|
---|
| 3383 | assert loginResult is not None and loginResult.loggedIn
|
---|
| 3384 | pilotID = loginResult.pilotID
|
---|
| 3385 | password = loginResult.password
|
---|
| 3386 | entranceExam = loginResult.entranceExam
|
---|
| 3387 | busyMessage = xstr("reload_busy")
|
---|
| 3388 | else:
|
---|
| 3389 | self._loginResult = None
|
---|
| 3390 | busyMessage = xstr("login_busy")
|
---|
| 3391 |
|
---|
| 3392 | self.gui.beginBusy(busyMessage)
|
---|
[347] | 3393 |
|
---|
[208] | 3394 | self.gui.webHandler.login(self._loginResultCallback,
|
---|
| 3395 | pilotID, password,
|
---|
| 3396 | entranceExam = entranceExam)
|
---|
| 3397 |
|
---|
| 3398 | def reloadFlights(self, callback):
|
---|
| 3399 | """Reload the flights from the MAVA server."""
|
---|
| 3400 | self.login(callback, None, None, None)
|
---|
| 3401 |
|
---|
[304] | 3402 | def cruiseLevelChanged(self):
|
---|
| 3403 | """Called when the cruise level is changed."""
|
---|
[383] | 3404 | return self.gui.cruiseLevelChanged()
|
---|
[304] | 3405 |
|
---|
[208] | 3406 | def _loginResultCallback(self, returned, result):
|
---|
| 3407 | """The login result callback, called in the web handler's thread."""
|
---|
| 3408 | gobject.idle_add(self._handleLoginResult, returned, result)
|
---|
| 3409 |
|
---|
| 3410 | def _handleLoginResult(self, returned, result):
|
---|
| 3411 | """Handle the login result."""
|
---|
| 3412 | self.gui.endBusy()
|
---|
| 3413 | isReload = self._loginResult is not None
|
---|
| 3414 | if returned:
|
---|
| 3415 | if result.loggedIn:
|
---|
| 3416 | self._loginResult = result
|
---|
| 3417 | else:
|
---|
| 3418 | if isReload:
|
---|
| 3419 | message = xstr("reload_failed")
|
---|
| 3420 | else:
|
---|
| 3421 | message = xstr("login_entranceExam_invalid"
|
---|
| 3422 | if self.entranceExam else
|
---|
| 3423 | xstr("login_invalid"))
|
---|
| 3424 | dialog = gtk.MessageDialog(parent = self.gui.mainWindow,
|
---|
| 3425 | type = MESSAGETYPE_ERROR,
|
---|
| 3426 | message_format = message)
|
---|
| 3427 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 3428 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 3429 | if isReload:
|
---|
| 3430 | secondary = xstr("reload_failed_sec")
|
---|
| 3431 | else:
|
---|
| 3432 | secondary = xstr("login_entranceExam_invalid_sec"
|
---|
| 3433 | if self.entranceExam else
|
---|
| 3434 | xstr("login_invalid_sec"))
|
---|
| 3435 | dialog.format_secondary_markup(secondary)
|
---|
| 3436 | dialog.run()
|
---|
| 3437 | dialog.hide()
|
---|
| 3438 | else:
|
---|
| 3439 | message = xstr("reload_failconn") if isReload \
|
---|
| 3440 | else xstr("login_failconn")
|
---|
| 3441 | dialog = gtk.MessageDialog(parent = self.gui.mainWindow,
|
---|
| 3442 | type = MESSAGETYPE_ERROR,
|
---|
| 3443 | message_format = message)
|
---|
| 3444 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
| 3445 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
| 3446 | secondary = xstr("reload_failconn_sec") if isReload \
|
---|
| 3447 | else xstr("login_failconn_sec")
|
---|
| 3448 | dialog.format_secondary_markup(secondary)
|
---|
[347] | 3449 |
|
---|
[208] | 3450 | dialog.run()
|
---|
| 3451 | dialog.hide()
|
---|
| 3452 |
|
---|
| 3453 | callback = self._loginCallback
|
---|
| 3454 | self._loginCallback = None
|
---|
| 3455 | callback(returned, result)
|
---|
[126] | 3456 |
|
---|
[130] | 3457 | def getFleet(self, callback, force = False):
|
---|
[126] | 3458 | """Get the fleet via the GUI and call the given callback."""
|
---|
| 3459 | self._fleetCallback = callback
|
---|
[130] | 3460 | self.gui.getFleet(callback = self._fleetRetrieved, force = force)
|
---|
[126] | 3461 |
|
---|
| 3462 | def _fleetRetrieved(self, fleet):
|
---|
| 3463 | """Callback for the fleet retrieval."""
|
---|
| 3464 | self._fleet = fleet
|
---|
| 3465 | if self._fleetCallback is not None:
|
---|
| 3466 | self._fleetCallback(fleet)
|
---|
| 3467 | self._fleetCallback = None
|
---|
[347] | 3468 |
|
---|
[130] | 3469 | def updatePlane(self, callback, tailNumber, status, gateNumber = None):
|
---|
[51] | 3470 | """Update the given plane's gate information."""
|
---|
[130] | 3471 | self.gui.updatePlane(tailNumber, status, gateNumber = gateNumber,
|
---|
| 3472 | callback = callback)
|
---|
[51] | 3473 |
|
---|
[349] | 3474 | def updateRTO(self):
|
---|
| 3475 | """Update the RTO state.
|
---|
| 3476 |
|
---|
| 3477 | The RTO checkbox will be enabled if the flight has an RTO state and the
|
---|
| 3478 | comments field contains some text."""
|
---|
| 3479 | flight = self.gui.flight
|
---|
| 3480 | rtoEnabled = flight is not None and flight.hasRTO and \
|
---|
| 3481 | self.gui.hasComments
|
---|
| 3482 | self._takeoffPage.setRTOEnabled(rtoEnabled)
|
---|
| 3483 |
|
---|
| 3484 | def rtoToggled(self, indicated):
|
---|
| 3485 | """Called when the RTO indication has changed."""
|
---|
| 3486 | self.gui.rtoToggled(indicated)
|
---|
| 3487 |
|
---|
[51] | 3488 | def _connectSimulator(self):
|
---|
| 3489 | """Connect to the simulator."""
|
---|
[59] | 3490 | self.gui.connectSimulator(self._bookedFlight.aircraftType)
|
---|
[106] | 3491 |
|
---|
| 3492 | def _arrivalMETARCallback(self, returned, result):
|
---|
| 3493 | """Called when the METAR of the arrival airport is retrieved."""
|
---|
| 3494 | gobject.idle_add(self._handleArrivalMETAR, returned, result)
|
---|
[347] | 3495 |
|
---|
[106] | 3496 | def _handleArrivalMETAR(self, returned, result):
|
---|
| 3497 | """Called when the METAR of the arrival airport is retrieved."""
|
---|
| 3498 | icao = self._bookedFlight.arrivalICAO
|
---|
| 3499 | if returned and icao in result.metars:
|
---|
| 3500 | metar = result.metars[icao]
|
---|
| 3501 | if metar!="":
|
---|
| 3502 | self._arrivalBriefingPage.setMETAR(metar)
|
---|
[347] | 3503 |
|
---|
[42] | 3504 | #-----------------------------------------------------------------------------
|
---|