[42] | 1 | # The flight handling "wizard"
|
---|
| 2 |
|
---|
| 3 | from mlx.gui.common import *
|
---|
| 4 |
|
---|
[51] | 5 | import mlx.const as const
|
---|
| 6 | import mlx.fs as fs
|
---|
[141] | 7 | import mlx.acft as acft
|
---|
[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
|
---|
[51] | 12 |
|
---|
[61] | 13 | import datetime
|
---|
| 14 | import time
|
---|
| 15 |
|
---|
[78] | 16 | #------------------------------------------------------------------------------
|
---|
| 17 |
|
---|
| 18 | acftTypeNames = { const.AIRCRAFT_B736: "Boeing 737-600",
|
---|
| 19 | const.AIRCRAFT_B737: "Boeing 737-700",
|
---|
| 20 | const.AIRCRAFT_B738: "Boeing 737-800",
|
---|
| 21 | const.AIRCRAFT_DH8D: "Bombardier Dash 8-Q400",
|
---|
| 22 | const.AIRCRAFT_B733: "Boeing 737-300",
|
---|
| 23 | const.AIRCRAFT_B734: "Boeing 737-400",
|
---|
| 24 | const.AIRCRAFT_B735: "Boeing 737-500",
|
---|
| 25 | const.AIRCRAFT_B762: "Boeing 767-200",
|
---|
| 26 | const.AIRCRAFT_B763: "Boeing 767-300",
|
---|
| 27 | const.AIRCRAFT_CRJ2: "Bombardier CRJ200",
|
---|
| 28 | const.AIRCRAFT_F70: "Fokker 70",
|
---|
| 29 | const.AIRCRAFT_DC3: "Lisunov Li-2",
|
---|
| 30 | const.AIRCRAFT_T134: "Tupolev Tu-134",
|
---|
| 31 | const.AIRCRAFT_T154: "Tupolev Tu-154",
|
---|
| 32 | const.AIRCRAFT_YK40: "Yakovlev Yak-40" }
|
---|
| 33 |
|
---|
[42] | 34 | #-----------------------------------------------------------------------------
|
---|
| 35 |
|
---|
[44] | 36 | class Page(gtk.Alignment):
|
---|
[42] | 37 | """A page in the flight wizard."""
|
---|
[94] | 38 | def __init__(self, wizard, title, help, completedHelp = None):
|
---|
[42] | 39 | """Construct the page."""
|
---|
[44] | 40 | super(Page, self).__init__(xalign = 0.0, yalign = 0.0,
|
---|
| 41 | xscale = 1.0, yscale = 1.0)
|
---|
| 42 | self.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 43 | padding_left = 12, padding_right = 12)
|
---|
| 44 |
|
---|
| 45 | frame = gtk.Frame()
|
---|
| 46 | self.add(frame)
|
---|
| 47 |
|
---|
| 48 | style = self.get_style() if pygobject else self.rc_get_style()
|
---|
| 49 |
|
---|
| 50 | self._vbox = gtk.VBox()
|
---|
[48] | 51 | self._vbox.set_homogeneous(False)
|
---|
[44] | 52 | frame.add(self._vbox)
|
---|
| 53 |
|
---|
| 54 | eventBox = gtk.EventBox()
|
---|
| 55 | eventBox.modify_bg(0, style.bg[3])
|
---|
| 56 |
|
---|
| 57 | alignment = gtk.Alignment(xalign = 0.0, xscale = 0.0)
|
---|
| 58 |
|
---|
| 59 | label = gtk.Label(title)
|
---|
| 60 | label.modify_fg(0, style.fg[3])
|
---|
| 61 | label.modify_font(pango.FontDescription("bold 24"))
|
---|
| 62 | alignment.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
| 63 | padding_left = 6, padding_right = 0)
|
---|
| 64 |
|
---|
| 65 | alignment.add(label)
|
---|
| 66 | eventBox.add(alignment)
|
---|
| 67 |
|
---|
| 68 | self._vbox.pack_start(eventBox, False, False, 0)
|
---|
| 69 |
|
---|
[79] | 70 | mainBox = gtk.VBox()
|
---|
[48] | 71 |
|
---|
| 72 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 73 | xscale = 1.0, yscale = 1.0)
|
---|
| 74 | alignment.set_padding(padding_top = 16, padding_bottom = 16,
|
---|
| 75 | padding_left = 16, padding_right = 16)
|
---|
[79] | 76 | alignment.add(mainBox)
|
---|
[48] | 77 | self._vbox.pack_start(alignment, True, True, 0)
|
---|
| 78 |
|
---|
| 79 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
[94] | 80 | xscale = 0.0, yscale = 0.0)
|
---|
[50] | 81 | alignment.set_padding(padding_top = 0, padding_bottom = 16,
|
---|
| 82 | padding_left = 0, padding_right = 0)
|
---|
[48] | 83 |
|
---|
[94] | 84 | self._help = help
|
---|
| 85 | self._completedHelp = completedHelp
|
---|
| 86 |
|
---|
| 87 | if self._completedHelp is None or \
|
---|
| 88 | len(help.splitlines())>=len(completedHelp.splitlines()):
|
---|
| 89 | longerHelp = help
|
---|
| 90 | else:
|
---|
| 91 | longerHelp = completedHelp
|
---|
| 92 |
|
---|
| 93 | self._helpLabel = gtk.Label(completedHelp)
|
---|
| 94 | # FIXME: should be a constant in common
|
---|
| 95 | self._helpLabel.set_justify(gtk.Justification.CENTER if pygobject
|
---|
| 96 | else gtk.JUSTIFY_CENTER)
|
---|
| 97 | self._helpLabel.set_use_markup(True)
|
---|
| 98 | alignment.add(self._helpLabel)
|
---|
[79] | 99 | mainBox.pack_start(alignment, False, False, 0)
|
---|
[44] | 100 |
|
---|
| 101 | self._mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
[48] | 102 | xscale = 1.0, yscale = 1.0)
|
---|
[79] | 103 | mainBox.pack_start(self._mainAlignment, True, True, 0)
|
---|
[48] | 104 |
|
---|
| 105 | buttonAlignment = gtk.Alignment(xalign = 1.0, xscale=0.0, yscale = 0.0)
|
---|
[44] | 106 | buttonAlignment.set_padding(padding_top = 4, padding_bottom = 10,
|
---|
| 107 | padding_left = 16, padding_right = 16)
|
---|
| 108 |
|
---|
[70] | 109 | self._buttonBox = gtk.HBox()
|
---|
| 110 | self._buttonBox.set_homogeneous(False)
|
---|
[46] | 111 | self._defaultButton = None
|
---|
[44] | 112 | buttonAlignment.add(self._buttonBox)
|
---|
| 113 |
|
---|
| 114 | self._vbox.pack_start(buttonAlignment, False, False, 0)
|
---|
| 115 |
|
---|
[42] | 116 | self._wizard = wizard
|
---|
| 117 |
|
---|
[94] | 118 | self._completed = False
|
---|
[70] | 119 | self._fromPage = None
|
---|
| 120 |
|
---|
[44] | 121 | def setMainWidget(self, widget):
|
---|
| 122 | """Set the given widget as the main one."""
|
---|
| 123 | self._mainAlignment.add(widget)
|
---|
| 124 |
|
---|
[107] | 125 | def addButton(self, label, default = False, sensitive = True,
|
---|
| 126 | tooltip = None, clicked = None):
|
---|
[44] | 127 | """Add a button with the given label.
|
---|
| 128 |
|
---|
| 129 | Return the button object created."""
|
---|
| 130 | button = gtk.Button(label)
|
---|
[70] | 131 | self._buttonBox.pack_start(button, False, False, 4)
|
---|
[48] | 132 | button.set_use_underline(True)
|
---|
[46] | 133 | if default:
|
---|
| 134 | button.set_can_default(True)
|
---|
| 135 | self._defaultButton = button
|
---|
[107] | 136 | button.set_sensitive(sensitive)
|
---|
| 137 | if tooltip is not None:
|
---|
| 138 | button.set_tooltip_text(tooltip)
|
---|
| 139 | if clicked is not None:
|
---|
| 140 | button.connect("clicked", clicked)
|
---|
[44] | 141 | return button
|
---|
| 142 |
|
---|
[107] | 143 | def addPreviousButton(self, sensitive = True, clicked = None):
|
---|
| 144 | """Add the 'Next' button to the page."""
|
---|
| 145 | return self.addButton(xstr("button_previous"),
|
---|
| 146 | sensitive = sensitive,
|
---|
| 147 | tooltip = xstr("button_previous_tooltip"),
|
---|
| 148 | clicked = clicked)
|
---|
| 149 |
|
---|
| 150 | def addNextButton(self, default = True, sensitive = True,
|
---|
| 151 | clicked = None):
|
---|
| 152 | """Add the 'Next' button to the page."""
|
---|
| 153 | return self.addButton(xstr("button_next"),
|
---|
| 154 | default = default,
|
---|
| 155 | sensitive = sensitive,
|
---|
| 156 | tooltip = xstr("button_next_tooltip"),
|
---|
| 157 | clicked = clicked)
|
---|
| 158 |
|
---|
[94] | 159 | def initialize(self):
|
---|
| 160 | """Initialize the page.
|
---|
| 161 |
|
---|
| 162 | It sets up the primary help, and calls the activate() function."""
|
---|
| 163 | self._helpLabel.set_markup(self._help)
|
---|
| 164 | self._helpLabel.set_sensitive(True)
|
---|
| 165 | self.activate()
|
---|
| 166 |
|
---|
[48] | 167 | def activate(self):
|
---|
| 168 | """Called when this page becomes active.
|
---|
| 169 |
|
---|
| 170 | This default implementation does nothing."""
|
---|
| 171 | pass
|
---|
| 172 |
|
---|
[94] | 173 | def complete(self):
|
---|
| 174 | """Called when the page is completed.
|
---|
| 175 |
|
---|
| 176 | It greys out/changes the help text and then calls finalize()."""
|
---|
| 177 | self.finalize()
|
---|
| 178 | if self._completedHelp is None:
|
---|
| 179 | self._helpLabel.set_sensitive(False)
|
---|
| 180 | else:
|
---|
| 181 | self._helpLabel.set_markup(self._completedHelp)
|
---|
| 182 | self._completed = True
|
---|
| 183 |
|
---|
[70] | 184 | def finalize(self):
|
---|
| 185 | """Called when the page is finalized."""
|
---|
| 186 | pass
|
---|
| 187 |
|
---|
[46] | 188 | def grabDefault(self):
|
---|
| 189 | """If the page has a default button, make it the default one."""
|
---|
| 190 | if self._defaultButton is not None:
|
---|
| 191 | self._defaultButton.grab_default()
|
---|
[67] | 192 |
|
---|
| 193 | def reset(self):
|
---|
| 194 | """Reset the page if the wizard is reset."""
|
---|
[94] | 195 | self._completed = False
|
---|
[70] | 196 | self._fromPage = None
|
---|
| 197 |
|
---|
| 198 | def goBack(self):
|
---|
| 199 | """Go to the page we were invoked from."""
|
---|
| 200 | assert self._fromPage is not None
|
---|
| 201 |
|
---|
| 202 | self._wizard.setCurrentPage(self._fromPage, finalize = False)
|
---|
[46] | 203 |
|
---|
[42] | 204 | #-----------------------------------------------------------------------------
|
---|
| 205 |
|
---|
| 206 | class LoginPage(Page):
|
---|
| 207 | """The login page."""
|
---|
| 208 | def __init__(self, wizard):
|
---|
| 209 | """Construct the login page."""
|
---|
[107] | 210 | super(LoginPage, self).__init__(wizard, xstr("login"),
|
---|
| 211 | xstr("loginHelp"))
|
---|
[42] | 212 |
|
---|
[48] | 213 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 214 | xscale = 0.0, yscale = 0.0)
|
---|
[139] | 215 |
|
---|
[45] | 216 | table = gtk.Table(2, 3)
|
---|
[42] | 217 | table.set_row_spacings(4)
|
---|
| 218 | table.set_col_spacings(32)
|
---|
[48] | 219 | alignment.add(table)
|
---|
| 220 | self.setMainWidget(alignment)
|
---|
[42] | 221 |
|
---|
[107] | 222 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 223 | xscale = 0.0, yscale = 0.0)
|
---|
| 224 | label = gtk.Label(xstr("label_pilotID"))
|
---|
[45] | 225 | label.set_use_underline(True)
|
---|
| 226 | labelAlignment.add(label)
|
---|
[42] | 227 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 228 |
|
---|
| 229 | self._pilotID = gtk.Entry()
|
---|
| 230 | self._pilotID.connect("changed", self._setLoginButton)
|
---|
[107] | 231 | self._pilotID.set_tooltip_text(xstr("login_pilotID_tooltip"))
|
---|
[42] | 232 | table.attach(self._pilotID, 1, 2, 0, 1)
|
---|
[45] | 233 | label.set_mnemonic_widget(self._pilotID)
|
---|
[42] | 234 |
|
---|
[107] | 235 | labelAlignment = gtk.Alignment(xalign = 1.0, yalign = 0.5,
|
---|
| 236 | xscale = 0.0, yscale = 0.0)
|
---|
| 237 | label = gtk.Label(xstr("label_password"))
|
---|
[45] | 238 | label.set_use_underline(True)
|
---|
| 239 | labelAlignment.add(label)
|
---|
[42] | 240 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 241 |
|
---|
| 242 | self._password = gtk.Entry()
|
---|
| 243 | self._password.set_visibility(False)
|
---|
| 244 | self._password.connect("changed", self._setLoginButton)
|
---|
[107] | 245 | self._password.set_tooltip_text(xstr("login_password_tooltip"))
|
---|
[42] | 246 | table.attach(self._password, 1, 2, 1, 2)
|
---|
[45] | 247 | label.set_mnemonic_widget(self._password)
|
---|
[42] | 248 |
|
---|
[107] | 249 | self._rememberButton = gtk.CheckButton(xstr("remember_password"))
|
---|
[45] | 250 | self._rememberButton.set_use_underline(True)
|
---|
[107] | 251 | self._rememberButton.set_tooltip_text(xstr("login_remember_tooltip"))
|
---|
[45] | 252 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
| 253 |
|
---|
[107] | 254 | self._loginButton = self.addButton(xstr("button_login"), default = True)
|
---|
[42] | 255 | self._loginButton.set_sensitive(False)
|
---|
| 256 | self._loginButton.connect("clicked", self._loginClicked)
|
---|
[107] | 257 | self._loginButton.set_tooltip_text(xstr("login_button_tooltip"))
|
---|
[92] | 258 |
|
---|
| 259 | def activate(self):
|
---|
| 260 | """Activate the page."""
|
---|
[42] | 261 | config = self._wizard.gui.config
|
---|
| 262 | self._pilotID.set_text(config.pilotID)
|
---|
| 263 | self._password.set_text(config.password)
|
---|
[45] | 264 | self._rememberButton.set_active(config.rememberPassword)
|
---|
[42] | 265 |
|
---|
| 266 | def _setLoginButton(self, entry):
|
---|
| 267 | """Set the login button's sensitivity.
|
---|
| 268 |
|
---|
| 269 | The button is sensitive only if both the pilot ID and the password
|
---|
| 270 | fields contain values."""
|
---|
| 271 | self._loginButton.set_sensitive(self._pilotID.get_text()!="" and
|
---|
| 272 | self._password.get_text()!="")
|
---|
| 273 |
|
---|
| 274 | def _loginClicked(self, button):
|
---|
| 275 | """Called when the login button was clicked."""
|
---|
[70] | 276 | self._loginButton.set_sensitive(False)
|
---|
| 277 | gui = self._wizard.gui
|
---|
[107] | 278 | gui.beginBusy(xstr("login_busy"))
|
---|
[70] | 279 | gui.webHandler.login(self._loginResultCallback,
|
---|
| 280 | self._pilotID.get_text(),
|
---|
| 281 | self._password.get_text())
|
---|
[42] | 282 |
|
---|
| 283 | def _loginResultCallback(self, returned, result):
|
---|
| 284 | """The login result callback, called in the web handler's thread."""
|
---|
| 285 | gobject.idle_add(self._handleLoginResult, returned, result)
|
---|
| 286 |
|
---|
| 287 | def _handleLoginResult(self, returned, result):
|
---|
| 288 | """Handle the login result."""
|
---|
[49] | 289 | self._wizard.gui.endBusy()
|
---|
[70] | 290 | self._loginButton.set_sensitive(True)
|
---|
[42] | 291 | if returned:
|
---|
| 292 | if result.loggedIn:
|
---|
| 293 | config = self._wizard.gui.config
|
---|
[45] | 294 |
|
---|
[42] | 295 | config.pilotID = self._pilotID.get_text()
|
---|
[45] | 296 |
|
---|
| 297 | rememberPassword = self._rememberButton.get_active()
|
---|
| 298 | config.password = self._password.get_text() if rememberPassword \
|
---|
| 299 | else ""
|
---|
| 300 |
|
---|
| 301 | config.rememberPassword = rememberPassword
|
---|
| 302 |
|
---|
[43] | 303 | config.save()
|
---|
[48] | 304 | self._wizard._loginResult = result
|
---|
[42] | 305 | self._wizard.nextPage()
|
---|
| 306 | else:
|
---|
[105] | 307 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 308 | type = MESSAGETYPE_ERROR,
|
---|
[107] | 309 | message_format = xstr("login_invalid"))
|
---|
[124] | 310 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
[105] | 311 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
[107] | 312 | dialog.format_secondary_markup(xstr("login_invalid_sec"))
|
---|
[42] | 313 | dialog.run()
|
---|
| 314 | dialog.hide()
|
---|
| 315 | else:
|
---|
[105] | 316 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 317 | type = MESSAGETYPE_ERROR,
|
---|
[107] | 318 | message_format = xstr("login_failconn"))
|
---|
[124] | 319 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
[105] | 320 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
[107] | 321 | dialog.format_secondary_markup(xstr("login_failconn_sec"))
|
---|
| 322 |
|
---|
[42] | 323 | dialog.run()
|
---|
| 324 | dialog.hide()
|
---|
| 325 |
|
---|
| 326 | #-----------------------------------------------------------------------------
|
---|
| 327 |
|
---|
| 328 | class FlightSelectionPage(Page):
|
---|
| 329 | """The page to select the flight."""
|
---|
| 330 | def __init__(self, wizard):
|
---|
| 331 | """Construct the flight selection page."""
|
---|
[107] | 332 | help = xstr("flightsel_help")
|
---|
| 333 | completedHelp = xstr("flightsel_chelp")
|
---|
| 334 | super(FlightSelectionPage, self).__init__(wizard, xstr("flightsel_title"),
|
---|
[94] | 335 | help, completedHelp = completedHelp)
|
---|
[48] | 336 |
|
---|
| 337 |
|
---|
| 338 | self._listStore = gtk.ListStore(str, str, str, str)
|
---|
| 339 | self._flightList = gtk.TreeView(self._listStore)
|
---|
[107] | 340 | column = gtk.TreeViewColumn(xstr("flightsel_no"), gtk.CellRendererText(),
|
---|
[48] | 341 | text = 1)
|
---|
| 342 | column.set_expand(True)
|
---|
| 343 | self._flightList.append_column(column)
|
---|
[107] | 344 | column = gtk.TreeViewColumn(xstr("flightsel_deptime"), gtk.CellRendererText(),
|
---|
[48] | 345 | text = 0)
|
---|
| 346 | column.set_expand(True)
|
---|
| 347 | self._flightList.append_column(column)
|
---|
[107] | 348 | column = gtk.TreeViewColumn(xstr("flightsel_from"), gtk.CellRendererText(),
|
---|
[48] | 349 | text = 2)
|
---|
| 350 | column.set_expand(True)
|
---|
| 351 | self._flightList.append_column(column)
|
---|
[107] | 352 | column = gtk.TreeViewColumn(xstr("flightsel_to"), gtk.CellRendererText(),
|
---|
[48] | 353 | text = 3)
|
---|
| 354 | column.set_expand(True)
|
---|
| 355 | self._flightList.append_column(column)
|
---|
| 356 |
|
---|
| 357 | flightSelection = self._flightList.get_selection()
|
---|
| 358 | flightSelection.connect("changed", self._selectionChanged)
|
---|
| 359 |
|
---|
| 360 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 361 | scrolledWindow.add(self._flightList)
|
---|
| 362 | scrolledWindow.set_size_request(400, -1)
|
---|
[118] | 363 | # FIXME: these should be constants in common.py
|
---|
[48] | 364 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 365 | else gtk.POLICY_AUTOMATIC,
|
---|
[69] | 366 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 367 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 368 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 369 | else gtk.SHADOW_IN)
|
---|
[48] | 370 |
|
---|
| 371 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
| 372 | alignment.add(scrolledWindow)
|
---|
| 373 |
|
---|
| 374 | self.setMainWidget(alignment)
|
---|
| 375 |
|
---|
[107] | 376 | self._button = self.addNextButton(sensitive = False,
|
---|
| 377 | clicked = self._forwardClicked)
|
---|
[48] | 378 |
|
---|
| 379 | def activate(self):
|
---|
| 380 | """Fill the flight list."""
|
---|
[70] | 381 | self._flightList.set_sensitive(True)
|
---|
| 382 | self._listStore.clear()
|
---|
| 383 | for flight in self._wizard.loginResult.flights:
|
---|
| 384 | self._listStore.append([str(flight.departureTime),
|
---|
| 385 | flight.callsign,
|
---|
| 386 | flight.departureICAO,
|
---|
| 387 | flight.arrivalICAO])
|
---|
| 388 |
|
---|
| 389 | def finalize(self):
|
---|
| 390 | """Finalize the page."""
|
---|
| 391 | self._flightList.set_sensitive(False)
|
---|
[48] | 392 |
|
---|
| 393 | def _selectionChanged(self, selection):
|
---|
| 394 | """Called when the selection is changed."""
|
---|
| 395 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
[42] | 396 |
|
---|
[51] | 397 | def _forwardClicked(self, button):
|
---|
| 398 | """Called when the forward button was clicked."""
|
---|
[94] | 399 | if self._completed:
|
---|
[70] | 400 | self._wizard.jumpPage(self._nextDistance, finalize = False)
|
---|
| 401 | else:
|
---|
| 402 | selection = self._flightList.get_selection()
|
---|
| 403 | (listStore, iter) = selection.get_selected()
|
---|
| 404 | path = listStore.get_path(iter)
|
---|
| 405 | [index] = path.get_indices() if pygobject else path
|
---|
[51] | 406 |
|
---|
[70] | 407 | flight = self._wizard.loginResult.flights[index]
|
---|
| 408 | self._wizard._bookedFlight = flight
|
---|
[93] | 409 | self._wizard.gui.enableFlightInfo()
|
---|
[51] | 410 |
|
---|
[70] | 411 | self._updateDepartureGate()
|
---|
[51] | 412 |
|
---|
| 413 | def _updateDepartureGate(self):
|
---|
| 414 | """Update the departure gate for the booked flight."""
|
---|
| 415 | flight = self._wizard._bookedFlight
|
---|
[136] | 416 | if self._wizard.gui.config.onlineGateSystem:
|
---|
| 417 | if flight.departureICAO=="LHBP":
|
---|
| 418 | self._wizard.getFleet(self._fleetRetrieved)
|
---|
| 419 | else:
|
---|
| 420 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 421 | flight.tailNumber,
|
---|
| 422 | const.PLANE_AWAY)
|
---|
[51] | 423 | else:
|
---|
[136] | 424 | self._nextDistance = 2
|
---|
| 425 | self._wizard.jumpPage(2)
|
---|
| 426 |
|
---|
[51] | 427 | def _fleetRetrieved(self, fleet):
|
---|
| 428 | """Called when the fleet has been retrieved."""
|
---|
| 429 | if fleet is None:
|
---|
[70] | 430 | self._nextDistance = 2
|
---|
[51] | 431 | self._wizard.jumpPage(2)
|
---|
| 432 | else:
|
---|
| 433 | plane = fleet[self._wizard._bookedFlight.tailNumber]
|
---|
| 434 | if plane is None:
|
---|
[70] | 435 | self._nextDistance = 2
|
---|
[51] | 436 | self._wizard.jumpPage(2)
|
---|
[70] | 437 | elif plane.gateNumber is not None and \
|
---|
| 438 | not fleet.isGateConflicting(plane):
|
---|
[51] | 439 | self._wizard._departureGate = plane.gateNumber
|
---|
[70] | 440 | self._nextDistance = 2
|
---|
[51] | 441 | self._wizard.jumpPage(2)
|
---|
| 442 | else:
|
---|
[70] | 443 | self._nextDistance = 1
|
---|
[51] | 444 | self._wizard.nextPage()
|
---|
[130] | 445 |
|
---|
| 446 | def _planeUpdated(self, success):
|
---|
| 447 | """Callback for the plane updating."""
|
---|
| 448 | self._nextDistance = 2
|
---|
| 449 | self._wizard.jumpPage(2)
|
---|
[51] | 450 |
|
---|
| 451 | #-----------------------------------------------------------------------------
|
---|
| 452 |
|
---|
| 453 | class GateSelectionPage(Page):
|
---|
| 454 | """Page to select a free gate at LHBP.
|
---|
| 455 | This page should be displayed only if we have fleet information!."""
|
---|
| 456 | def __init__(self, wizard):
|
---|
| 457 | """Construct the gate selection page."""
|
---|
[107] | 458 | super(GateSelectionPage, self).__init__(wizard, xstr("gatesel_title"),
|
---|
| 459 | xstr("gatesel_help"))
|
---|
| 460 |
|
---|
[51] | 461 | self._listStore = gtk.ListStore(str)
|
---|
| 462 | self._gateList = gtk.TreeView(self._listStore)
|
---|
| 463 | column = gtk.TreeViewColumn(None, gtk.CellRendererText(),
|
---|
| 464 | text = 0)
|
---|
| 465 | column.set_expand(True)
|
---|
| 466 | self._gateList.append_column(column)
|
---|
| 467 | self._gateList.set_headers_visible(False)
|
---|
| 468 |
|
---|
| 469 | gateSelection = self._gateList.get_selection()
|
---|
| 470 | gateSelection.connect("changed", self._selectionChanged)
|
---|
| 471 |
|
---|
| 472 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 473 | scrolledWindow.add(self._gateList)
|
---|
| 474 | scrolledWindow.set_size_request(50, -1)
|
---|
| 475 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 476 | else gtk.POLICY_AUTOMATIC,
|
---|
[69] | 477 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 478 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 479 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 480 | else gtk.SHADOW_IN)
|
---|
[51] | 481 |
|
---|
| 482 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
| 483 | alignment.add(scrolledWindow)
|
---|
| 484 |
|
---|
| 485 | self.setMainWidget(alignment)
|
---|
| 486 |
|
---|
[107] | 487 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[73] | 488 |
|
---|
[107] | 489 | self._button = self.addNextButton(sensitive = False,
|
---|
| 490 | clicked = self._forwardClicked)
|
---|
[51] | 491 |
|
---|
| 492 | def activate(self):
|
---|
| 493 | """Fill the gate list."""
|
---|
| 494 | self._listStore.clear()
|
---|
[70] | 495 | self._gateList.set_sensitive(True)
|
---|
[51] | 496 | occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
| 497 | for gateNumber in const.lhbpGateNumbers:
|
---|
| 498 | if gateNumber not in occupiedGateNumbers:
|
---|
| 499 | self._listStore.append([gateNumber])
|
---|
| 500 |
|
---|
[70] | 501 | def finalize(self):
|
---|
| 502 | """Finalize the page."""
|
---|
| 503 | self._gateList.set_sensitive(False)
|
---|
| 504 |
|
---|
[51] | 505 | def _selectionChanged(self, selection):
|
---|
| 506 | """Called when the selection is changed."""
|
---|
| 507 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
| 508 |
|
---|
[73] | 509 | def _backClicked(self, button):
|
---|
| 510 | """Called when the Back button is pressed."""
|
---|
| 511 | self.goBack()
|
---|
| 512 |
|
---|
[51] | 513 | def _forwardClicked(self, button):
|
---|
| 514 | """Called when the forward button is clicked."""
|
---|
[94] | 515 | if not self._completed:
|
---|
[70] | 516 | selection = self._gateList.get_selection()
|
---|
| 517 | (listStore, iter) = selection.get_selected()
|
---|
| 518 | (gateNumber,) = listStore.get(iter, 0)
|
---|
[51] | 519 |
|
---|
[70] | 520 | self._wizard._departureGate = gateNumber
|
---|
[51] | 521 |
|
---|
[130] | 522 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 523 | self._wizard._bookedFlight.tailNumber,
|
---|
| 524 | const.PLANE_HOME, gateNumber)
|
---|
| 525 | else:
|
---|
| 526 | self._wizard.nextPage()
|
---|
[51] | 527 |
|
---|
| 528 | def _planeUpdated(self, success):
|
---|
| 529 | """Callback for the plane updating call."""
|
---|
| 530 | if success is None or success:
|
---|
| 531 | self._wizard.nextPage()
|
---|
| 532 | else:
|
---|
[105] | 533 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
| 534 | type = MESSAGETYPE_ERROR,
|
---|
[107] | 535 | message_format = xstr("gatesel_conflict"))
|
---|
[124] | 536 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
[105] | 537 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
[107] | 538 | dialog.format_secondary_markup(xstr("gatesel_conflict_sec"))
|
---|
[51] | 539 | dialog.run()
|
---|
| 540 | dialog.hide()
|
---|
| 541 |
|
---|
[126] | 542 | self._wizard.getFleet(self._fleetRetrieved)
|
---|
[51] | 543 |
|
---|
| 544 | def _fleetRetrieved(self, fleet):
|
---|
| 545 | """Called when the fleet has been retrieved."""
|
---|
| 546 | if fleet is None:
|
---|
| 547 | self._wizard.nextPage()
|
---|
| 548 | else:
|
---|
| 549 | self.activate()
|
---|
| 550 |
|
---|
| 551 | #-----------------------------------------------------------------------------
|
---|
| 552 |
|
---|
| 553 | class ConnectPage(Page):
|
---|
| 554 | """Page which displays the departure airport and gate (if at LHBP)."""
|
---|
| 555 | def __init__(self, wizard):
|
---|
| 556 | """Construct the connect page."""
|
---|
[78] | 557 | help = "Load the aircraft below into the simulator and park it\n" \
|
---|
| 558 | "at the given airport, at the gate below, if present.\n\n" \
|
---|
[51] | 559 | "Then press the Connect button to connect to the simulator."
|
---|
[94] | 560 | completedHelp = "The basic data of your flight can be read below."
|
---|
[107] | 561 | super(ConnectPage, self).__init__(wizard, xstr("connect_title"),
|
---|
| 562 | xstr("connect_help"),
|
---|
| 563 | completedHelp = xstr("connect_chelp"))
|
---|
[51] | 564 |
|
---|
| 565 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 566 | xscale = 0.0, yscale = 0.0)
|
---|
| 567 |
|
---|
[78] | 568 | table = gtk.Table(5, 2)
|
---|
[51] | 569 | table.set_row_spacings(4)
|
---|
| 570 | table.set_col_spacings(16)
|
---|
| 571 | table.set_homogeneous(True)
|
---|
| 572 | alignment.add(table)
|
---|
| 573 | self.setMainWidget(alignment)
|
---|
| 574 |
|
---|
| 575 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 576 | label = gtk.Label(xstr("connect_flightno"))
|
---|
[51] | 577 | labelAlignment.add(label)
|
---|
| 578 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 579 |
|
---|
| 580 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[78] | 581 | self._flightNumber = gtk.Label()
|
---|
[82] | 582 | self._flightNumber.set_width_chars(7)
|
---|
[78] | 583 | self._flightNumber.set_alignment(0.0, 0.5)
|
---|
| 584 | labelAlignment.add(self._flightNumber)
|
---|
| 585 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
| 586 |
|
---|
| 587 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 588 | label = gtk.Label(xstr("connect_acft"))
|
---|
[78] | 589 | labelAlignment.add(label)
|
---|
| 590 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 591 |
|
---|
| 592 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 593 | self._aircraft = gtk.Label()
|
---|
| 594 | self._aircraft.set_width_chars(25)
|
---|
| 595 | self._aircraft.set_alignment(0.0, 0.5)
|
---|
| 596 | labelAlignment.add(self._aircraft)
|
---|
| 597 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
| 598 |
|
---|
| 599 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 600 | label = gtk.Label(xstr("connect_tailno"))
|
---|
[78] | 601 | labelAlignment.add(label)
|
---|
| 602 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
| 603 |
|
---|
| 604 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 605 | self._tailNumber = gtk.Label()
|
---|
[80] | 606 | self._tailNumber.set_width_chars(10)
|
---|
[78] | 607 | self._tailNumber.set_alignment(0.0, 0.5)
|
---|
| 608 | labelAlignment.add(self._tailNumber)
|
---|
| 609 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
| 610 |
|
---|
| 611 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 612 | label = gtk.Label(xstr("connect_airport"))
|
---|
[78] | 613 | labelAlignment.add(label)
|
---|
| 614 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
| 615 |
|
---|
| 616 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
[51] | 617 | self._departureICAO = gtk.Label()
|
---|
[80] | 618 | self._departureICAO.set_width_chars(6)
|
---|
[51] | 619 | self._departureICAO.set_alignment(0.0, 0.5)
|
---|
| 620 | labelAlignment.add(self._departureICAO)
|
---|
[78] | 621 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
[51] | 622 |
|
---|
| 623 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 624 | label = gtk.Label(xstr("connect_gate"))
|
---|
[51] | 625 | labelAlignment.add(label)
|
---|
[78] | 626 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
[51] | 627 |
|
---|
| 628 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 629 | self._departureGate = gtk.Label()
|
---|
| 630 | self._departureGate.set_width_chars(5)
|
---|
| 631 | self._departureGate.set_alignment(0.0, 0.5)
|
---|
| 632 | labelAlignment.add(self._departureGate)
|
---|
[78] | 633 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
[51] | 634 |
|
---|
[107] | 635 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[70] | 636 |
|
---|
[107] | 637 | self._button = self.addButton(xstr("button_connect"), default = True,
|
---|
| 638 | tooltip = xstr("button_connect_tooltip"))
|
---|
[70] | 639 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[51] | 640 |
|
---|
| 641 | def activate(self):
|
---|
[60] | 642 | """Setup the departure information."""
|
---|
[107] | 643 | self._button.set_label(xstr("button_connect"))
|
---|
[70] | 644 | self._button.set_use_underline(True)
|
---|
[107] | 645 | self._button.set_tooltip_text(xstr("button_connect_tooltip"))
|
---|
[70] | 646 | self._button.disconnect(self._clickedID)
|
---|
| 647 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
[78] | 648 |
|
---|
| 649 | bookedFlight = self._wizard._bookedFlight
|
---|
| 650 |
|
---|
| 651 | self._flightNumber.set_markup("<b>" + bookedFlight.callsign + "</b>")
|
---|
| 652 |
|
---|
| 653 | aircraftType = acftTypeNames[bookedFlight.aircraftType]
|
---|
| 654 | self._aircraft.set_markup("<b>" + aircraftType + "</b>")
|
---|
[70] | 655 |
|
---|
[78] | 656 | self._tailNumber.set_markup("<b>" + bookedFlight.tailNumber + "</b>")
|
---|
| 657 |
|
---|
| 658 | icao = bookedFlight.departureICAO
|
---|
[51] | 659 | self._departureICAO.set_markup("<b>" + icao + "</b>")
|
---|
| 660 | gate = self._wizard._departureGate
|
---|
| 661 | if gate!="-":
|
---|
| 662 | gate = "<b>" + gate + "</b>"
|
---|
| 663 | self._departureGate.set_markup(gate)
|
---|
| 664 |
|
---|
[70] | 665 | def finalize(self):
|
---|
| 666 | """Finalize the page."""
|
---|
[107] | 667 | self._button.set_label(xstr("button_next"))
|
---|
| 668 | self._button.set_use_underline(True)
|
---|
| 669 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
[70] | 670 | self._button.disconnect(self._clickedID)
|
---|
| 671 | self._clickedID = self._button.connect("clicked", self._forwardClicked)
|
---|
| 672 |
|
---|
| 673 | def _backClicked(self, button):
|
---|
| 674 | """Called when the Back button is pressed."""
|
---|
| 675 | self.goBack()
|
---|
| 676 |
|
---|
[51] | 677 | def _connectClicked(self, button):
|
---|
| 678 | """Called when the Connect button is pressed."""
|
---|
| 679 | self._wizard._connectSimulator()
|
---|
| 680 |
|
---|
[70] | 681 | def _forwardClicked(self, button):
|
---|
| 682 | """Called when the Forward button is pressed."""
|
---|
| 683 | self._wizard.nextPage()
|
---|
| 684 |
|
---|
[42] | 685 | #-----------------------------------------------------------------------------
|
---|
| 686 |
|
---|
[59] | 687 | class PayloadPage(Page):
|
---|
| 688 | """Page to allow setting up the payload."""
|
---|
| 689 | def __init__(self, wizard):
|
---|
| 690 | """Construct the page."""
|
---|
[107] | 691 | super(PayloadPage, self).__init__(wizard, xstr("payload_title"),
|
---|
| 692 | xstr("payload_help"),
|
---|
| 693 | completedHelp = xstr("payload_chelp"))
|
---|
[59] | 694 |
|
---|
[60] | 695 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 696 | xscale = 0.0, yscale = 0.0)
|
---|
| 697 |
|
---|
| 698 | table = gtk.Table(7, 3)
|
---|
| 699 | table.set_row_spacings(4)
|
---|
| 700 | table.set_col_spacings(16)
|
---|
| 701 | table.set_homogeneous(False)
|
---|
| 702 | alignment.add(table)
|
---|
| 703 | self.setMainWidget(alignment)
|
---|
| 704 |
|
---|
[107] | 705 | label = gtk.Label(xstr("payload_crew"))
|
---|
[60] | 706 | label.set_alignment(0.0, 0.5)
|
---|
| 707 | table.attach(label, 0, 1, 0, 1)
|
---|
| 708 |
|
---|
| 709 | self._numCrew = gtk.Label()
|
---|
| 710 | self._numCrew.set_width_chars(6)
|
---|
| 711 | self._numCrew.set_alignment(1.0, 0.5)
|
---|
| 712 | table.attach(self._numCrew, 1, 2, 0, 1)
|
---|
| 713 |
|
---|
[107] | 714 | label = gtk.Label(xstr("payload_pax"))
|
---|
[60] | 715 | label.set_alignment(0.0, 0.5)
|
---|
| 716 | table.attach(label, 0, 1, 1, 2)
|
---|
| 717 |
|
---|
| 718 | self._numPassengers = gtk.Label()
|
---|
| 719 | self._numPassengers.set_width_chars(6)
|
---|
| 720 | self._numPassengers.set_alignment(1.0, 0.5)
|
---|
| 721 | table.attach(self._numPassengers, 1, 2, 1, 2)
|
---|
| 722 |
|
---|
[107] | 723 | label = gtk.Label(xstr("payload_bag"))
|
---|
[60] | 724 | label.set_alignment(0.0, 0.5)
|
---|
| 725 | table.attach(label, 0, 1, 2, 3)
|
---|
| 726 |
|
---|
| 727 | self._bagWeight = gtk.Label()
|
---|
| 728 | self._bagWeight.set_width_chars(6)
|
---|
| 729 | self._bagWeight.set_alignment(1.0, 0.5)
|
---|
| 730 | table.attach(self._bagWeight, 1, 2, 2, 3)
|
---|
| 731 |
|
---|
| 732 | table.attach(gtk.Label("kg"), 2, 3, 2, 3)
|
---|
| 733 |
|
---|
[107] | 734 | label = gtk.Label(xstr("payload_cargo"))
|
---|
[60] | 735 | label.set_use_underline(True)
|
---|
| 736 | label.set_alignment(0.0, 0.5)
|
---|
| 737 | table.attach(label, 0, 1, 3, 4)
|
---|
| 738 |
|
---|
[84] | 739 | self._cargoWeight = IntegerEntry(defaultValue = 0)
|
---|
[60] | 740 | self._cargoWeight.set_width_chars(6)
|
---|
[84] | 741 | self._cargoWeight.connect("integer-changed", self._cargoWeightChanged)
|
---|
[107] | 742 | self._cargoWeight.set_tooltip_text(xstr("payload_cargo_tooltip"))
|
---|
[60] | 743 | table.attach(self._cargoWeight, 1, 2, 3, 4)
|
---|
| 744 | label.set_mnemonic_widget(self._cargoWeight)
|
---|
| 745 |
|
---|
| 746 | table.attach(gtk.Label("kg"), 2, 3, 3, 4)
|
---|
| 747 |
|
---|
[107] | 748 | label = gtk.Label(xstr("payload_mail"))
|
---|
[60] | 749 | label.set_alignment(0.0, 0.5)
|
---|
| 750 | table.attach(label, 0, 1, 4, 5)
|
---|
| 751 |
|
---|
| 752 | self._mailWeight = gtk.Label()
|
---|
| 753 | self._mailWeight.set_width_chars(6)
|
---|
| 754 | self._mailWeight.set_alignment(1.0, 0.5)
|
---|
| 755 | table.attach(self._mailWeight, 1, 2, 4, 5)
|
---|
| 756 |
|
---|
| 757 | table.attach(gtk.Label("kg"), 2, 3, 4, 5)
|
---|
| 758 |
|
---|
[107] | 759 | label = gtk.Label("<b>" + xstr("payload_zfw") + "</b>")
|
---|
[60] | 760 | label.set_alignment(0.0, 0.5)
|
---|
| 761 | label.set_use_markup(True)
|
---|
| 762 | table.attach(label, 0, 1, 5, 6)
|
---|
| 763 |
|
---|
| 764 | self._calculatedZFW = gtk.Label()
|
---|
| 765 | self._calculatedZFW.set_width_chars(6)
|
---|
| 766 | self._calculatedZFW.set_alignment(1.0, 0.5)
|
---|
| 767 | table.attach(self._calculatedZFW, 1, 2, 5, 6)
|
---|
| 768 |
|
---|
| 769 | table.attach(gtk.Label("kg"), 2, 3, 5, 6)
|
---|
| 770 |
|
---|
[107] | 771 | self._zfwButton = gtk.Button(xstr("payload_fszfw"))
|
---|
[70] | 772 | self._zfwButton.set_use_underline(True)
|
---|
| 773 | self._zfwButton.connect("clicked", self._zfwRequested)
|
---|
[107] | 774 | self._zfwButton.set_tooltip_text(xstr("payload_fszfw_tooltip"))
|
---|
[70] | 775 | table.attach(self._zfwButton, 0, 1, 6, 7)
|
---|
[60] | 776 |
|
---|
| 777 | self._simulatorZFW = gtk.Label("-")
|
---|
| 778 | self._simulatorZFW.set_width_chars(6)
|
---|
| 779 | self._simulatorZFW.set_alignment(1.0, 0.5)
|
---|
| 780 | table.attach(self._simulatorZFW, 1, 2, 6, 7)
|
---|
| 781 | self._simulatorZFWValue = None
|
---|
| 782 |
|
---|
| 783 | table.attach(gtk.Label("kg"), 2, 3, 6, 7)
|
---|
| 784 |
|
---|
[107] | 785 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 786 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[60] | 787 |
|
---|
[97] | 788 | @property
|
---|
| 789 | def cargoWeight(self):
|
---|
| 790 | """Get the cargo weight entered."""
|
---|
| 791 | return self._cargoWeight.get_int()
|
---|
| 792 |
|
---|
[60] | 793 | def activate(self):
|
---|
| 794 | """Setup the information."""
|
---|
| 795 | bookedFlight = self._wizard._bookedFlight
|
---|
| 796 | self._numCrew.set_text(str(bookedFlight.numCrew))
|
---|
| 797 | self._numPassengers.set_text(str(bookedFlight.numPassengers))
|
---|
| 798 | self._bagWeight.set_text(str(bookedFlight.bagWeight))
|
---|
[84] | 799 | self._cargoWeight.set_int(bookedFlight.cargoWeight)
|
---|
[70] | 800 | self._cargoWeight.set_sensitive(True)
|
---|
[60] | 801 | self._mailWeight.set_text(str(bookedFlight.mailWeight))
|
---|
[92] | 802 | self._simulatorZFW.set_text("-")
|
---|
| 803 | self._simulatorZFWValue = None
|
---|
[70] | 804 | self._zfwButton.set_sensitive(True)
|
---|
[60] | 805 | self._updateCalculatedZFW()
|
---|
[59] | 806 |
|
---|
[70] | 807 | def finalize(self):
|
---|
| 808 | """Finalize the payload page."""
|
---|
| 809 | self._cargoWeight.set_sensitive(False)
|
---|
[117] | 810 | self._wizard.gui.initializeWeightHelp()
|
---|
[70] | 811 |
|
---|
[84] | 812 | def calculateZFW(self):
|
---|
[60] | 813 | """Calculate the ZFW value."""
|
---|
| 814 | zfw = self._wizard.gui._flight.aircraft.dow
|
---|
| 815 | bookedFlight = self._wizard._bookedFlight
|
---|
| 816 | zfw += (bookedFlight.numCrew + bookedFlight.numPassengers) * 82
|
---|
| 817 | zfw += bookedFlight.bagWeight
|
---|
[84] | 818 | zfw += self._cargoWeight.get_int()
|
---|
[60] | 819 | zfw += bookedFlight.mailWeight
|
---|
| 820 | return zfw
|
---|
| 821 |
|
---|
| 822 | def _updateCalculatedZFW(self):
|
---|
| 823 | """Update the calculated ZFW"""
|
---|
[84] | 824 | zfw = self.calculateZFW()
|
---|
[60] | 825 |
|
---|
| 826 | markupBegin = "<b>"
|
---|
| 827 | markupEnd = "</b>"
|
---|
| 828 | if self._simulatorZFWValue is not None and \
|
---|
| 829 | PayloadChecker.isZFWFaulty(self._simulatorZFWValue, zfw):
|
---|
| 830 | markupBegin += '<span foreground="red">'
|
---|
| 831 | markupEnd = "</span>" + markupEnd
|
---|
| 832 | self._calculatedZFW.set_markup(markupBegin + str(zfw) + markupEnd)
|
---|
| 833 |
|
---|
[84] | 834 | def _cargoWeightChanged(self, entry, weight):
|
---|
[60] | 835 | """Called when the cargo weight has changed."""
|
---|
| 836 | self._updateCalculatedZFW()
|
---|
| 837 |
|
---|
[59] | 838 | def _zfwRequested(self, button):
|
---|
| 839 | """Called when the ZFW is requested from the simulator."""
|
---|
[70] | 840 | self._zfwButton.set_sensitive(False)
|
---|
| 841 | self._backButton.set_sensitive(False)
|
---|
| 842 | self._button.set_sensitive(False)
|
---|
| 843 | gui = self._wizard.gui
|
---|
[107] | 844 | gui.beginBusy(xstr("payload_zfw_busy"))
|
---|
[70] | 845 | gui.simulator.requestZFW(self._handleZFW)
|
---|
[59] | 846 |
|
---|
| 847 | def _handleZFW(self, zfw):
|
---|
| 848 | """Called when the ZFW value is retrieved."""
|
---|
[60] | 849 | gobject.idle_add(self._processZFW, zfw)
|
---|
[59] | 850 |
|
---|
[60] | 851 | def _processZFW(self, zfw):
|
---|
| 852 | """Process the given ZFW value received from the simulator."""
|
---|
[61] | 853 | self._wizard.gui.endBusy()
|
---|
[70] | 854 | self._zfwButton.set_sensitive(True)
|
---|
| 855 | self._backButton.set_sensitive(True)
|
---|
| 856 | self._button.set_sensitive(True)
|
---|
[60] | 857 | self._simulatorZFWValue = zfw
|
---|
| 858 | self._simulatorZFW.set_text("%.0f" % (zfw,))
|
---|
| 859 | self._updateCalculatedZFW()
|
---|
| 860 |
|
---|
| 861 | def _forwardClicked(self, button):
|
---|
| 862 | """Called when the forward button is clicked."""
|
---|
| 863 | self._wizard.nextPage()
|
---|
[70] | 864 |
|
---|
| 865 | def _backClicked(self, button):
|
---|
| 866 | """Called when the Back button is pressed."""
|
---|
| 867 | self.goBack()
|
---|
[60] | 868 |
|
---|
[59] | 869 | #-----------------------------------------------------------------------------
|
---|
| 870 |
|
---|
[61] | 871 | class TimePage(Page):
|
---|
| 872 | """Page displaying the departure and arrival times and allows querying the
|
---|
| 873 | current time from the flight simulator."""
|
---|
| 874 | def __init__(self, wizard):
|
---|
[107] | 875 | super(TimePage, self).__init__(wizard, xstr("time_title"),
|
---|
| 876 | xstr("time_help"),
|
---|
| 877 | completedHelp = xstr("time_chelp"))
|
---|
[61] | 878 |
|
---|
| 879 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 880 | xscale = 0.0, yscale = 0.0)
|
---|
| 881 |
|
---|
| 882 | table = gtk.Table(3, 2)
|
---|
| 883 | table.set_row_spacings(4)
|
---|
| 884 | table.set_col_spacings(16)
|
---|
| 885 | table.set_homogeneous(False)
|
---|
| 886 | alignment.add(table)
|
---|
| 887 | self.setMainWidget(alignment)
|
---|
| 888 |
|
---|
[107] | 889 | label = gtk.Label(xstr("time_departure"))
|
---|
[61] | 890 | label.set_alignment(0.0, 0.5)
|
---|
| 891 | table.attach(label, 0, 1, 0, 1)
|
---|
| 892 |
|
---|
| 893 | self._departure = gtk.Label()
|
---|
| 894 | self._departure.set_alignment(0.0, 0.5)
|
---|
| 895 | table.attach(self._departure, 1, 2, 0, 1)
|
---|
| 896 |
|
---|
[107] | 897 | label = gtk.Label(xstr("time_arrival"))
|
---|
[61] | 898 | label.set_alignment(0.0, 0.5)
|
---|
| 899 | table.attach(label, 0, 1, 1, 2)
|
---|
| 900 |
|
---|
| 901 | self._arrival = gtk.Label()
|
---|
| 902 | self._arrival.set_alignment(0.0, 0.5)
|
---|
| 903 | table.attach(self._arrival, 1, 2, 1, 2)
|
---|
| 904 |
|
---|
[107] | 905 | self._timeButton = gtk.Button(xstr("time_fs"))
|
---|
[70] | 906 | self._timeButton.set_use_underline(True)
|
---|
[107] | 907 | self._timeButton.set_tooltip_text(xstr("time_fs_tooltip"))
|
---|
[70] | 908 | self._timeButton.connect("clicked", self._timeRequested)
|
---|
| 909 | table.attach(self._timeButton, 0, 1, 2, 3)
|
---|
[61] | 910 |
|
---|
| 911 | self._simulatorTime = gtk.Label("-")
|
---|
| 912 | self._simulatorTime.set_alignment(0.0, 0.5)
|
---|
| 913 | table.attach(self._simulatorTime, 1, 2, 2, 3)
|
---|
| 914 |
|
---|
[107] | 915 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 916 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[61] | 917 |
|
---|
| 918 | def activate(self):
|
---|
| 919 | """Activate the page."""
|
---|
[70] | 920 | self._timeButton.set_sensitive(True)
|
---|
[61] | 921 | bookedFlight = self._wizard._bookedFlight
|
---|
| 922 | self._departure.set_text(str(bookedFlight.departureTime.time()))
|
---|
| 923 | self._arrival.set_text(str(bookedFlight.arrivalTime.time()))
|
---|
[92] | 924 | self._simulatorTime.set_text("-")
|
---|
[61] | 925 |
|
---|
| 926 | def _timeRequested(self, button):
|
---|
| 927 | """Request the time from the simulator."""
|
---|
[70] | 928 | self._timeButton.set_sensitive(False)
|
---|
| 929 | self._backButton.set_sensitive(False)
|
---|
| 930 | self._button.set_sensitive(False)
|
---|
[107] | 931 | self._wizard.gui.beginBusy(xstr("time_busy"))
|
---|
[61] | 932 | self._wizard.gui.simulator.requestTime(self._handleTime)
|
---|
| 933 |
|
---|
| 934 | def _handleTime(self, timestamp):
|
---|
| 935 | """Handle the result of a time retrieval."""
|
---|
| 936 | gobject.idle_add(self._processTime, timestamp)
|
---|
| 937 |
|
---|
| 938 | def _processTime(self, timestamp):
|
---|
| 939 | """Process the given time."""
|
---|
| 940 | self._wizard.gui.endBusy()
|
---|
[70] | 941 | self._timeButton.set_sensitive(True)
|
---|
| 942 | self._backButton.set_sensitive(True)
|
---|
| 943 | self._button.set_sensitive(True)
|
---|
[61] | 944 | tm = time.gmtime(timestamp)
|
---|
| 945 | t = datetime.time(tm.tm_hour, tm.tm_min, tm.tm_sec)
|
---|
| 946 | self._simulatorTime.set_text(str(t))
|
---|
| 947 |
|
---|
| 948 | ts = tm.tm_hour * 3600 + tm.tm_min * 60 + tm.tm_sec
|
---|
| 949 | dt = self._wizard._bookedFlight.departureTime.time()
|
---|
| 950 | dts = dt.hour * 3600 + dt.minute * 60 + dt.second
|
---|
| 951 | diff = dts-ts
|
---|
| 952 |
|
---|
| 953 | markupBegin = ""
|
---|
| 954 | markupEnd = ""
|
---|
| 955 | if diff < 0:
|
---|
| 956 | markupBegin = '<b><span foreground="red">'
|
---|
| 957 | markupEnd = '</span></b>'
|
---|
| 958 | elif diff < 3*60 or diff > 30*60:
|
---|
| 959 | markupBegin = '<b><span foreground="orange">'
|
---|
| 960 | markupEnd = '</span></b>'
|
---|
| 961 |
|
---|
| 962 | self._departure.set_markup(markupBegin + str(dt) + markupEnd)
|
---|
| 963 |
|
---|
[70] | 964 | def _backClicked(self, button):
|
---|
| 965 | """Called when the Back button is pressed."""
|
---|
| 966 | self.goBack()
|
---|
| 967 |
|
---|
[61] | 968 | def _forwardClicked(self, button):
|
---|
| 969 | """Called when the forward button is clicked."""
|
---|
[141] | 970 | if not self._completed:
|
---|
| 971 | gui = self._wizard.gui
|
---|
| 972 | gui.beginBusy(xstr("fuel_get_busy"))
|
---|
| 973 |
|
---|
| 974 | gui.simulator.getFuel(gui.flight.aircraft.fuelTanks,
|
---|
| 975 | self._handleFuel)
|
---|
| 976 | else:
|
---|
| 977 | self._wizard.nextPage()
|
---|
| 978 |
|
---|
| 979 | def _handleFuel(self, fuelData):
|
---|
| 980 | """Callback for the fuel query operation."""
|
---|
| 981 | gobject.idle_add(self._processFuel, fuelData)
|
---|
| 982 |
|
---|
| 983 | def _processFuel(self, fuelData):
|
---|
| 984 | """Process the given fuel data."""
|
---|
| 985 | self._wizard.gui.endBusy()
|
---|
| 986 | self._wizard._fuelData = fuelData
|
---|
[61] | 987 | self._wizard.nextPage()
|
---|
| 988 |
|
---|
| 989 | #-----------------------------------------------------------------------------
|
---|
| 990 |
|
---|
[141] | 991 | class FuelTank(gtk.VBox):
|
---|
| 992 | """Widget for the fuel tank."""
|
---|
| 993 | def __init__(self, fuelTank, name, capacity, currentWeight):
|
---|
| 994 | """Construct the widget for the tank with the given name."""
|
---|
| 995 | super(FuelTank, self).__init__()
|
---|
| 996 |
|
---|
[146] | 997 | self._enabled = True
|
---|
[141] | 998 | self.fuelTank = fuelTank
|
---|
| 999 | self.capacity = capacity
|
---|
| 1000 | self.currentWeight = currentWeight
|
---|
| 1001 | self.expectedWeight = currentWeight
|
---|
| 1002 |
|
---|
| 1003 | label = gtk.Label("<b>" + name + "</b>")
|
---|
| 1004 | label.set_use_markup(True)
|
---|
[145] | 1005 | label.set_use_underline(True)
|
---|
[141] | 1006 | label.set_justify(JUSTIFY_CENTER)
|
---|
| 1007 | label.set_alignment(0.5, 1.0)
|
---|
| 1008 | self.pack_start(label, False, False, 4)
|
---|
| 1009 |
|
---|
[142] | 1010 | self._tankFigure = gtk.EventBox()
|
---|
[141] | 1011 | self._tankFigure.set_size_request(38, -1)
|
---|
[142] | 1012 | self._tankFigure.set_visible_window(False)
|
---|
[144] | 1013 | self._tankFigure.set_tooltip_markup(xstr("fuel_tank_tooltip"))
|
---|
[141] | 1014 |
|
---|
| 1015 | if pygobject:
|
---|
| 1016 | self._tankFigure.connect("draw", self._drawTankFigure)
|
---|
| 1017 | else:
|
---|
| 1018 | self._tankFigure.connect("expose_event", self._drawTankFigure)
|
---|
[144] | 1019 | self._tankFigure.connect("button_press_event", self._buttonPressed)
|
---|
| 1020 | self._tankFigure.connect("motion_notify_event", self._motionNotify)
|
---|
| 1021 | self._tankFigure.connect("scroll-event", self._scrolled)
|
---|
| 1022 |
|
---|
[141] | 1023 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1024 | xscale = 0.0, yscale = 1.0)
|
---|
[142] | 1025 | alignment.add(self._tankFigure)
|
---|
[141] | 1026 |
|
---|
| 1027 | self.pack_start(alignment, True, True, 4)
|
---|
| 1028 |
|
---|
| 1029 | self._expectedButton = gtk.SpinButton()
|
---|
| 1030 | self._expectedButton.set_numeric(True)
|
---|
| 1031 | self._expectedButton.set_range(0, self.capacity)
|
---|
| 1032 | self._expectedButton.set_increments(10, 100)
|
---|
| 1033 | self._expectedButton.set_value(currentWeight)
|
---|
| 1034 | self._expectedButton.set_alignment(1.0)
|
---|
| 1035 | self._expectedButton.set_width_chars(5)
|
---|
| 1036 | self._expectedButton.connect("value-changed", self._expectedChanged)
|
---|
| 1037 |
|
---|
[145] | 1038 | label.set_mnemonic_widget(self._expectedButton)
|
---|
| 1039 |
|
---|
[141] | 1040 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1041 | xscale = 0.0, yscale = 1.0)
|
---|
| 1042 | alignment.add(self._expectedButton)
|
---|
| 1043 | self.pack_start(alignment, False, False, 4)
|
---|
| 1044 |
|
---|
| 1045 | def setCurrent(self, currentWeight):
|
---|
| 1046 | """Set the current weight."""
|
---|
| 1047 | self.currentWeight = currentWeight
|
---|
| 1048 | self._redraw()
|
---|
| 1049 |
|
---|
| 1050 | def isCorrect(self):
|
---|
| 1051 | """Determine if the contents of the fuel tank are as expected"""
|
---|
| 1052 | return abs(self.expectedWeight - self.currentWeight)<=1
|
---|
| 1053 |
|
---|
| 1054 | def disable(self):
|
---|
| 1055 | """Disable the fuel tank."""
|
---|
| 1056 | self._expectedButton.set_sensitive(False)
|
---|
[146] | 1057 | self._enabled = False
|
---|
[141] | 1058 |
|
---|
| 1059 | def _redraw(self):
|
---|
| 1060 | """Redraw the tank figure."""
|
---|
| 1061 | self._tankFigure.queue_draw()
|
---|
| 1062 |
|
---|
[142] | 1063 | def _drawTankFigure(self, tankFigure, eventOrContext):
|
---|
[141] | 1064 | """Draw the tank figure."""
|
---|
| 1065 | triangleSize = 5
|
---|
[142] | 1066 |
|
---|
| 1067 | context = eventOrContext if pygobject else tankFigure.window.cairo_create()
|
---|
| 1068 | (xOffset, yOffset) = (0, 0) if pygobject \
|
---|
| 1069 | else (tankFigure.allocation.x, tankFigure.allocation.y)
|
---|
[141] | 1070 |
|
---|
[142] | 1071 | width = tankFigure.get_allocated_width() if pygobject \
|
---|
| 1072 | else tankFigure.allocation.width
|
---|
| 1073 | height = tankFigure.get_allocated_height() if pygobject \
|
---|
| 1074 | else tankFigure.allocation.height
|
---|
[141] | 1075 |
|
---|
| 1076 | rectangleX0 = triangleSize
|
---|
| 1077 | rectangleY0 = triangleSize
|
---|
| 1078 | rectangleX1 = width - 1 - triangleSize
|
---|
| 1079 | rectangleY1 = height - 1 - triangleSize
|
---|
| 1080 | rectangleLineWidth = 2.0
|
---|
| 1081 |
|
---|
| 1082 | context.set_source_rgb(0.0, 0.0, 0.0)
|
---|
| 1083 | context.set_line_width(rectangleLineWidth)
|
---|
[142] | 1084 | context.rectangle(xOffset + rectangleX0 + rectangleLineWidth/2,
|
---|
| 1085 | yOffset + rectangleY0 + rectangleLineWidth/2,
|
---|
[141] | 1086 | rectangleX1 - rectangleX0 - rectangleLineWidth,
|
---|
| 1087 | rectangleY1 - rectangleY0 - rectangleLineWidth)
|
---|
| 1088 | context.stroke()
|
---|
| 1089 |
|
---|
| 1090 | rectangleInnerLeft = rectangleX0 + rectangleLineWidth
|
---|
| 1091 | rectangleInnerRight = rectangleX1 - rectangleLineWidth
|
---|
[144] | 1092 | self._rectangleInnerTop = rectangleInnerTop = rectangleY0 + rectangleLineWidth
|
---|
| 1093 | self._rectangleInnerBottom = rectangleInnerBottom = rectangleY1 - rectangleLineWidth
|
---|
[141] | 1094 |
|
---|
| 1095 | rectangleInnerWidth = rectangleInnerRight - rectangleInnerLeft
|
---|
| 1096 | rectangleInnerHeight = rectangleInnerBottom - rectangleInnerTop
|
---|
| 1097 |
|
---|
| 1098 | context.set_source_rgb(1.0, 0.9, 0.6)
|
---|
| 1099 | currentHeight = self.currentWeight * rectangleInnerHeight / self.capacity
|
---|
| 1100 | currentX = rectangleInnerTop + rectangleInnerHeight - currentHeight
|
---|
[142] | 1101 | context.rectangle(xOffset + rectangleInnerLeft,
|
---|
| 1102 | yOffset + rectangleInnerTop +
|
---|
| 1103 | rectangleInnerHeight - currentHeight,
|
---|
[141] | 1104 | rectangleInnerWidth, currentHeight)
|
---|
| 1105 | context.fill()
|
---|
| 1106 |
|
---|
| 1107 | expectedHeight = self.expectedWeight * rectangleInnerHeight / self.capacity
|
---|
| 1108 | expectedY = rectangleInnerTop + rectangleInnerHeight - expectedHeight
|
---|
| 1109 |
|
---|
| 1110 | context.set_line_width(1.5)
|
---|
| 1111 | context.set_source_rgb(0.0, 0.85, 0.85)
|
---|
[142] | 1112 | context.move_to(xOffset + rectangleX0, yOffset + expectedY)
|
---|
| 1113 | context.line_to(xOffset + rectangleX1, yOffset + expectedY)
|
---|
[141] | 1114 | context.stroke()
|
---|
| 1115 |
|
---|
| 1116 | context.set_line_width(0.0)
|
---|
[142] | 1117 | context.move_to(xOffset + 0, yOffset + expectedY - triangleSize)
|
---|
| 1118 | context.line_to(xOffset + 0, yOffset + expectedY + triangleSize)
|
---|
| 1119 | context.line_to(xOffset + rectangleX0 + 1, yOffset + expectedY)
|
---|
| 1120 | context.line_to(xOffset + 0, yOffset + expectedY - triangleSize)
|
---|
[141] | 1121 | context.fill()
|
---|
| 1122 |
|
---|
| 1123 | context.set_line_width(0.0)
|
---|
[142] | 1124 | context.move_to(xOffset + width, yOffset + expectedY - triangleSize)
|
---|
| 1125 | context.line_to(xOffset + width, yOffset + expectedY + triangleSize)
|
---|
| 1126 | context.line_to(xOffset + rectangleX1 - 1, yOffset + expectedY)
|
---|
| 1127 | context.line_to(xOffset + width, yOffset + expectedY - triangleSize)
|
---|
[141] | 1128 | context.fill()
|
---|
| 1129 |
|
---|
[142] | 1130 | return True
|
---|
| 1131 |
|
---|
[144] | 1132 | def _setExpectedFromY(self, y):
|
---|
| 1133 | """Set the expected weight from the given Y-coordinate."""
|
---|
| 1134 | level = (self._rectangleInnerBottom - y) / \
|
---|
| 1135 | (self._rectangleInnerBottom - self._rectangleInnerTop)
|
---|
| 1136 | level = min(1.0, max(0.0, level))
|
---|
| 1137 | self._expectedButton.set_value(level * self.capacity)
|
---|
| 1138 |
|
---|
| 1139 | def _buttonPressed(self, tankFigure, event):
|
---|
| 1140 | """Called when a button is pressed in the figure.
|
---|
| 1141 |
|
---|
| 1142 | The expected level will be set there."""
|
---|
[146] | 1143 | if self._enabled and event.button==1:
|
---|
[144] | 1144 | self._setExpectedFromY(event.y)
|
---|
| 1145 |
|
---|
| 1146 | def _motionNotify(self, tankFigure, event):
|
---|
| 1147 | """Called when the mouse pointer moves within the area of a tank figure."""
|
---|
[146] | 1148 | if self._enabled and event.state==BUTTON1_MASK:
|
---|
[144] | 1149 | self._setExpectedFromY(event.y)
|
---|
| 1150 |
|
---|
| 1151 | def _scrolled(self, tankFigure, event):
|
---|
| 1152 | """Called when a scroll event is received."""
|
---|
[146] | 1153 | if self._enabled:
|
---|
| 1154 | increment = 1 if event.state==CONTROL_MASK \
|
---|
| 1155 | else 100 if event.state==SHIFT_MASK \
|
---|
| 1156 | else 10 if event.state==0 else 0
|
---|
| 1157 | if increment!=0:
|
---|
| 1158 | if event.direction==SCROLL_DOWN:
|
---|
| 1159 | increment *= -1
|
---|
| 1160 | self._expectedButton.spin(SPIN_USER_DEFINED, increment)
|
---|
[144] | 1161 |
|
---|
[141] | 1162 | def _expectedChanged(self, spinButton):
|
---|
| 1163 | """Called when the expected value has changed."""
|
---|
| 1164 | self.expectedWeight = spinButton.get_value_as_int()
|
---|
| 1165 | self._redraw()
|
---|
| 1166 |
|
---|
| 1167 | #-----------------------------------------------------------------------------
|
---|
| 1168 |
|
---|
| 1169 | class FuelPage(Page):
|
---|
| 1170 | """The page containing the fuel tank filling."""
|
---|
| 1171 | _pumpStep = 0.02
|
---|
| 1172 |
|
---|
| 1173 | def __init__(self, wizard):
|
---|
| 1174 | """Construct the page."""
|
---|
| 1175 | super(FuelPage, self).__init__(wizard, xstr("fuel_title"),
|
---|
| 1176 | xstr("fuel_help"),
|
---|
| 1177 | completedHelp = xstr("fuel_chelp"))
|
---|
| 1178 |
|
---|
| 1179 | self._fuelTanks = []
|
---|
| 1180 | self._fuelTable = None
|
---|
| 1181 | self._fuelAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1182 | xscale = 0.0, yscale = 1.0)
|
---|
| 1183 | self.setMainWidget(self._fuelAlignment)
|
---|
| 1184 |
|
---|
| 1185 | tanks = acft.MostFuelTankAircraft.fuelTanks
|
---|
| 1186 | tankData = ((2500, 3900),) * len(tanks)
|
---|
| 1187 | self._setupTanks(tanks, tankData)
|
---|
| 1188 |
|
---|
| 1189 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1190 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
| 1191 |
|
---|
| 1192 | self._pumpIndex = 0
|
---|
| 1193 |
|
---|
[145] | 1194 | def activate(self):
|
---|
| 1195 | """Activate the page."""
|
---|
| 1196 | gui = self._wizard.gui
|
---|
| 1197 |
|
---|
| 1198 | self._setupTanks(gui.flight.aircraft.fuelTanks,
|
---|
| 1199 | self._wizard._fuelData)
|
---|
[141] | 1200 |
|
---|
| 1201 | def finalize(self):
|
---|
| 1202 | """Finalize the page."""
|
---|
| 1203 | for fuelTank in self._fuelTanks:
|
---|
| 1204 | fuelTank.disable()
|
---|
| 1205 |
|
---|
| 1206 | def _backClicked(self, button):
|
---|
| 1207 | """Called when the Back button is pressed."""
|
---|
| 1208 | self.goBack()
|
---|
| 1209 |
|
---|
| 1210 | def _forwardClicked(self, button):
|
---|
| 1211 | """Called when the forward button is clicked."""
|
---|
| 1212 | if not self._completed:
|
---|
| 1213 | self._pumpIndex = 0
|
---|
| 1214 | self._wizard.gui.beginBusy(xstr("fuel_pump_busy"))
|
---|
| 1215 | self._pump()
|
---|
| 1216 | else:
|
---|
| 1217 | self._wizard.nextPage()
|
---|
| 1218 |
|
---|
| 1219 | def _setupTanks(self, tanks, tankData):
|
---|
| 1220 | """Setup the tanks for the given data."""
|
---|
| 1221 | numTanks = len(tanks)
|
---|
| 1222 | if self._fuelTable is not None:
|
---|
| 1223 | self._fuelAlignment.remove(self._fuelTable)
|
---|
| 1224 |
|
---|
| 1225 | self._fuelTanks = []
|
---|
| 1226 | self._fuelTable = gtk.Table(numTanks, 1)
|
---|
| 1227 | self._fuelTable.set_col_spacings(16)
|
---|
| 1228 | for i in range(0, numTanks):
|
---|
| 1229 | tank = tanks[i]
|
---|
| 1230 | (current, capacity) = tankData[i]
|
---|
| 1231 |
|
---|
| 1232 | fuelTank = FuelTank(tank,
|
---|
| 1233 | xstr("fuel_tank_" +
|
---|
| 1234 | const.fuelTank2string(tank)),
|
---|
| 1235 | capacity, current)
|
---|
| 1236 | self._fuelTable.attach(fuelTank, i, i+1, 0, 1)
|
---|
| 1237 | self._fuelTanks.append(fuelTank)
|
---|
| 1238 |
|
---|
| 1239 | self._fuelAlignment.add(self._fuelTable)
|
---|
| 1240 | self.show_all()
|
---|
| 1241 |
|
---|
| 1242 | def _pump(self):
|
---|
| 1243 | """Perform one step of pumping.
|
---|
| 1244 |
|
---|
| 1245 | It is checked, if the current tank's contents are of the right
|
---|
| 1246 | quantity. If not, it is filled one step further to the desired
|
---|
| 1247 | contents. Otherwise the next tank is started. If all tanks are are
|
---|
| 1248 | filled, the next page is selected."""
|
---|
| 1249 | numTanks = len(self._fuelTanks)
|
---|
| 1250 |
|
---|
| 1251 | fuelTank = None
|
---|
| 1252 | while self._pumpIndex < numTanks:
|
---|
| 1253 | fuelTank = self._fuelTanks[self._pumpIndex]
|
---|
| 1254 | if fuelTank.isCorrect():
|
---|
| 1255 | self._pumpIndex += 1
|
---|
| 1256 | fuelTank = None
|
---|
| 1257 | else:
|
---|
| 1258 | break
|
---|
| 1259 |
|
---|
| 1260 | if fuelTank is None:
|
---|
| 1261 | self._wizard.gui.endBusy()
|
---|
| 1262 | self._wizard.nextPage()
|
---|
| 1263 | else:
|
---|
| 1264 | currentLevel = fuelTank.currentWeight / fuelTank.capacity
|
---|
| 1265 | expectedLevel = fuelTank.expectedWeight / fuelTank.capacity
|
---|
| 1266 | if currentLevel<expectedLevel:
|
---|
| 1267 | currentLevel += FuelPage._pumpStep
|
---|
| 1268 | if currentLevel>expectedLevel: currentLevel = expectedLevel
|
---|
| 1269 | else:
|
---|
| 1270 | currentLevel -= FuelPage._pumpStep
|
---|
| 1271 | if currentLevel<expectedLevel: currentLevel = expectedLevel
|
---|
| 1272 | fuelTank.setCurrent(currentLevel * fuelTank.capacity)
|
---|
| 1273 | self._wizard.gui.simulator.setFuelLevel([(fuelTank.fuelTank,
|
---|
| 1274 | currentLevel)])
|
---|
| 1275 | gobject.timeout_add(50, self._pump)
|
---|
| 1276 |
|
---|
| 1277 | #-----------------------------------------------------------------------------
|
---|
| 1278 |
|
---|
[62] | 1279 | class RoutePage(Page):
|
---|
| 1280 | """The page containing the route and the flight level."""
|
---|
| 1281 | def __init__(self, wizard):
|
---|
[141] | 1282 | """Construct the page."""
|
---|
[107] | 1283 | super(RoutePage, self).__init__(wizard, xstr("route_title"),
|
---|
| 1284 | xstr("route_help"),
|
---|
| 1285 | completedHelp = xstr("route_chelp"))
|
---|
[62] | 1286 |
|
---|
| 1287 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1288 | xscale = 0.0, yscale = 0.0)
|
---|
| 1289 |
|
---|
| 1290 | mainBox = gtk.VBox()
|
---|
| 1291 | alignment.add(mainBox)
|
---|
| 1292 | self.setMainWidget(alignment)
|
---|
| 1293 |
|
---|
| 1294 | levelBox = gtk.HBox()
|
---|
| 1295 |
|
---|
[107] | 1296 | label = gtk.Label(xstr("route_level"))
|
---|
[62] | 1297 | label.set_use_underline(True)
|
---|
| 1298 | levelBox.pack_start(label, True, True, 0)
|
---|
| 1299 |
|
---|
| 1300 | self._cruiseLevel = gtk.SpinButton()
|
---|
| 1301 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
| 1302 | self._cruiseLevel.set_range(min = 50, max = 500)
|
---|
[107] | 1303 | self._cruiseLevel.set_tooltip_text(xstr("route_level_tooltip"))
|
---|
[62] | 1304 | self._cruiseLevel.set_numeric(True)
|
---|
| 1305 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
[97] | 1306 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
| 1307 | self._filedCruiseLevel = 240
|
---|
[62] | 1308 |
|
---|
| 1309 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
| 1310 |
|
---|
| 1311 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 1312 | xscale = 0.0, yscale = 0.0)
|
---|
| 1313 | alignment.add(levelBox)
|
---|
| 1314 |
|
---|
| 1315 | mainBox.pack_start(alignment, False, False, 0)
|
---|
| 1316 |
|
---|
| 1317 |
|
---|
| 1318 | routeBox = gtk.VBox()
|
---|
| 1319 |
|
---|
| 1320 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
| 1321 | xscale = 0.0, yscale = 0.0)
|
---|
[107] | 1322 | label = gtk.Label(xstr("route_route"))
|
---|
[62] | 1323 | label.set_use_underline(True)
|
---|
| 1324 | alignment.add(label)
|
---|
| 1325 | routeBox.pack_start(alignment, True, True, 0)
|
---|
| 1326 |
|
---|
| 1327 | routeWindow = gtk.ScrolledWindow()
|
---|
| 1328 | routeWindow.set_size_request(400, 80)
|
---|
| 1329 | routeWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
| 1330 | else gtk.SHADOW_IN)
|
---|
[69] | 1331 | routeWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1332 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1333 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1334 | else gtk.POLICY_AUTOMATIC)
|
---|
[62] | 1335 |
|
---|
[138] | 1336 | self._uppercasingRoute = False
|
---|
| 1337 |
|
---|
[62] | 1338 | self._route = gtk.TextView()
|
---|
[107] | 1339 | self._route.set_tooltip_text(xstr("route_route_tooltip"))
|
---|
[138] | 1340 | self._route.set_wrap_mode(WRAP_WORD)
|
---|
[62] | 1341 | self._route.get_buffer().connect("changed", self._routeChanged)
|
---|
[138] | 1342 | self._route.get_buffer().connect_after("insert-text", self._routeInserted)
|
---|
[62] | 1343 | routeWindow.add(self._route)
|
---|
| 1344 |
|
---|
| 1345 | label.set_mnemonic_widget(self._route)
|
---|
| 1346 | routeBox.pack_start(routeWindow, True, True, 0)
|
---|
| 1347 |
|
---|
| 1348 | mainBox.pack_start(routeBox, True, True, 8)
|
---|
| 1349 |
|
---|
[107] | 1350 | self._backButton = self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1351 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[62] | 1352 |
|
---|
[84] | 1353 | @property
|
---|
[97] | 1354 | def filedCruiseLevel(self):
|
---|
| 1355 | """Get the filed cruise level."""
|
---|
| 1356 | return self._filedCruiseLevel
|
---|
| 1357 |
|
---|
| 1358 | @property
|
---|
[84] | 1359 | def cruiseLevel(self):
|
---|
| 1360 | """Get the cruise level."""
|
---|
| 1361 | return self._cruiseLevel.get_value_as_int()
|
---|
| 1362 |
|
---|
[97] | 1363 | @property
|
---|
| 1364 | def route(self):
|
---|
| 1365 | """Get the route."""
|
---|
| 1366 | return self._getRoute()
|
---|
| 1367 |
|
---|
[62] | 1368 | def activate(self):
|
---|
| 1369 | """Setup the route from the booked flight."""
|
---|
[92] | 1370 | self._cruiseLevel.set_value(240)
|
---|
[97] | 1371 | self._filedCruiseLevel = 240
|
---|
[62] | 1372 | self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
|
---|
| 1373 | self._updateForwardButton()
|
---|
| 1374 |
|
---|
| 1375 | def _getRoute(self):
|
---|
| 1376 | """Get the text of the route."""
|
---|
| 1377 | buffer = self._route.get_buffer()
|
---|
| 1378 | return buffer.get_text(buffer.get_start_iter(),
|
---|
| 1379 | buffer.get_end_iter(), True)
|
---|
| 1380 |
|
---|
| 1381 | def _updateForwardButton(self):
|
---|
| 1382 | """Update the sensitivity of the forward button."""
|
---|
| 1383 | self._button.set_sensitive(self._cruiseLevel.get_value_as_int()>=50 and \
|
---|
[68] | 1384 | self._getRoute()!="")
|
---|
[62] | 1385 |
|
---|
| 1386 | def _cruiseLevelChanged(self, spinButton):
|
---|
| 1387 | """Called when the cruise level has changed."""
|
---|
| 1388 | self._updateForwardButton()
|
---|
| 1389 |
|
---|
| 1390 | def _routeChanged(self, textBuffer):
|
---|
| 1391 | """Called when the route has changed."""
|
---|
[138] | 1392 | if not self._uppercasingRoute:
|
---|
| 1393 | self._updateForwardButton()
|
---|
| 1394 |
|
---|
| 1395 | def _routeInserted(self, textBuffer, iter, text, length):
|
---|
| 1396 | """Called when new characters are inserted into the route.
|
---|
| 1397 |
|
---|
| 1398 | It uppercases all characters."""
|
---|
| 1399 | if not self._uppercasingRoute:
|
---|
| 1400 | self._uppercasingRoute = True
|
---|
| 1401 |
|
---|
| 1402 | iter1 = iter.copy()
|
---|
| 1403 | iter1.backward_chars(length)
|
---|
| 1404 | textBuffer.delete(iter, iter1)
|
---|
| 1405 |
|
---|
| 1406 | textBuffer.insert(iter, text.upper())
|
---|
| 1407 |
|
---|
| 1408 | self._uppercasingRoute = False
|
---|
[62] | 1409 |
|
---|
[70] | 1410 | def _backClicked(self, button):
|
---|
| 1411 | """Called when the Back button is pressed."""
|
---|
| 1412 | self.goBack()
|
---|
| 1413 |
|
---|
[62] | 1414 | def _forwardClicked(self, button):
|
---|
| 1415 | """Called when the Forward button is clicked."""
|
---|
[94] | 1416 | if self._completed:
|
---|
[70] | 1417 | self._wizard.nextPage()
|
---|
| 1418 | else:
|
---|
| 1419 | bookedFlight = self._wizard._bookedFlight
|
---|
[97] | 1420 | self._filedCruiseLevel = self.cruiseLevel
|
---|
[107] | 1421 | self._wizard.gui.beginBusy(xstr("route_down_notams"))
|
---|
[70] | 1422 | self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback,
|
---|
| 1423 | bookedFlight.departureICAO,
|
---|
| 1424 | bookedFlight.arrivalICAO)
|
---|
[64] | 1425 |
|
---|
| 1426 | def _notamsCallback(self, returned, result):
|
---|
| 1427 | """Callback for the NOTAMs."""
|
---|
| 1428 | gobject.idle_add(self._handleNOTAMs, returned, result)
|
---|
| 1429 |
|
---|
| 1430 | def _handleNOTAMs(self, returned, result):
|
---|
| 1431 | """Handle the NOTAMs."""
|
---|
| 1432 | if returned:
|
---|
| 1433 | self._wizard._departureNOTAMs = result.departureNOTAMs
|
---|
| 1434 | self._wizard._arrivalNOTAMs = result.arrivalNOTAMs
|
---|
[67] | 1435 | else:
|
---|
| 1436 | self._wizard._departureNOTAMs = None
|
---|
| 1437 | self._wizard._arrivalNOTAMs = None
|
---|
[64] | 1438 |
|
---|
[67] | 1439 | bookedFlight = self._wizard._bookedFlight
|
---|
[107] | 1440 | self._wizard.gui.beginBusy(xstr("route_down_metars"))
|
---|
[67] | 1441 | self._wizard.gui.webHandler.getMETARs(self._metarsCallback,
|
---|
| 1442 | [bookedFlight.departureICAO,
|
---|
| 1443 | bookedFlight.arrivalICAO])
|
---|
| 1444 |
|
---|
| 1445 | def _metarsCallback(self, returned, result):
|
---|
| 1446 | """Callback for the METARs."""
|
---|
| 1447 | gobject.idle_add(self._handleMETARs, returned, result)
|
---|
| 1448 |
|
---|
| 1449 | def _handleMETARs(self, returned, result):
|
---|
| 1450 | """Handle the METARs."""
|
---|
| 1451 | self._wizard._departureMETAR = None
|
---|
| 1452 | self._wizard._arrivalMETAR = None
|
---|
| 1453 | bookedFlight = self._wizard._bookedFlight
|
---|
| 1454 | if returned:
|
---|
| 1455 | if bookedFlight.departureICAO in result.metars:
|
---|
| 1456 | self._wizard._departureMETAR = result.metars[bookedFlight.departureICAO]
|
---|
| 1457 | if bookedFlight.arrivalICAO in result.metars:
|
---|
| 1458 | self._wizard._arrivalMETAR = result.metars[bookedFlight.arrivalICAO]
|
---|
| 1459 |
|
---|
| 1460 | self._wizard.gui.endBusy()
|
---|
[70] | 1461 | self._backButton.set_sensitive(True)
|
---|
| 1462 | self._button.set_sensitive(True)
|
---|
[62] | 1463 | self._wizard.nextPage()
|
---|
| 1464 |
|
---|
| 1465 | #-----------------------------------------------------------------------------
|
---|
| 1466 |
|
---|
[67] | 1467 | class BriefingPage(Page):
|
---|
| 1468 | """Page for the briefing."""
|
---|
| 1469 | def __init__(self, wizard, departure):
|
---|
| 1470 | """Construct the briefing page."""
|
---|
| 1471 | self._departure = departure
|
---|
| 1472 |
|
---|
[107] | 1473 | title = xstr("briefing_title") % (1 if departure else 2,
|
---|
| 1474 | xstr("briefing_departure")
|
---|
| 1475 | if departure
|
---|
| 1476 | else xstr("briefing_arrival"))
|
---|
| 1477 | super(BriefingPage, self).__init__(wizard, title, xstr("briefing_help"),
|
---|
| 1478 | completedHelp = xstr("briefing_chelp"))
|
---|
[64] | 1479 |
|
---|
| 1480 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1481 | xscale = 1.0, yscale = 1.0)
|
---|
| 1482 |
|
---|
| 1483 | mainBox = gtk.VBox()
|
---|
| 1484 | alignment.add(mainBox)
|
---|
| 1485 | self.setMainWidget(alignment)
|
---|
| 1486 |
|
---|
[67] | 1487 | self._notamsFrame = gtk.Frame()
|
---|
[107] | 1488 | self._notamsFrame.set_label(xstr("briefing_notams_init"))
|
---|
[64] | 1489 | scrolledWindow = gtk.ScrolledWindow()
|
---|
[67] | 1490 | scrolledWindow.set_size_request(-1, 128)
|
---|
[94] | 1491 | # FIXME: these constants should be in common
|
---|
[69] | 1492 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1493 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1494 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1495 | else gtk.POLICY_AUTOMATIC)
|
---|
[67] | 1496 | self._notams = gtk.TextView()
|
---|
| 1497 | self._notams.set_editable(False)
|
---|
| 1498 | self._notams.set_accepts_tab(False)
|
---|
| 1499 | self._notams.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
| 1500 | scrolledWindow.add(self._notams)
|
---|
| 1501 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1502 | xscale = 1.0, yscale = 1.0)
|
---|
| 1503 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 1504 | padding_left = 0, padding_right = 0)
|
---|
| 1505 | alignment.add(scrolledWindow)
|
---|
| 1506 | self._notamsFrame.add(alignment)
|
---|
| 1507 | mainBox.pack_start(self._notamsFrame, True, True, 4)
|
---|
| 1508 |
|
---|
| 1509 | self._metarFrame = gtk.Frame()
|
---|
[107] | 1510 | self._metarFrame.set_label(xstr("briefing_metar_init"))
|
---|
[67] | 1511 | scrolledWindow = gtk.ScrolledWindow()
|
---|
| 1512 | scrolledWindow.set_size_request(-1, 32)
|
---|
[69] | 1513 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1514 | else gtk.POLICY_AUTOMATIC,
|
---|
| 1515 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
| 1516 | else gtk.POLICY_AUTOMATIC)
|
---|
[138] | 1517 |
|
---|
| 1518 | self._uppercasingMETAR = False
|
---|
| 1519 |
|
---|
[67] | 1520 | self._metar = gtk.TextView()
|
---|
| 1521 | self._metar.set_accepts_tab(False)
|
---|
| 1522 | self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
[106] | 1523 | self._metar.get_buffer().connect("changed", self._metarChanged)
|
---|
[138] | 1524 | self._metar.get_buffer().connect_after("insert-text", self._metarInserted)
|
---|
[67] | 1525 | scrolledWindow.add(self._metar)
|
---|
| 1526 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
| 1527 | xscale = 1.0, yscale = 1.0)
|
---|
| 1528 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
| 1529 | padding_left = 0, padding_right = 0)
|
---|
| 1530 | alignment.add(scrolledWindow)
|
---|
| 1531 | self._metarFrame.add(alignment)
|
---|
| 1532 | mainBox.pack_start(self._metarFrame, True, True, 4)
|
---|
[106] | 1533 | self.metarEdited = False
|
---|
[64] | 1534 |
|
---|
[107] | 1535 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1536 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[64] | 1537 |
|
---|
[97] | 1538 | @property
|
---|
| 1539 | def metar(self):
|
---|
| 1540 | """Get the METAR on the page."""
|
---|
| 1541 | buffer = self._metar.get_buffer()
|
---|
| 1542 | return buffer.get_text(buffer.get_start_iter(),
|
---|
| 1543 | buffer.get_end_iter(), True)
|
---|
| 1544 |
|
---|
[106] | 1545 | def setMETAR(self, metar):
|
---|
| 1546 | """Set the metar."""
|
---|
| 1547 | self._metar.get_buffer().set_text(metar)
|
---|
| 1548 | self.metarEdited = False
|
---|
| 1549 |
|
---|
[64] | 1550 | def activate(self):
|
---|
| 1551 | """Activate the page."""
|
---|
[70] | 1552 | if not self._departure:
|
---|
[107] | 1553 | self._button.set_label(xstr("briefing_button"))
|
---|
| 1554 | self._button.set_has_tooltip(False)
|
---|
[70] | 1555 | self._button.set_use_stock(False)
|
---|
| 1556 |
|
---|
| 1557 | bookedFlight = self._wizard._bookedFlight
|
---|
[67] | 1558 |
|
---|
[70] | 1559 | icao = bookedFlight.departureICAO if self._departure \
|
---|
| 1560 | else bookedFlight.arrivalICAO
|
---|
| 1561 | notams = self._wizard._departureNOTAMs if self._departure \
|
---|
| 1562 | else self._wizard._arrivalNOTAMs
|
---|
| 1563 | metar = self._wizard._departureMETAR if self._departure \
|
---|
| 1564 | else self._wizard._arrivalMETAR
|
---|
[64] | 1565 |
|
---|
[107] | 1566 | self._notamsFrame.set_label(xstr("briefing_notams_template") % (icao,))
|
---|
[70] | 1567 | buffer = self._notams.get_buffer()
|
---|
| 1568 | if notams is None:
|
---|
[107] | 1569 | buffer.set_text(xstr("briefing_notams_failed"))
|
---|
[92] | 1570 | elif not notams:
|
---|
[107] | 1571 | buffer.set_text(xstr("briefing_notams_missing"))
|
---|
[70] | 1572 | else:
|
---|
| 1573 | s = ""
|
---|
| 1574 | for notam in notams:
|
---|
| 1575 | s += str(notam.begin)
|
---|
| 1576 | if notam.end is not None:
|
---|
| 1577 | s += " - " + str(notam.end)
|
---|
| 1578 | elif notam.permanent:
|
---|
| 1579 | s += " - PERMANENT"
|
---|
| 1580 | s += "\n"
|
---|
| 1581 | if notam.repeatCycle:
|
---|
| 1582 | s += "Repeat cycle: " + notam.repeatCycle + "\n"
|
---|
| 1583 | s += notam.notice + "\n"
|
---|
| 1584 | s += "-------------------- * --------------------\n"
|
---|
| 1585 | buffer.set_text(s)
|
---|
[67] | 1586 |
|
---|
[107] | 1587 | self._metarFrame.set_label(xstr("briefing_metar_template") % (icao,))
|
---|
[70] | 1588 | buffer = self._metar.get_buffer()
|
---|
| 1589 | if metar is None:
|
---|
[107] | 1590 | buffer.set_text(xstr("briefing_metar_failed"))
|
---|
[70] | 1591 | else:
|
---|
| 1592 | buffer.set_text(metar)
|
---|
[67] | 1593 |
|
---|
[107] | 1594 | label = self._metarFrame.get_label_widget()
|
---|
| 1595 | label.set_use_underline(True)
|
---|
| 1596 | label.set_mnemonic_widget(self._metar)
|
---|
| 1597 |
|
---|
[106] | 1598 | self.metarEdited = False
|
---|
| 1599 |
|
---|
[70] | 1600 | def _backClicked(self, button):
|
---|
| 1601 | """Called when the Back button is pressed."""
|
---|
| 1602 | self.goBack()
|
---|
| 1603 |
|
---|
[67] | 1604 | def _forwardClicked(self, button):
|
---|
[64] | 1605 | """Called when the forward button is clicked."""
|
---|
[70] | 1606 | if not self._departure:
|
---|
[94] | 1607 | if not self._completed:
|
---|
[70] | 1608 | self._wizard.gui.startMonitoring()
|
---|
[107] | 1609 | self._button.set_label(xstr("button_next"))
|
---|
| 1610 | self._button.set_tooltip_text(xstr("button_next_tooltip"))
|
---|
[94] | 1611 | self.complete()
|
---|
[71] | 1612 |
|
---|
| 1613 | self._wizard.nextPage()
|
---|
| 1614 |
|
---|
[106] | 1615 | def _metarChanged(self, buffer):
|
---|
| 1616 | """Called when the METAR has changed."""
|
---|
[138] | 1617 | if not self._uppercasingMETAR:
|
---|
| 1618 | self.metarEdited = True
|
---|
| 1619 | self._button.set_sensitive(buffer.get_text(buffer.get_start_iter(),
|
---|
| 1620 | buffer.get_end_iter(),
|
---|
| 1621 | True)!="")
|
---|
| 1622 |
|
---|
| 1623 | def _metarInserted(self, textBuffer, iter, text, length):
|
---|
| 1624 | """Called when new characters are inserted into the METAR.
|
---|
| 1625 |
|
---|
| 1626 | It uppercases all characters."""
|
---|
| 1627 | if not self._uppercasingMETAR:
|
---|
| 1628 | self._uppercasingMETAR = True
|
---|
| 1629 |
|
---|
| 1630 | iter1 = iter.copy()
|
---|
| 1631 | iter1.backward_chars(length)
|
---|
| 1632 | textBuffer.delete(iter, iter1)
|
---|
| 1633 |
|
---|
| 1634 | textBuffer.insert(iter, text.upper())
|
---|
| 1635 |
|
---|
| 1636 | self._uppercasingMETAR = False
|
---|
[106] | 1637 |
|
---|
[71] | 1638 | #-----------------------------------------------------------------------------
|
---|
| 1639 |
|
---|
| 1640 | class TakeoffPage(Page):
|
---|
| 1641 | """Page for entering the takeoff data."""
|
---|
| 1642 | def __init__(self, wizard):
|
---|
| 1643 | """Construct the takeoff page."""
|
---|
[107] | 1644 | super(TakeoffPage, self).__init__(wizard, xstr("takeoff_title"),
|
---|
| 1645 | xstr("takeoff_help"),
|
---|
| 1646 | completedHelp = xstr("takeoff_chelp"))
|
---|
[71] | 1647 |
|
---|
[101] | 1648 | self._forwardAllowed = False
|
---|
| 1649 |
|
---|
[71] | 1650 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1651 | xscale = 0.0, yscale = 0.0)
|
---|
| 1652 |
|
---|
[84] | 1653 | table = gtk.Table(5, 4)
|
---|
[71] | 1654 | table.set_row_spacings(4)
|
---|
| 1655 | table.set_col_spacings(16)
|
---|
| 1656 | table.set_homogeneous(False)
|
---|
| 1657 | alignment.add(table)
|
---|
| 1658 | self.setMainWidget(alignment)
|
---|
| 1659 |
|
---|
[107] | 1660 | label = gtk.Label(xstr("takeoff_runway"))
|
---|
[71] | 1661 | label.set_use_underline(True)
|
---|
| 1662 | label.set_alignment(0.0, 0.5)
|
---|
| 1663 | table.attach(label, 0, 1, 0, 1)
|
---|
| 1664 |
|
---|
| 1665 | self._runway = gtk.Entry()
|
---|
| 1666 | self._runway.set_width_chars(10)
|
---|
[107] | 1667 | self._runway.set_tooltip_text(xstr("takeoff_runway_tooltip"))
|
---|
[138] | 1668 | self._runway.connect("changed", self._upperChanged)
|
---|
[84] | 1669 | table.attach(self._runway, 1, 3, 0, 1)
|
---|
[71] | 1670 | label.set_mnemonic_widget(self._runway)
|
---|
| 1671 |
|
---|
[107] | 1672 | label = gtk.Label(xstr("takeoff_sid"))
|
---|
[71] | 1673 | label.set_use_underline(True)
|
---|
| 1674 | label.set_alignment(0.0, 0.5)
|
---|
| 1675 | table.attach(label, 0, 1, 1, 2)
|
---|
| 1676 |
|
---|
| 1677 | self._sid = gtk.Entry()
|
---|
| 1678 | self._sid.set_width_chars(10)
|
---|
[107] | 1679 | self._sid.set_tooltip_text(xstr("takeoff_sid_tooltip"))
|
---|
[138] | 1680 | self._sid.connect("changed", self._upperChanged)
|
---|
[84] | 1681 | table.attach(self._sid, 1, 3, 1, 2)
|
---|
[71] | 1682 | label.set_mnemonic_widget(self._sid)
|
---|
| 1683 |
|
---|
[107] | 1684 | label = gtk.Label(xstr("takeoff_v1"))
|
---|
[71] | 1685 | label.set_use_markup(True)
|
---|
| 1686 | label.set_use_underline(True)
|
---|
| 1687 | label.set_alignment(0.0, 0.5)
|
---|
| 1688 | table.attach(label, 0, 1, 2, 3)
|
---|
| 1689 |
|
---|
[84] | 1690 | self._v1 = IntegerEntry()
|
---|
[86] | 1691 | self._v1.set_width_chars(4)
|
---|
[107] | 1692 | self._v1.set_tooltip_markup(xstr("takeoff_v1_tooltip"))
|
---|
[101] | 1693 | self._v1.connect("integer-changed", self._valueChanged)
|
---|
[84] | 1694 | table.attach(self._v1, 2, 3, 2, 3)
|
---|
[71] | 1695 | label.set_mnemonic_widget(self._v1)
|
---|
| 1696 |
|
---|
[107] | 1697 | table.attach(gtk.Label(xstr("label_knots")), 3, 4, 2, 3)
|
---|
[71] | 1698 |
|
---|
[107] | 1699 | label = gtk.Label(xstr("takeoff_vr"))
|
---|
[71] | 1700 | label.set_use_markup(True)
|
---|
| 1701 | label.set_use_underline(True)
|
---|
| 1702 | label.set_alignment(0.0, 0.5)
|
---|
| 1703 | table.attach(label, 0, 1, 3, 4)
|
---|
| 1704 |
|
---|
[84] | 1705 | self._vr = IntegerEntry()
|
---|
[86] | 1706 | self._vr.set_width_chars(4)
|
---|
[107] | 1707 | self._vr.set_tooltip_markup(xstr("takeoff_vr_tooltip"))
|
---|
[101] | 1708 | self._vr.connect("integer-changed", self._valueChanged)
|
---|
[84] | 1709 | table.attach(self._vr, 2, 3, 3, 4)
|
---|
[71] | 1710 | label.set_mnemonic_widget(self._vr)
|
---|
| 1711 |
|
---|
[107] | 1712 | table.attach(gtk.Label(xstr("label_knots")), 3, 4, 3, 4)
|
---|
[71] | 1713 |
|
---|
[107] | 1714 | label = gtk.Label(xstr("takeoff_v2"))
|
---|
[71] | 1715 | label.set_use_markup(True)
|
---|
| 1716 | label.set_use_underline(True)
|
---|
| 1717 | label.set_alignment(0.0, 0.5)
|
---|
| 1718 | table.attach(label, 0, 1, 4, 5)
|
---|
| 1719 |
|
---|
[84] | 1720 | self._v2 = IntegerEntry()
|
---|
[86] | 1721 | self._v2.set_width_chars(4)
|
---|
[107] | 1722 | self._v2.set_tooltip_markup(xstr("takeoff_v2_tooltip"))
|
---|
[101] | 1723 | self._v2.connect("integer-changed", self._valueChanged)
|
---|
[84] | 1724 | table.attach(self._v2, 2, 3, 4, 5)
|
---|
[71] | 1725 | label.set_mnemonic_widget(self._v2)
|
---|
| 1726 |
|
---|
[107] | 1727 | table.attach(gtk.Label(xstr("label_knots")), 3, 4, 4, 5)
|
---|
[71] | 1728 |
|
---|
[107] | 1729 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1730 |
|
---|
| 1731 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[71] | 1732 |
|
---|
[84] | 1733 | @property
|
---|
[97] | 1734 | def runway(self):
|
---|
| 1735 | """Get the runway."""
|
---|
| 1736 | return self._runway.get_text()
|
---|
| 1737 |
|
---|
| 1738 | @property
|
---|
| 1739 | def sid(self):
|
---|
| 1740 | """Get the SID."""
|
---|
| 1741 | return self._sid.get_text()
|
---|
| 1742 |
|
---|
| 1743 | @property
|
---|
[84] | 1744 | def v1(self):
|
---|
| 1745 | """Get the v1 speed."""
|
---|
| 1746 | return self._v1.get_int()
|
---|
| 1747 |
|
---|
| 1748 | @property
|
---|
| 1749 | def vr(self):
|
---|
| 1750 | """Get the vr speed."""
|
---|
| 1751 | return self._vr.get_int()
|
---|
| 1752 |
|
---|
| 1753 | @property
|
---|
| 1754 | def v2(self):
|
---|
| 1755 | """Get the v2 speed."""
|
---|
| 1756 | return self._v2.get_int()
|
---|
| 1757 |
|
---|
[71] | 1758 | def activate(self):
|
---|
| 1759 | """Activate the page."""
|
---|
[72] | 1760 | self._runway.set_text("")
|
---|
[71] | 1761 | self._runway.set_sensitive(True)
|
---|
[72] | 1762 | self._sid.set_text("")
|
---|
[71] | 1763 | self._sid.set_sensitive(True)
|
---|
[84] | 1764 | self._v1.set_int(None)
|
---|
[71] | 1765 | self._v1.set_sensitive(True)
|
---|
[86] | 1766 | self._vr.set_int(None)
|
---|
[71] | 1767 | self._vr.set_sensitive(True)
|
---|
[86] | 1768 | self._v2.set_int(None)
|
---|
[71] | 1769 | self._v2.set_sensitive(True)
|
---|
[84] | 1770 | self._button.set_sensitive(False)
|
---|
[71] | 1771 |
|
---|
[101] | 1772 | def finalize(self):
|
---|
| 1773 | """Finalize the page."""
|
---|
[71] | 1774 | self._runway.set_sensitive(False)
|
---|
| 1775 | self._sid.set_sensitive(False)
|
---|
| 1776 | self._v1.set_sensitive(False)
|
---|
| 1777 | self._vr.set_sensitive(False)
|
---|
| 1778 | self._v2.set_sensitive(False)
|
---|
[101] | 1779 | self._wizard.gui.flight.aircraft.updateV1R2()
|
---|
| 1780 |
|
---|
| 1781 | def allowForward(self):
|
---|
| 1782 | """Allow going to the next page."""
|
---|
| 1783 | self._forwardAllowed = True
|
---|
| 1784 | self._updateForwardButton()
|
---|
| 1785 |
|
---|
| 1786 | def _updateForwardButton(self):
|
---|
| 1787 | """Update the sensitivity of the forward button based on some conditions."""
|
---|
| 1788 | sensitive = self._forwardAllowed and \
|
---|
| 1789 | self._runway.get_text()!="" and \
|
---|
| 1790 | self._sid.get_text()!="" and \
|
---|
| 1791 | self.v1 is not None and \
|
---|
| 1792 | self.vr is not None and \
|
---|
| 1793 | self.v2 is not None and \
|
---|
| 1794 | self.v1 <= self.vr and \
|
---|
| 1795 | self.vr <= self.v2
|
---|
| 1796 | self._button.set_sensitive(sensitive)
|
---|
| 1797 |
|
---|
| 1798 | def _valueChanged(self, widget, arg = None):
|
---|
| 1799 | """Called when the value of some widget has changed."""
|
---|
| 1800 | self._updateForwardButton()
|
---|
[84] | 1801 |
|
---|
[138] | 1802 | def _upperChanged(self, entry, arg = None):
|
---|
| 1803 | """Called when the value of some entry widget has changed and the value
|
---|
| 1804 | should be converted to uppercase."""
|
---|
| 1805 | entry.set_text(entry.get_text().upper())
|
---|
| 1806 | self._valueChanged(entry, arg)
|
---|
| 1807 |
|
---|
[71] | 1808 | def _backClicked(self, button):
|
---|
| 1809 | """Called when the Back button is pressed."""
|
---|
| 1810 | self.goBack()
|
---|
| 1811 |
|
---|
| 1812 | def _forwardClicked(self, button):
|
---|
| 1813 | """Called when the forward button is clicked."""
|
---|
[75] | 1814 | self._wizard.nextPage()
|
---|
| 1815 |
|
---|
| 1816 | #-----------------------------------------------------------------------------
|
---|
| 1817 |
|
---|
| 1818 | class LandingPage(Page):
|
---|
| 1819 | """Page for entering landing data."""
|
---|
| 1820 | def __init__(self, wizard):
|
---|
| 1821 | """Construct the landing page."""
|
---|
[107] | 1822 | super(LandingPage, self).__init__(wizard, xstr("landing_title"),
|
---|
| 1823 | xstr("landing_help"),
|
---|
| 1824 | completedHelp = xstr("landing_chelp"))
|
---|
[75] | 1825 |
|
---|
[88] | 1826 | self._flightEnded = False
|
---|
| 1827 |
|
---|
[75] | 1828 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 1829 | xscale = 0.0, yscale = 0.0)
|
---|
| 1830 |
|
---|
[86] | 1831 | table = gtk.Table(5, 5)
|
---|
[75] | 1832 | table.set_row_spacings(4)
|
---|
| 1833 | table.set_col_spacings(16)
|
---|
| 1834 | table.set_homogeneous(False)
|
---|
| 1835 | alignment.add(table)
|
---|
| 1836 | self.setMainWidget(alignment)
|
---|
| 1837 |
|
---|
| 1838 | self._starButton = gtk.CheckButton()
|
---|
| 1839 | self._starButton.connect("clicked", self._starButtonClicked)
|
---|
| 1840 | table.attach(self._starButton, 0, 1, 0, 1)
|
---|
| 1841 |
|
---|
[107] | 1842 | label = gtk.Label(xstr("landing_star"))
|
---|
[75] | 1843 | label.set_use_underline(True)
|
---|
| 1844 | label.set_alignment(0.0, 0.5)
|
---|
| 1845 | table.attach(label, 1, 2, 0, 1)
|
---|
| 1846 |
|
---|
| 1847 | self._star = gtk.Entry()
|
---|
| 1848 | self._star.set_width_chars(10)
|
---|
[107] | 1849 | self._star.set_tooltip_text(xstr("landing_star_tooltip"))
|
---|
[138] | 1850 | self._star.connect("changed", self._upperChanged)
|
---|
[75] | 1851 | self._star.set_sensitive(False)
|
---|
[86] | 1852 | table.attach(self._star, 2, 4, 0, 1)
|
---|
[75] | 1853 | label.set_mnemonic_widget(self._starButton)
|
---|
| 1854 |
|
---|
| 1855 | self._transitionButton = gtk.CheckButton()
|
---|
| 1856 | self._transitionButton.connect("clicked", self._transitionButtonClicked)
|
---|
| 1857 | table.attach(self._transitionButton, 0, 1, 1, 2)
|
---|
| 1858 |
|
---|
[107] | 1859 | label = gtk.Label(xstr("landing_transition"))
|
---|
[75] | 1860 | label.set_use_underline(True)
|
---|
| 1861 | label.set_alignment(0.0, 0.5)
|
---|
| 1862 | table.attach(label, 1, 2, 1, 2)
|
---|
| 1863 |
|
---|
| 1864 | self._transition = gtk.Entry()
|
---|
| 1865 | self._transition.set_width_chars(10)
|
---|
[107] | 1866 | self._transition.set_tooltip_text(xstr("landing_transition_tooltip"))
|
---|
[138] | 1867 | self._transition.connect("changed", self._upperChanged)
|
---|
[75] | 1868 | self._transition.set_sensitive(False)
|
---|
[86] | 1869 | table.attach(self._transition, 2, 4, 1, 2)
|
---|
[75] | 1870 | label.set_mnemonic_widget(self._transitionButton)
|
---|
| 1871 |
|
---|
[107] | 1872 | label = gtk.Label(xstr("landing_runway"))
|
---|
[75] | 1873 | label.set_use_underline(True)
|
---|
| 1874 | label.set_alignment(0.0, 0.5)
|
---|
| 1875 | table.attach(label, 1, 2, 2, 3)
|
---|
| 1876 |
|
---|
| 1877 | self._runway = gtk.Entry()
|
---|
| 1878 | self._runway.set_width_chars(10)
|
---|
[107] | 1879 | self._runway.set_tooltip_text(xstr("landing_runway_tooltip"))
|
---|
[138] | 1880 | self._runway.connect("changed", self._upperChanged)
|
---|
[86] | 1881 | table.attach(self._runway, 2, 4, 2, 3)
|
---|
[75] | 1882 | label.set_mnemonic_widget(self._runway)
|
---|
| 1883 |
|
---|
[107] | 1884 | label = gtk.Label(xstr("landing_approach"))
|
---|
[75] | 1885 | label.set_use_underline(True)
|
---|
| 1886 | label.set_alignment(0.0, 0.5)
|
---|
| 1887 | table.attach(label, 1, 2, 3, 4)
|
---|
| 1888 |
|
---|
| 1889 | self._approachType = gtk.Entry()
|
---|
| 1890 | self._approachType.set_width_chars(10)
|
---|
[107] | 1891 | self._approachType.set_tooltip_text(xstr("landing_approach_tooltip"))
|
---|
[138] | 1892 | self._approachType.connect("changed", self._upperChanged)
|
---|
[86] | 1893 | table.attach(self._approachType, 2, 4, 3, 4)
|
---|
[75] | 1894 | label.set_mnemonic_widget(self._approachType)
|
---|
| 1895 |
|
---|
[107] | 1896 | label = gtk.Label(xstr("landing_vref"))
|
---|
[75] | 1897 | label.set_use_markup(True)
|
---|
| 1898 | label.set_use_underline(True)
|
---|
| 1899 | label.set_alignment(0.0, 0.5)
|
---|
| 1900 | table.attach(label, 1, 2, 5, 6)
|
---|
| 1901 |
|
---|
[86] | 1902 | self._vref = IntegerEntry()
|
---|
| 1903 | self._vref.set_width_chars(5)
|
---|
[107] | 1904 | self._vref.set_tooltip_markup(xstr("landing_vref_tooltip"))
|
---|
[86] | 1905 | self._vref.connect("integer-changed", self._vrefChanged)
|
---|
| 1906 | table.attach(self._vref, 3, 4, 5, 6)
|
---|
[75] | 1907 | label.set_mnemonic_widget(self._vref)
|
---|
| 1908 |
|
---|
[107] | 1909 | table.attach(gtk.Label(xstr("label_knots")), 4, 5, 5, 6)
|
---|
[75] | 1910 |
|
---|
[107] | 1911 | self.addPreviousButton(clicked = self._backClicked)
|
---|
| 1912 |
|
---|
| 1913 | self._button = self.addNextButton(clicked = self._forwardClicked)
|
---|
[75] | 1914 |
|
---|
[76] | 1915 | # These are needed for correct size calculations
|
---|
| 1916 | self._starButton.set_active(True)
|
---|
| 1917 | self._transitionButton.set_active(True)
|
---|
| 1918 |
|
---|
[86] | 1919 | @property
|
---|
[97] | 1920 | def star(self):
|
---|
| 1921 | """Get the STAR or None if none entered."""
|
---|
| 1922 | return self._star.get_text() if self._starButton.get_active() else None
|
---|
| 1923 |
|
---|
| 1924 | @property
|
---|
| 1925 | def transition(self):
|
---|
| 1926 | """Get the transition or None if none entered."""
|
---|
| 1927 | return self._transition.get_text() \
|
---|
| 1928 | if self._transitionButton.get_active() else None
|
---|
| 1929 |
|
---|
| 1930 | @property
|
---|
| 1931 | def approachType(self):
|
---|
| 1932 | """Get the approach type."""
|
---|
| 1933 | return self._approachType.get_text()
|
---|
| 1934 |
|
---|
| 1935 | @property
|
---|
| 1936 | def runway(self):
|
---|
| 1937 | """Get the runway."""
|
---|
| 1938 | return self._runway.get_text()
|
---|
| 1939 |
|
---|
| 1940 | @property
|
---|
[86] | 1941 | def vref(self):
|
---|
| 1942 | """Return the landing reference speed."""
|
---|
| 1943 | return self._vref.get_int()
|
---|
| 1944 |
|
---|
[75] | 1945 | def activate(self):
|
---|
| 1946 | """Called when the page is activated."""
|
---|
| 1947 | self._starButton.set_sensitive(True)
|
---|
| 1948 | self._starButton.set_active(False)
|
---|
| 1949 | self._star.set_text("")
|
---|
| 1950 |
|
---|
| 1951 | self._transitionButton.set_sensitive(True)
|
---|
| 1952 | self._transitionButton.set_active(False)
|
---|
| 1953 | self._transition.set_text("")
|
---|
| 1954 |
|
---|
| 1955 | self._runway.set_text("")
|
---|
| 1956 | self._runway.set_sensitive(True)
|
---|
| 1957 |
|
---|
| 1958 | self._approachType.set_text("")
|
---|
| 1959 | self._approachType.set_sensitive(True)
|
---|
| 1960 |
|
---|
[86] | 1961 | self._vref.set_int(None)
|
---|
[75] | 1962 | self._vref.set_sensitive(True)
|
---|
| 1963 |
|
---|
| 1964 | self._updateForwardButton()
|
---|
| 1965 |
|
---|
[88] | 1966 | def flightEnded(self):
|
---|
| 1967 | """Called when the flight has ended."""
|
---|
| 1968 | self._flightEnded = True
|
---|
| 1969 | self._updateForwardButton()
|
---|
| 1970 |
|
---|
[75] | 1971 | def finalize(self):
|
---|
| 1972 | """Finalize the page."""
|
---|
| 1973 | self._starButton.set_sensitive(False)
|
---|
| 1974 | self._star.set_sensitive(False)
|
---|
| 1975 |
|
---|
| 1976 | self._transitionButton.set_sensitive(False)
|
---|
| 1977 | self._transition.set_sensitive(False)
|
---|
| 1978 |
|
---|
| 1979 | self._runway.set_sensitive(False)
|
---|
| 1980 |
|
---|
| 1981 | self._approachType.set_sensitive(False)
|
---|
| 1982 |
|
---|
| 1983 | self._vref.set_sensitive(False)
|
---|
[96] | 1984 | self._wizard.gui.flight.aircraft.updateVRef()
|
---|
[89] | 1985 | # FIXME: Perhaps a separate initialize() call which would set up
|
---|
[96] | 1986 | # defaults? -> use reset()
|
---|
[89] | 1987 | self._flightEnded = False
|
---|
[75] | 1988 |
|
---|
| 1989 | def _starButtonClicked(self, button):
|
---|
| 1990 | """Called when the STAR button is clicked."""
|
---|
| 1991 | active = button.get_active()
|
---|
| 1992 | self._star.set_sensitive(active)
|
---|
| 1993 | if active:
|
---|
| 1994 | self._star.grab_focus()
|
---|
| 1995 | self._updateForwardButton()
|
---|
| 1996 |
|
---|
| 1997 | def _transitionButtonClicked(self, button):
|
---|
| 1998 | """Called when the Transition button is clicked."""
|
---|
| 1999 | active = button.get_active()
|
---|
| 2000 | self._transition.set_sensitive(active)
|
---|
| 2001 | if active:
|
---|
| 2002 | self._transition.grab_focus()
|
---|
[86] | 2003 | self._updateForwardButton()
|
---|
[75] | 2004 |
|
---|
[138] | 2005 | def _updateForwardButton(self):
|
---|
[75] | 2006 | """Update the sensitivity of the forward button."""
|
---|
[88] | 2007 | sensitive = self._flightEnded and \
|
---|
| 2008 | (self._starButton.get_active() or \
|
---|
[75] | 2009 | self._transitionButton.get_active()) and \
|
---|
| 2010 | (self._star.get_text()!="" or
|
---|
| 2011 | not self._starButton.get_active()) and \
|
---|
| 2012 | (self._transition.get_text()!="" or
|
---|
| 2013 | not self._transitionButton.get_active()) and \
|
---|
| 2014 | self._runway.get_text()!="" and \
|
---|
[86] | 2015 | self._approachType.get_text()!="" and \
|
---|
| 2016 | self.vref is not None
|
---|
[75] | 2017 | self._button.set_sensitive(sensitive)
|
---|
| 2018 |
|
---|
[138] | 2019 | def _upperChanged(self, entry):
|
---|
| 2020 | """Called for entry widgets that must be converted to uppercase."""
|
---|
| 2021 | entry.set_text(entry.get_text().upper())
|
---|
| 2022 | self._updateForwardButton()
|
---|
| 2023 |
|
---|
[86] | 2024 | def _vrefChanged(self, widget, value):
|
---|
| 2025 | """Called when the Vref has changed."""
|
---|
| 2026 | self._updateForwardButton()
|
---|
| 2027 |
|
---|
[75] | 2028 | def _backClicked(self, button):
|
---|
| 2029 | """Called when the Back button is pressed."""
|
---|
| 2030 | self.goBack()
|
---|
| 2031 |
|
---|
| 2032 | def _forwardClicked(self, button):
|
---|
| 2033 | """Called when the forward button is clicked."""
|
---|
[136] | 2034 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
| 2035 | not self._completed and \
|
---|
[130] | 2036 | self._wizard.bookedFlight.arrivalICAO=="LHBP":
|
---|
| 2037 | self._wizard.getFleet(callback = self._fleetRetrieved,
|
---|
| 2038 | force = True)
|
---|
| 2039 | else:
|
---|
| 2040 | self._wizard.nextPage()
|
---|
| 2041 |
|
---|
| 2042 | def _fleetRetrieved(self, fleet):
|
---|
| 2043 | """Callback for the fleet retrieval."""
|
---|
[89] | 2044 | self._wizard.nextPage()
|
---|
| 2045 |
|
---|
| 2046 | #-----------------------------------------------------------------------------
|
---|
| 2047 |
|
---|
| 2048 | class FinishPage(Page):
|
---|
| 2049 | """Flight finish page."""
|
---|
[107] | 2050 | _flightTypes = [ ("flighttype_scheduled", const.FLIGHTTYPE_SCHEDULED),
|
---|
| 2051 | ("flighttype_ot", const.FLIGHTTYPE_OLDTIMER),
|
---|
| 2052 | ("flighttype_vip", const.FLIGHTTYPE_VIP),
|
---|
| 2053 | ("flighttype_charter", const.FLIGHTTYPE_CHARTER) ]
|
---|
[97] | 2054 |
|
---|
[89] | 2055 | def __init__(self, wizard):
|
---|
| 2056 | """Construct the finish page."""
|
---|
[107] | 2057 | super(FinishPage, self).__init__(wizard, xstr("finish_title"),
|
---|
| 2058 | xstr("finish_help"))
|
---|
[89] | 2059 |
|
---|
| 2060 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
| 2061 | xscale = 0.0, yscale = 0.0)
|
---|
| 2062 |
|
---|
[130] | 2063 | table = gtk.Table(8, 2)
|
---|
[89] | 2064 | table.set_row_spacings(4)
|
---|
| 2065 | table.set_col_spacings(16)
|
---|
[96] | 2066 | table.set_homogeneous(False)
|
---|
[89] | 2067 | alignment.add(table)
|
---|
| 2068 | self.setMainWidget(alignment)
|
---|
| 2069 |
|
---|
| 2070 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2071 | label = gtk.Label(xstr("finish_rating"))
|
---|
[89] | 2072 | labelAlignment.add(label)
|
---|
| 2073 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
| 2074 |
|
---|
| 2075 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2076 | self._flightRating = gtk.Label()
|
---|
| 2077 | self._flightRating.set_width_chars(7)
|
---|
| 2078 | self._flightRating.set_alignment(0.0, 0.5)
|
---|
| 2079 | self._flightRating.set_use_markup(True)
|
---|
| 2080 | labelAlignment.add(self._flightRating)
|
---|
| 2081 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
| 2082 |
|
---|
| 2083 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2084 | label = gtk.Label(xstr("finish_flight_time"))
|
---|
[89] | 2085 | labelAlignment.add(label)
|
---|
| 2086 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
| 2087 |
|
---|
| 2088 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2089 | self._flightTime = gtk.Label()
|
---|
| 2090 | self._flightTime.set_width_chars(10)
|
---|
| 2091 | self._flightTime.set_alignment(0.0, 0.5)
|
---|
| 2092 | self._flightTime.set_use_markup(True)
|
---|
| 2093 | labelAlignment.add(self._flightTime)
|
---|
| 2094 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
| 2095 |
|
---|
| 2096 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2097 | label = gtk.Label(xstr("finish_block_time"))
|
---|
[89] | 2098 | labelAlignment.add(label)
|
---|
| 2099 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
| 2100 |
|
---|
| 2101 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2102 | self._blockTime = gtk.Label()
|
---|
| 2103 | self._blockTime.set_width_chars(10)
|
---|
| 2104 | self._blockTime.set_alignment(0.0, 0.5)
|
---|
| 2105 | self._blockTime.set_use_markup(True)
|
---|
| 2106 | labelAlignment.add(self._blockTime)
|
---|
| 2107 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
| 2108 |
|
---|
| 2109 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2110 | label = gtk.Label(xstr("finish_distance"))
|
---|
[89] | 2111 | labelAlignment.add(label)
|
---|
| 2112 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
| 2113 |
|
---|
| 2114 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2115 | self._distanceFlown = gtk.Label()
|
---|
| 2116 | self._distanceFlown.set_width_chars(10)
|
---|
| 2117 | self._distanceFlown.set_alignment(0.0, 0.5)
|
---|
| 2118 | self._distanceFlown.set_use_markup(True)
|
---|
| 2119 | labelAlignment.add(self._distanceFlown)
|
---|
| 2120 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
| 2121 |
|
---|
| 2122 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
[107] | 2123 | label = gtk.Label(xstr("finish_fuel"))
|
---|
[89] | 2124 | labelAlignment.add(label)
|
---|
| 2125 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
| 2126 |
|
---|
| 2127 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2128 | self._fuelUsed = gtk.Label()
|
---|
| 2129 | self._fuelUsed.set_width_chars(10)
|
---|
| 2130 | self._fuelUsed.set_alignment(0.0, 0.5)
|
---|
| 2131 | self._fuelUsed.set_use_markup(True)
|
---|
| 2132 | labelAlignment.add(self._fuelUsed)
|
---|
| 2133 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
| 2134 |
|
---|
[107] | 2135 | labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0,
|
---|
| 2136 | yalign = 0.5, yscale = 0.0)
|
---|
| 2137 | label = gtk.Label(xstr("finish_type"))
|
---|
[96] | 2138 | label.set_use_underline(True)
|
---|
| 2139 | labelAlignment.add(label)
|
---|
| 2140 | table.attach(labelAlignment, 0, 1, 5, 6)
|
---|
| 2141 |
|
---|
| 2142 | flightTypeModel = gtk.ListStore(str, int)
|
---|
[97] | 2143 | for (name, type) in FinishPage._flightTypes:
|
---|
[107] | 2144 | flightTypeModel.append([xstr(name), type])
|
---|
[96] | 2145 |
|
---|
| 2146 | self._flightType = gtk.ComboBox(model = flightTypeModel)
|
---|
| 2147 | renderer = gtk.CellRendererText()
|
---|
| 2148 | self._flightType.pack_start(renderer, True)
|
---|
| 2149 | self._flightType.add_attribute(renderer, "text", 0)
|
---|
[107] | 2150 | self._flightType.set_tooltip_text(xstr("finish_type_tooltip"))
|
---|
[96] | 2151 | self._flightType.set_active(0)
|
---|
| 2152 | self._flightType.connect("changed", self._flightTypeChanged)
|
---|
| 2153 | flightTypeAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2154 | flightTypeAlignment.add(self._flightType)
|
---|
| 2155 | table.attach(flightTypeAlignment, 1, 2, 5, 6)
|
---|
| 2156 | label.set_mnemonic_widget(self._flightType)
|
---|
| 2157 |
|
---|
[107] | 2158 | self._onlineFlight = gtk.CheckButton(xstr("finish_online"))
|
---|
[96] | 2159 | self._onlineFlight.set_use_underline(True)
|
---|
[107] | 2160 | self._onlineFlight.set_tooltip_text(xstr("finish_online_tooltip"))
|
---|
[96] | 2161 | onlineFlightAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
| 2162 | onlineFlightAlignment.add(self._onlineFlight)
|
---|
| 2163 | table.attach(onlineFlightAlignment, 1, 2, 6, 7)
|
---|
| 2164 |
|
---|
[130] | 2165 | labelAlignment = gtk.Alignment(xalign = 1.0, xscale = 0.0,
|
---|
| 2166 | yalign = 0.5, yscale = 0.0)
|
---|
| 2167 | self._gateLabel = gtk.Label(xstr("finish_gate"))
|
---|
| 2168 | self._gateLabel.set_use_underline(True)
|
---|
| 2169 | labelAlignment.add(self._gateLabel)
|
---|
| 2170 | table.attach(labelAlignment, 0, 1, 7, 8)
|
---|
| 2171 |
|
---|
| 2172 | self._gatesModel = gtk.ListStore(str)
|
---|
| 2173 |
|
---|
| 2174 | self._gate = gtk.ComboBox(model = self._gatesModel)
|
---|
| 2175 | renderer = gtk.CellRendererText()
|
---|
| 2176 | self._gate.pack_start(renderer, True)
|
---|
| 2177 | self._gate.add_attribute(renderer, "text", 0)
|
---|
| 2178 | self._gate.set_tooltip_text(xstr("finish_gate_tooltip"))
|
---|
| 2179 | self._gate.connect("changed", self._gateChanged)
|
---|
| 2180 | gateAlignment = gtk.Alignment(xalign=0.0, xscale=1.0)
|
---|
| 2181 | gateAlignment.add(self._gate)
|
---|
| 2182 | table.attach(gateAlignment, 1, 2, 7, 8)
|
---|
| 2183 | self._gateLabel.set_mnemonic_widget(self._gate)
|
---|
| 2184 |
|
---|
[107] | 2185 | self.addPreviousButton(clicked = self._backClicked)
|
---|
[94] | 2186 |
|
---|
[107] | 2187 | self._saveButton = self.addButton(xstr("finish_save"),
|
---|
| 2188 | sensitive = False,
|
---|
| 2189 | tooltip = xstr("finish_send_tooltip"))
|
---|
[89] | 2190 |
|
---|
[107] | 2191 | self._sendButton = self.addButton(xstr("finish_send"), default = True,
|
---|
| 2192 | sensitive = False,
|
---|
| 2193 | clicked = self._sendClicked,
|
---|
| 2194 | tooltip = xstr("finish_send_tooltip"))
|
---|
[97] | 2195 |
|
---|
| 2196 | @property
|
---|
| 2197 | def flightType(self):
|
---|
| 2198 | """Get the flight type."""
|
---|
| 2199 | index = self._flightType.get_active()
|
---|
| 2200 | return None if index<0 else self._flightType.get_model()[index][1]
|
---|
| 2201 |
|
---|
| 2202 | @property
|
---|
| 2203 | def online(self):
|
---|
| 2204 | """Get whether the flight was an online flight or not."""
|
---|
| 2205 | return self._onlineFlight.get_active()
|
---|
[89] | 2206 |
|
---|
| 2207 | def activate(self):
|
---|
| 2208 | """Activate the page."""
|
---|
| 2209 | flight = self._wizard.gui._flight
|
---|
| 2210 | rating = flight.logger.getRating()
|
---|
| 2211 | if rating<0:
|
---|
| 2212 | self._flightRating.set_markup('<b><span foreground="red">NO GO</span></b>')
|
---|
| 2213 | else:
|
---|
| 2214 | self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
|
---|
| 2215 |
|
---|
| 2216 | flightLength = flight.flightTimeEnd - flight.flightTimeStart
|
---|
| 2217 | self._flightTime.set_markup("<b>%s</b>" % \
|
---|
| 2218 | (util.getTimeIntervalString(flightLength),))
|
---|
| 2219 |
|
---|
| 2220 | blockLength = flight.blockTimeEnd - flight.blockTimeStart
|
---|
| 2221 | self._blockTime.set_markup("<b>%s</b>" % \
|
---|
| 2222 | (util.getTimeIntervalString(blockLength),))
|
---|
| 2223 |
|
---|
| 2224 | self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
|
---|
| 2225 | (flight.flownDistance,))
|
---|
| 2226 |
|
---|
| 2227 | self._fuelUsed.set_markup("<b>%.0f kg</b>" % \
|
---|
[102] | 2228 | (flight.startFuel - flight.endFuel,))
|
---|
[64] | 2229 |
|
---|
[96] | 2230 | self._flightType.set_active(-1)
|
---|
| 2231 | self._onlineFlight.set_active(True)
|
---|
| 2232 |
|
---|
[130] | 2233 | self._gatesModel.clear()
|
---|
[136] | 2234 | if self._wizard.gui.config.onlineGateSystem and \
|
---|
| 2235 | self._wizard.bookedFlight.arrivalICAO=="LHBP":
|
---|
[130] | 2236 | occupiedGates = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
| 2237 | for gateNumber in const.lhbpGateNumbers:
|
---|
| 2238 | if gateNumber not in occupiedGates:
|
---|
| 2239 | self._gatesModel.append([gateNumber])
|
---|
| 2240 | self._gateLabel.set_sensitive(True)
|
---|
| 2241 | self._gate.set_sensitive(True)
|
---|
| 2242 | self._gate.set_active(-1)
|
---|
| 2243 | else:
|
---|
| 2244 | self._gateLabel.set_sensitive(False)
|
---|
| 2245 | self._gate.set_sensitive(False)
|
---|
| 2246 |
|
---|
[94] | 2247 | def _backClicked(self, button):
|
---|
| 2248 | """Called when the Back button is pressed."""
|
---|
| 2249 | self.goBack()
|
---|
[96] | 2250 |
|
---|
[130] | 2251 | def _updateButtons(self):
|
---|
| 2252 | """Update the sensitivity state of the buttons."""
|
---|
| 2253 | sensitive = self._flightType.get_active()>=0 and \
|
---|
| 2254 | (self._gatesModel.get_iter_first() is None or
|
---|
| 2255 | self._gate.get_active()>=0)
|
---|
| 2256 |
|
---|
| 2257 | #self._saveButton.set_sensitive(sensitive)
|
---|
| 2258 | self._sendButton.set_sensitive(sensitive)
|
---|
| 2259 |
|
---|
[96] | 2260 | def _flightTypeChanged(self, comboBox):
|
---|
| 2261 | """Called when the flight type has changed."""
|
---|
[130] | 2262 | self._updateButtons()
|
---|
| 2263 |
|
---|
| 2264 | def _gateChanged(self, comboBox):
|
---|
| 2265 | """Called when the arrival gate has changed."""
|
---|
| 2266 | self._updateButtons()
|
---|
[97] | 2267 |
|
---|
| 2268 | def _sendClicked(self, button):
|
---|
| 2269 | """Called when the Send button is clicked."""
|
---|
| 2270 | pirep = PIREP(self._wizard.gui)
|
---|
| 2271 | gui = self._wizard.gui
|
---|
[107] | 2272 | gui.beginBusy(xstr("finish_send_busy"))
|
---|
[97] | 2273 | gui.webHandler.sendPIREP(self._pirepSentCallback, pirep)
|
---|
| 2274 |
|
---|
| 2275 | def _pirepSentCallback(self, returned, result):
|
---|
| 2276 | """Callback for the PIREP sending result."""
|
---|
| 2277 | gobject.idle_add(self._handlePIREPSent, returned, result)
|
---|
| 2278 |
|
---|
| 2279 | def _handlePIREPSent(self, returned, result):
|
---|
| 2280 | """Callback for the PIREP sending result."""
|
---|
| 2281 | self._wizard.gui.endBusy()
|
---|
| 2282 | secondaryMarkup = None
|
---|
| 2283 | type = MESSAGETYPE_ERROR
|
---|
| 2284 | if returned:
|
---|
| 2285 | if result.success:
|
---|
| 2286 | type = MESSAGETYPE_INFO
|
---|
[107] | 2287 | messageFormat = xstr("finish_send_success")
|
---|
| 2288 | secondaryMarkup = xstr("finish_send_success_sec")
|
---|
[97] | 2289 | elif result.alreadyFlown:
|
---|
[107] | 2290 | messageFormat = xstr("finish_send_already")
|
---|
| 2291 | secondaryMarkup = xstr("finish_send_already_sec")
|
---|
[97] | 2292 | elif result.notAvailable:
|
---|
[107] | 2293 | messageFormat = xstr("finish_send_notavail")
|
---|
[97] | 2294 | else:
|
---|
[107] | 2295 | messageFormat = xstr("finish_send_unknown")
|
---|
| 2296 | secondaryMarkup = xstr("finish_send_unknown_sec")
|
---|
[97] | 2297 | else:
|
---|
| 2298 | print "PIREP sending failed", result
|
---|
[107] | 2299 | messageFormat = xstr("finish_send_failed")
|
---|
| 2300 | secondaryMarkup = xstr("finish_send_failed_sec")
|
---|
[97] | 2301 |
|
---|
[105] | 2302 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
[124] | 2303 | type = type, message_format = messageFormat)
|
---|
| 2304 | dialog.add_button(xstr("button_ok"), RESPONSETYPE_OK)
|
---|
[105] | 2305 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
[97] | 2306 | if secondaryMarkup is not None:
|
---|
| 2307 | dialog.format_secondary_markup(secondaryMarkup)
|
---|
| 2308 |
|
---|
| 2309 | dialog.run()
|
---|
| 2310 | dialog.hide()
|
---|
[130] | 2311 |
|
---|
[136] | 2312 | if self._wizard.gui.config.onlineGateSystem and returned and result.success:
|
---|
[130] | 2313 | bookedFlight = self._wizard.bookedFlight
|
---|
| 2314 | if bookedFlight.arrivalICAO=="LHBP":
|
---|
| 2315 | iter = self._gate.get_active_iter()
|
---|
| 2316 | gateNumber = None if iter is None \
|
---|
| 2317 | else self._gatesModel.get_value(iter, 0)
|
---|
| 2318 |
|
---|
| 2319 | status = const.PLANE_PARKING if gateNumber is None \
|
---|
| 2320 | else const.PLANE_HOME
|
---|
| 2321 | else:
|
---|
| 2322 | gateNumber = None
|
---|
| 2323 | status = const.PLANE_AWAY
|
---|
| 2324 |
|
---|
| 2325 | self._wizard.updatePlane(self._planeUpdated,
|
---|
| 2326 | bookedFlight.tailNumber,
|
---|
| 2327 | status, gateNumber = gateNumber)
|
---|
| 2328 |
|
---|
| 2329 | def _planeUpdated(self, success):
|
---|
| 2330 | """Callback for the plane updating."""
|
---|
| 2331 | pass
|
---|
[94] | 2332 |
|
---|
[64] | 2333 | #-----------------------------------------------------------------------------
|
---|
| 2334 |
|
---|
[42] | 2335 | class Wizard(gtk.VBox):
|
---|
| 2336 | """The flight wizard."""
|
---|
| 2337 | def __init__(self, gui):
|
---|
| 2338 | """Construct the wizard."""
|
---|
| 2339 | super(Wizard, self).__init__()
|
---|
| 2340 |
|
---|
| 2341 | self.gui = gui
|
---|
| 2342 |
|
---|
| 2343 | self._pages = []
|
---|
| 2344 | self._currentPage = None
|
---|
| 2345 |
|
---|
| 2346 | self._pages.append(LoginPage(self))
|
---|
| 2347 | self._pages.append(FlightSelectionPage(self))
|
---|
[51] | 2348 | self._pages.append(GateSelectionPage(self))
|
---|
| 2349 | self._pages.append(ConnectPage(self))
|
---|
[84] | 2350 | self._payloadPage = PayloadPage(self)
|
---|
| 2351 | self._pages.append(self._payloadPage)
|
---|
[117] | 2352 | self._payloadIndex = len(self._pages)
|
---|
[61] | 2353 | self._pages.append(TimePage(self))
|
---|
[141] | 2354 | self._pages.append(FuelPage(self))
|
---|
[84] | 2355 | self._routePage = RoutePage(self)
|
---|
| 2356 | self._pages.append(self._routePage)
|
---|
[97] | 2357 | self._departureBriefingPage = BriefingPage(self, True)
|
---|
| 2358 | self._pages.append(self._departureBriefingPage)
|
---|
| 2359 | self._arrivalBriefingPage = BriefingPage(self, False)
|
---|
| 2360 | self._pages.append(self._arrivalBriefingPage)
|
---|
[117] | 2361 | self._arrivalBriefingIndex = len(self._pages)
|
---|
[84] | 2362 | self._takeoffPage = TakeoffPage(self)
|
---|
| 2363 | self._pages.append(self._takeoffPage)
|
---|
[86] | 2364 | self._landingPage = LandingPage(self)
|
---|
| 2365 | self._pages.append(self._landingPage)
|
---|
[97] | 2366 | self._finishPage = FinishPage(self)
|
---|
| 2367 | self._pages.append(self._finishPage)
|
---|
[67] | 2368 |
|
---|
[51] | 2369 | maxWidth = 0
|
---|
| 2370 | maxHeight = 0
|
---|
| 2371 | for page in self._pages:
|
---|
| 2372 | page.show_all()
|
---|
| 2373 | pageSizeRequest = page.size_request()
|
---|
| 2374 | width = pageSizeRequest.width if pygobject else pageSizeRequest[0]
|
---|
| 2375 | height = pageSizeRequest.height if pygobject else pageSizeRequest[1]
|
---|
| 2376 | maxWidth = max(maxWidth, width)
|
---|
| 2377 | maxHeight = max(maxHeight, height)
|
---|
| 2378 | maxWidth += 16
|
---|
| 2379 | maxHeight += 32
|
---|
| 2380 | self.set_size_request(maxWidth, maxHeight)
|
---|
| 2381 |
|
---|
[59] | 2382 | self._initialize()
|
---|
[51] | 2383 |
|
---|
[48] | 2384 | @property
|
---|
| 2385 | def loginResult(self):
|
---|
| 2386 | """Get the login result."""
|
---|
| 2387 | return self._loginResult
|
---|
| 2388 |
|
---|
[70] | 2389 | def setCurrentPage(self, index, finalize = False):
|
---|
[42] | 2390 | """Set the current page to the one with the given index."""
|
---|
| 2391 | assert index < len(self._pages)
|
---|
[70] | 2392 |
|
---|
| 2393 | fromPage = self._currentPage
|
---|
| 2394 | if fromPage is not None:
|
---|
| 2395 | page = self._pages[fromPage]
|
---|
[94] | 2396 | if finalize and not page._completed:
|
---|
| 2397 | page.complete()
|
---|
[70] | 2398 | self.remove(page)
|
---|
[42] | 2399 |
|
---|
| 2400 | self._currentPage = index
|
---|
[70] | 2401 | page = self._pages[index]
|
---|
| 2402 | self.add(page)
|
---|
| 2403 | if page._fromPage is None:
|
---|
| 2404 | page._fromPage = fromPage
|
---|
[94] | 2405 | page.initialize()
|
---|
[42] | 2406 | self.show_all()
|
---|
[72] | 2407 | if fromPage is not None:
|
---|
| 2408 | self.grabDefault()
|
---|
[42] | 2409 |
|
---|
[84] | 2410 | @property
|
---|
[97] | 2411 | def bookedFlight(self):
|
---|
| 2412 | """Get the booked flight selected."""
|
---|
| 2413 | return self._bookedFlight
|
---|
| 2414 |
|
---|
| 2415 | @property
|
---|
| 2416 | def cargoWeight(self):
|
---|
| 2417 | """Get the calculated ZFW value."""
|
---|
| 2418 | return self._payloadPage.cargoWeight
|
---|
| 2419 |
|
---|
| 2420 | @property
|
---|
[84] | 2421 | def zfw(self):
|
---|
| 2422 | """Get the calculated ZFW value."""
|
---|
| 2423 | return 0 if self._bookedFlight is None \
|
---|
| 2424 | else self._payloadPage.calculateZFW()
|
---|
| 2425 |
|
---|
| 2426 | @property
|
---|
[97] | 2427 | def filedCruiseAltitude(self):
|
---|
| 2428 | """Get the filed cruise altitude."""
|
---|
| 2429 | return self._routePage.filedCruiseLevel * 100
|
---|
| 2430 |
|
---|
| 2431 | @property
|
---|
[84] | 2432 | def cruiseAltitude(self):
|
---|
| 2433 | """Get the cruise altitude."""
|
---|
| 2434 | return self._routePage.cruiseLevel * 100
|
---|
| 2435 |
|
---|
| 2436 | @property
|
---|
[97] | 2437 | def route(self):
|
---|
| 2438 | """Get the route."""
|
---|
| 2439 | return self._routePage.route
|
---|
| 2440 |
|
---|
| 2441 | @property
|
---|
| 2442 | def departureMETAR(self):
|
---|
| 2443 | """Get the METAR of the departure airport."""
|
---|
| 2444 | return self._departureBriefingPage.metar
|
---|
| 2445 |
|
---|
| 2446 | @property
|
---|
| 2447 | def arrivalMETAR(self):
|
---|
| 2448 | """Get the METAR of the arrival airport."""
|
---|
| 2449 | return self._arrivalBriefingPage.metar
|
---|
| 2450 |
|
---|
| 2451 | @property
|
---|
| 2452 | def departureRunway(self):
|
---|
| 2453 | """Get the departure runway."""
|
---|
| 2454 | return self._takeoffPage.runway
|
---|
| 2455 |
|
---|
| 2456 | @property
|
---|
| 2457 | def sid(self):
|
---|
| 2458 | """Get the SID."""
|
---|
| 2459 | return self._takeoffPage.sid
|
---|
| 2460 |
|
---|
| 2461 | @property
|
---|
[84] | 2462 | def v1(self):
|
---|
| 2463 | """Get the V1 speed."""
|
---|
[86] | 2464 | return self._takeoffPage.v1
|
---|
[84] | 2465 |
|
---|
| 2466 | @property
|
---|
| 2467 | def vr(self):
|
---|
| 2468 | """Get the Vr speed."""
|
---|
[86] | 2469 | return self._takeoffPage.vr
|
---|
[84] | 2470 |
|
---|
| 2471 | @property
|
---|
| 2472 | def v2(self):
|
---|
| 2473 | """Get the V2 speed."""
|
---|
[86] | 2474 | return self._takeoffPage.v2
|
---|
| 2475 |
|
---|
| 2476 | @property
|
---|
[97] | 2477 | def arrivalRunway(self):
|
---|
| 2478 | """Get the arrival runway."""
|
---|
| 2479 | return self._landingPage.runway
|
---|
| 2480 |
|
---|
| 2481 | @property
|
---|
| 2482 | def star(self):
|
---|
| 2483 | """Get the STAR."""
|
---|
| 2484 | return self._landingPage.star
|
---|
| 2485 |
|
---|
| 2486 | @property
|
---|
| 2487 | def transition(self):
|
---|
| 2488 | """Get the transition."""
|
---|
| 2489 | return self._landingPage.transition
|
---|
| 2490 |
|
---|
| 2491 | @property
|
---|
| 2492 | def approachType(self):
|
---|
| 2493 | """Get the approach type."""
|
---|
| 2494 | return self._landingPage.approachType
|
---|
| 2495 |
|
---|
| 2496 | @property
|
---|
[86] | 2497 | def vref(self):
|
---|
| 2498 | """Get the Vref speed."""
|
---|
| 2499 | return self._landingPage.vref
|
---|
[84] | 2500 |
|
---|
[97] | 2501 | @property
|
---|
| 2502 | def flightType(self):
|
---|
| 2503 | """Get the flight type."""
|
---|
| 2504 | return self._finishPage.flightType
|
---|
| 2505 |
|
---|
| 2506 | @property
|
---|
| 2507 | def online(self):
|
---|
| 2508 | """Get whether the flight was online or not."""
|
---|
| 2509 | return self._finishPage.online
|
---|
| 2510 |
|
---|
[70] | 2511 | def nextPage(self, finalize = True):
|
---|
[42] | 2512 | """Go to the next page."""
|
---|
[70] | 2513 | self.jumpPage(1, finalize)
|
---|
[51] | 2514 |
|
---|
[70] | 2515 | def jumpPage(self, count, finalize = True):
|
---|
[51] | 2516 | """Go to the page which is 'count' pages after the current one."""
|
---|
[70] | 2517 | self.setCurrentPage(self._currentPage + count, finalize = finalize)
|
---|
[46] | 2518 |
|
---|
| 2519 | def grabDefault(self):
|
---|
| 2520 | """Make the default button of the current page the default."""
|
---|
| 2521 | self._pages[self._currentPage].grabDefault()
|
---|
[51] | 2522 |
|
---|
[59] | 2523 | def connected(self, fsType, descriptor):
|
---|
| 2524 | """Called when the connection could be made to the simulator."""
|
---|
| 2525 | self.nextPage()
|
---|
| 2526 |
|
---|
[91] | 2527 | def reset(self):
|
---|
| 2528 | """Resets the wizard to go back to the login page."""
|
---|
[59] | 2529 | self._initialize()
|
---|
| 2530 |
|
---|
[84] | 2531 | def setStage(self, stage):
|
---|
| 2532 | """Set the flight stage to the given one."""
|
---|
| 2533 | if stage==const.STAGE_TAKEOFF:
|
---|
[101] | 2534 | self._takeoffPage.allowForward()
|
---|
[106] | 2535 | elif stage==const.STAGE_LANDING:
|
---|
| 2536 | if not self._arrivalBriefingPage.metarEdited:
|
---|
| 2537 | print "Downloading arrival METAR again"
|
---|
| 2538 | self.gui.webHandler.getMETARs(self._arrivalMETARCallback,
|
---|
| 2539 | [self._bookedFlight.arrivalICAO])
|
---|
| 2540 |
|
---|
[88] | 2541 | elif stage==const.STAGE_END:
|
---|
| 2542 | self._landingPage.flightEnded()
|
---|
[84] | 2543 |
|
---|
[59] | 2544 | def _initialize(self):
|
---|
| 2545 | """Initialize the wizard."""
|
---|
| 2546 | self._fleet = None
|
---|
| 2547 | self._fleetCallback = None
|
---|
| 2548 |
|
---|
| 2549 | self._loginResult = None
|
---|
| 2550 | self._bookedFlight = None
|
---|
| 2551 | self._departureGate = "-"
|
---|
[141] | 2552 | self._fuelData = None
|
---|
[64] | 2553 | self._departureNOTAMs = None
|
---|
[67] | 2554 | self._departureMETAR = None
|
---|
[64] | 2555 | self._arrivalNOTAMs = None
|
---|
[67] | 2556 | self._arrivalMETAR = None
|
---|
| 2557 |
|
---|
| 2558 | for page in self._pages:
|
---|
| 2559 | page.reset()
|
---|
[62] | 2560 |
|
---|
[145] | 2561 | self.setCurrentPage(0)
|
---|
[126] | 2562 |
|
---|
[130] | 2563 | def getFleet(self, callback, force = False):
|
---|
[126] | 2564 | """Get the fleet via the GUI and call the given callback."""
|
---|
| 2565 | self._fleetCallback = callback
|
---|
[130] | 2566 | self.gui.getFleet(callback = self._fleetRetrieved, force = force)
|
---|
[126] | 2567 |
|
---|
| 2568 | def _fleetRetrieved(self, fleet):
|
---|
| 2569 | """Callback for the fleet retrieval."""
|
---|
| 2570 | self._fleet = fleet
|
---|
| 2571 | if self._fleetCallback is not None:
|
---|
| 2572 | self._fleetCallback(fleet)
|
---|
| 2573 | self._fleetCallback = None
|
---|
[59] | 2574 |
|
---|
[130] | 2575 | def updatePlane(self, callback, tailNumber, status, gateNumber = None):
|
---|
[51] | 2576 | """Update the given plane's gate information."""
|
---|
[130] | 2577 | self.gui.updatePlane(tailNumber, status, gateNumber = gateNumber,
|
---|
| 2578 | callback = callback)
|
---|
[51] | 2579 |
|
---|
| 2580 | def _connectSimulator(self):
|
---|
| 2581 | """Connect to the simulator."""
|
---|
[59] | 2582 | self.gui.connectSimulator(self._bookedFlight.aircraftType)
|
---|
[106] | 2583 |
|
---|
| 2584 | def _arrivalMETARCallback(self, returned, result):
|
---|
| 2585 | """Called when the METAR of the arrival airport is retrieved."""
|
---|
| 2586 | gobject.idle_add(self._handleArrivalMETAR, returned, result)
|
---|
| 2587 |
|
---|
| 2588 | def _handleArrivalMETAR(self, returned, result):
|
---|
| 2589 | """Called when the METAR of the arrival airport is retrieved."""
|
---|
| 2590 | icao = self._bookedFlight.arrivalICAO
|
---|
| 2591 | if returned and icao in result.metars:
|
---|
| 2592 | metar = result.metars[icao]
|
---|
| 2593 | if metar!="":
|
---|
| 2594 | self._arrivalBriefingPage.setMETAR(metar)
|
---|
[42] | 2595 |
|
---|
| 2596 | #-----------------------------------------------------------------------------
|
---|
| 2597 |
|
---|