1 | # The flight handling "wizard"
|
---|
2 |
|
---|
3 | from mlx.gui.common import *
|
---|
4 |
|
---|
5 | import mlx.const as const
|
---|
6 | import mlx.fs as fs
|
---|
7 | from mlx.checks import PayloadChecker
|
---|
8 | import mlx.util as util
|
---|
9 | from mlx.pirep import PIREP
|
---|
10 |
|
---|
11 | import datetime
|
---|
12 | import time
|
---|
13 |
|
---|
14 | #------------------------------------------------------------------------------
|
---|
15 |
|
---|
16 | acftTypeNames = { const.AIRCRAFT_B736: "Boeing 737-600",
|
---|
17 | const.AIRCRAFT_B737: "Boeing 737-700",
|
---|
18 | const.AIRCRAFT_B738: "Boeing 737-800",
|
---|
19 | const.AIRCRAFT_DH8D: "Bombardier Dash 8-Q400",
|
---|
20 | const.AIRCRAFT_B733: "Boeing 737-300",
|
---|
21 | const.AIRCRAFT_B734: "Boeing 737-400",
|
---|
22 | const.AIRCRAFT_B735: "Boeing 737-500",
|
---|
23 | const.AIRCRAFT_B762: "Boeing 767-200",
|
---|
24 | const.AIRCRAFT_B763: "Boeing 767-300",
|
---|
25 | const.AIRCRAFT_CRJ2: "Bombardier CRJ200",
|
---|
26 | const.AIRCRAFT_F70: "Fokker 70",
|
---|
27 | const.AIRCRAFT_DC3: "Lisunov Li-2",
|
---|
28 | const.AIRCRAFT_T134: "Tupolev Tu-134",
|
---|
29 | const.AIRCRAFT_T154: "Tupolev Tu-154",
|
---|
30 | const.AIRCRAFT_YK40: "Yakovlev Yak-40" }
|
---|
31 |
|
---|
32 | #-----------------------------------------------------------------------------
|
---|
33 |
|
---|
34 | class Page(gtk.Alignment):
|
---|
35 | """A page in the flight wizard."""
|
---|
36 | def __init__(self, wizard, title, help, completedHelp = None):
|
---|
37 | """Construct the page."""
|
---|
38 | super(Page, self).__init__(xalign = 0.0, yalign = 0.0,
|
---|
39 | xscale = 1.0, yscale = 1.0)
|
---|
40 | self.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
41 | padding_left = 12, padding_right = 12)
|
---|
42 |
|
---|
43 | frame = gtk.Frame()
|
---|
44 | self.add(frame)
|
---|
45 |
|
---|
46 | style = self.get_style() if pygobject else self.rc_get_style()
|
---|
47 |
|
---|
48 | self._vbox = gtk.VBox()
|
---|
49 | self._vbox.set_homogeneous(False)
|
---|
50 | frame.add(self._vbox)
|
---|
51 |
|
---|
52 | eventBox = gtk.EventBox()
|
---|
53 | eventBox.modify_bg(0, style.bg[3])
|
---|
54 |
|
---|
55 | alignment = gtk.Alignment(xalign = 0.0, xscale = 0.0)
|
---|
56 |
|
---|
57 | label = gtk.Label(title)
|
---|
58 | label.modify_fg(0, style.fg[3])
|
---|
59 | label.modify_font(pango.FontDescription("bold 24"))
|
---|
60 | alignment.set_padding(padding_top = 4, padding_bottom = 4,
|
---|
61 | padding_left = 6, padding_right = 0)
|
---|
62 |
|
---|
63 | alignment.add(label)
|
---|
64 | eventBox.add(alignment)
|
---|
65 |
|
---|
66 | self._vbox.pack_start(eventBox, False, False, 0)
|
---|
67 |
|
---|
68 | mainBox = gtk.VBox()
|
---|
69 |
|
---|
70 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
71 | xscale = 1.0, yscale = 1.0)
|
---|
72 | alignment.set_padding(padding_top = 16, padding_bottom = 16,
|
---|
73 | padding_left = 16, padding_right = 16)
|
---|
74 | alignment.add(mainBox)
|
---|
75 | self._vbox.pack_start(alignment, True, True, 0)
|
---|
76 |
|
---|
77 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0,
|
---|
78 | xscale = 0.0, yscale = 0.0)
|
---|
79 | alignment.set_padding(padding_top = 0, padding_bottom = 16,
|
---|
80 | padding_left = 0, padding_right = 0)
|
---|
81 |
|
---|
82 | self._help = help
|
---|
83 | self._completedHelp = completedHelp
|
---|
84 |
|
---|
85 | if self._completedHelp is None or \
|
---|
86 | len(help.splitlines())>=len(completedHelp.splitlines()):
|
---|
87 | longerHelp = help
|
---|
88 | else:
|
---|
89 | longerHelp = completedHelp
|
---|
90 |
|
---|
91 | self._helpLabel = gtk.Label(completedHelp)
|
---|
92 | # FIXME: should be a constant in common
|
---|
93 | self._helpLabel.set_justify(gtk.Justification.CENTER if pygobject
|
---|
94 | else gtk.JUSTIFY_CENTER)
|
---|
95 | self._helpLabel.set_use_markup(True)
|
---|
96 | alignment.add(self._helpLabel)
|
---|
97 | mainBox.pack_start(alignment, False, False, 0)
|
---|
98 |
|
---|
99 | self._mainAlignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
100 | xscale = 1.0, yscale = 1.0)
|
---|
101 | mainBox.pack_start(self._mainAlignment, True, True, 0)
|
---|
102 |
|
---|
103 | buttonAlignment = gtk.Alignment(xalign = 1.0, xscale=0.0, yscale = 0.0)
|
---|
104 | buttonAlignment.set_padding(padding_top = 4, padding_bottom = 10,
|
---|
105 | padding_left = 16, padding_right = 16)
|
---|
106 |
|
---|
107 | self._buttonBox = gtk.HBox()
|
---|
108 | self._buttonBox.set_homogeneous(False)
|
---|
109 | self._defaultButton = None
|
---|
110 | buttonAlignment.add(self._buttonBox)
|
---|
111 |
|
---|
112 | self._vbox.pack_start(buttonAlignment, False, False, 0)
|
---|
113 |
|
---|
114 | self._wizard = wizard
|
---|
115 |
|
---|
116 | self._completed = False
|
---|
117 | self._fromPage = None
|
---|
118 |
|
---|
119 | def setMainWidget(self, widget):
|
---|
120 | """Set the given widget as the main one."""
|
---|
121 | self._mainAlignment.add(widget)
|
---|
122 |
|
---|
123 | def addButton(self, label, default = False):
|
---|
124 | """Add a button with the given label.
|
---|
125 |
|
---|
126 | Return the button object created."""
|
---|
127 | button = gtk.Button(label)
|
---|
128 | self._buttonBox.pack_start(button, False, False, 4)
|
---|
129 | button.set_use_underline(True)
|
---|
130 | if default:
|
---|
131 | button.set_can_default(True)
|
---|
132 | self._defaultButton = button
|
---|
133 | return button
|
---|
134 |
|
---|
135 | def initialize(self):
|
---|
136 | """Initialize the page.
|
---|
137 |
|
---|
138 | It sets up the primary help, and calls the activate() function."""
|
---|
139 | self._helpLabel.set_markup(self._help)
|
---|
140 | self._helpLabel.set_sensitive(True)
|
---|
141 | self.activate()
|
---|
142 |
|
---|
143 | def activate(self):
|
---|
144 | """Called when this page becomes active.
|
---|
145 |
|
---|
146 | This default implementation does nothing."""
|
---|
147 | pass
|
---|
148 |
|
---|
149 | def complete(self):
|
---|
150 | """Called when the page is completed.
|
---|
151 |
|
---|
152 | It greys out/changes the help text and then calls finalize()."""
|
---|
153 | self.finalize()
|
---|
154 | if self._completedHelp is None:
|
---|
155 | self._helpLabel.set_sensitive(False)
|
---|
156 | else:
|
---|
157 | self._helpLabel.set_markup(self._completedHelp)
|
---|
158 | self._completed = True
|
---|
159 |
|
---|
160 | def finalize(self):
|
---|
161 | """Called when the page is finalized."""
|
---|
162 | pass
|
---|
163 |
|
---|
164 | def grabDefault(self):
|
---|
165 | """If the page has a default button, make it the default one."""
|
---|
166 | if self._defaultButton is not None:
|
---|
167 | self._defaultButton.grab_default()
|
---|
168 |
|
---|
169 | def reset(self):
|
---|
170 | """Reset the page if the wizard is reset."""
|
---|
171 | self._completed = False
|
---|
172 | self._fromPage = None
|
---|
173 |
|
---|
174 | def goBack(self):
|
---|
175 | """Go to the page we were invoked from."""
|
---|
176 | assert self._fromPage is not None
|
---|
177 |
|
---|
178 | self._wizard.setCurrentPage(self._fromPage, finalize = False)
|
---|
179 |
|
---|
180 | #-----------------------------------------------------------------------------
|
---|
181 |
|
---|
182 | class LoginPage(Page):
|
---|
183 | """The login page."""
|
---|
184 | def __init__(self, wizard):
|
---|
185 | """Construct the login page."""
|
---|
186 | help = "Enter your MAVA pilot's ID and password to\n" \
|
---|
187 | "log in to the MAVA website and download\n" \
|
---|
188 | "your booked flights."
|
---|
189 | super(LoginPage, self).__init__(wizard, "Login", help)
|
---|
190 |
|
---|
191 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
192 | xscale = 0.0, yscale = 0.0)
|
---|
193 |
|
---|
194 | table = gtk.Table(2, 3)
|
---|
195 | table.set_row_spacings(4)
|
---|
196 | table.set_col_spacings(32)
|
---|
197 | alignment.add(table)
|
---|
198 | self.setMainWidget(alignment)
|
---|
199 |
|
---|
200 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
201 | label = gtk.Label("Pilot _ID:")
|
---|
202 | label.set_use_underline(True)
|
---|
203 | labelAlignment.add(label)
|
---|
204 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
205 |
|
---|
206 | self._pilotID = gtk.Entry()
|
---|
207 | self._pilotID.connect("changed", self._setLoginButton)
|
---|
208 | self._pilotID.set_tooltip_text("Enter your MAVA pilot's ID. This "
|
---|
209 | "usually starts with a "
|
---|
210 | "'P' followed by 3 digits.")
|
---|
211 | table.attach(self._pilotID, 1, 2, 0, 1)
|
---|
212 | label.set_mnemonic_widget(self._pilotID)
|
---|
213 |
|
---|
214 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
215 | label = gtk.Label("_Password:")
|
---|
216 | label.set_use_underline(True)
|
---|
217 | labelAlignment.add(label)
|
---|
218 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
219 |
|
---|
220 | self._password = gtk.Entry()
|
---|
221 | self._password.set_visibility(False)
|
---|
222 | self._password.connect("changed", self._setLoginButton)
|
---|
223 | self._password.set_tooltip_text("Enter the password for your pilot's ID")
|
---|
224 | table.attach(self._password, 1, 2, 1, 2)
|
---|
225 | label.set_mnemonic_widget(self._password)
|
---|
226 |
|
---|
227 | self._rememberButton = gtk.CheckButton("_Remember password")
|
---|
228 | self._rememberButton.set_use_underline(True)
|
---|
229 | self._rememberButton.set_tooltip_text("If checked, your password will "
|
---|
230 | "be stored, so that you should "
|
---|
231 | "not have to enter it every time. "
|
---|
232 | "Note, however, that the password "
|
---|
233 | "is stored as text, and anybody "
|
---|
234 | "who can access your files will "
|
---|
235 | "be able to read it.")
|
---|
236 | table.attach(self._rememberButton, 1, 2, 2, 3, ypadding = 8)
|
---|
237 |
|
---|
238 | self._loginButton = self.addButton("_Login", default = True)
|
---|
239 | self._loginButton.set_sensitive(False)
|
---|
240 | self._loginButton.connect("clicked", self._loginClicked)
|
---|
241 | self._loginButton.set_tooltip_text("Click to log in.")
|
---|
242 |
|
---|
243 | def activate(self):
|
---|
244 | """Activate the page."""
|
---|
245 | config = self._wizard.gui.config
|
---|
246 | self._pilotID.set_text(config.pilotID)
|
---|
247 | self._password.set_text(config.password)
|
---|
248 | self._rememberButton.set_active(config.rememberPassword)
|
---|
249 |
|
---|
250 | def _setLoginButton(self, entry):
|
---|
251 | """Set the login button's sensitivity.
|
---|
252 |
|
---|
253 | The button is sensitive only if both the pilot ID and the password
|
---|
254 | fields contain values."""
|
---|
255 | self._loginButton.set_sensitive(self._pilotID.get_text()!="" and
|
---|
256 | self._password.get_text()!="")
|
---|
257 |
|
---|
258 | def _loginClicked(self, button):
|
---|
259 | """Called when the login button was clicked."""
|
---|
260 | self._loginButton.set_sensitive(False)
|
---|
261 | gui = self._wizard.gui
|
---|
262 | gui.beginBusy("Logging in...")
|
---|
263 | gui.webHandler.login(self._loginResultCallback,
|
---|
264 | self._pilotID.get_text(),
|
---|
265 | self._password.get_text())
|
---|
266 |
|
---|
267 | def _loginResultCallback(self, returned, result):
|
---|
268 | """The login result callback, called in the web handler's thread."""
|
---|
269 | gobject.idle_add(self._handleLoginResult, returned, result)
|
---|
270 |
|
---|
271 | def _handleLoginResult(self, returned, result):
|
---|
272 | """Handle the login result."""
|
---|
273 | self._wizard.gui.endBusy()
|
---|
274 | self._loginButton.set_sensitive(True)
|
---|
275 | if returned:
|
---|
276 | if result.loggedIn:
|
---|
277 | config = self._wizard.gui.config
|
---|
278 |
|
---|
279 | config.pilotID = self._pilotID.get_text()
|
---|
280 |
|
---|
281 | rememberPassword = self._rememberButton.get_active()
|
---|
282 | config.password = self._password.get_text() if rememberPassword \
|
---|
283 | else ""
|
---|
284 |
|
---|
285 | config.rememberPassword = rememberPassword
|
---|
286 |
|
---|
287 | config.save()
|
---|
288 | self._wizard._loginResult = result
|
---|
289 | self._wizard.nextPage()
|
---|
290 | else:
|
---|
291 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
292 | type = MESSAGETYPE_ERROR,
|
---|
293 | buttons = BUTTONSTYPE_OK,
|
---|
294 | message_format =
|
---|
295 | "Invalid pilot's ID or password.")
|
---|
296 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
297 | dialog.format_secondary_markup("Check the ID and try to reenter"
|
---|
298 | " the password.")
|
---|
299 | dialog.run()
|
---|
300 | dialog.hide()
|
---|
301 | else:
|
---|
302 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
303 | type = MESSAGETYPE_ERROR,
|
---|
304 | buttons = BUTTONSTYPE_OK,
|
---|
305 | message_format =
|
---|
306 | "Failed to connect to the MAVA website.")
|
---|
307 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
308 | dialog.format_secondary_markup("Try again in a few minutes.")
|
---|
309 | dialog.run()
|
---|
310 | dialog.hide()
|
---|
311 |
|
---|
312 | #-----------------------------------------------------------------------------
|
---|
313 |
|
---|
314 | class FlightSelectionPage(Page):
|
---|
315 | """The page to select the flight."""
|
---|
316 | def __init__(self, wizard):
|
---|
317 | """Construct the flight selection page."""
|
---|
318 | help = "Select the flight you want to perform."
|
---|
319 | completedHelp = "You have selected the flight highlighted below."
|
---|
320 | super(FlightSelectionPage, self).__init__(wizard, "Flight selection",
|
---|
321 | help, completedHelp = completedHelp)
|
---|
322 |
|
---|
323 |
|
---|
324 | self._listStore = gtk.ListStore(str, str, str, str)
|
---|
325 | self._flightList = gtk.TreeView(self._listStore)
|
---|
326 | column = gtk.TreeViewColumn("Flight no.", gtk.CellRendererText(),
|
---|
327 | text = 1)
|
---|
328 | column.set_expand(True)
|
---|
329 | self._flightList.append_column(column)
|
---|
330 | column = gtk.TreeViewColumn("Departure time [UTC]", gtk.CellRendererText(),
|
---|
331 | text = 0)
|
---|
332 | column.set_expand(True)
|
---|
333 | self._flightList.append_column(column)
|
---|
334 | column = gtk.TreeViewColumn("From", gtk.CellRendererText(),
|
---|
335 | text = 2)
|
---|
336 | column.set_expand(True)
|
---|
337 | self._flightList.append_column(column)
|
---|
338 | column = gtk.TreeViewColumn("To", gtk.CellRendererText(),
|
---|
339 | text = 3)
|
---|
340 | column.set_expand(True)
|
---|
341 | self._flightList.append_column(column)
|
---|
342 |
|
---|
343 | flightSelection = self._flightList.get_selection()
|
---|
344 | flightSelection.connect("changed", self._selectionChanged)
|
---|
345 |
|
---|
346 | scrolledWindow = gtk.ScrolledWindow()
|
---|
347 | scrolledWindow.add(self._flightList)
|
---|
348 | scrolledWindow.set_size_request(400, -1)
|
---|
349 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
350 | else gtk.POLICY_AUTOMATIC,
|
---|
351 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
352 | else gtk.POLICY_AUTOMATIC)
|
---|
353 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
354 | else gtk.SHADOW_IN)
|
---|
355 |
|
---|
356 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
357 | alignment.add(scrolledWindow)
|
---|
358 |
|
---|
359 | self.setMainWidget(alignment)
|
---|
360 |
|
---|
361 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
362 | self._button.set_use_stock(True)
|
---|
363 | self._button.set_sensitive(False)
|
---|
364 | self._button.connect("clicked", self._forwardClicked)
|
---|
365 |
|
---|
366 | def activate(self):
|
---|
367 | """Fill the flight list."""
|
---|
368 | self._flightList.set_sensitive(True)
|
---|
369 | self._listStore.clear()
|
---|
370 | for flight in self._wizard.loginResult.flights:
|
---|
371 | self._listStore.append([str(flight.departureTime),
|
---|
372 | flight.callsign,
|
---|
373 | flight.departureICAO,
|
---|
374 | flight.arrivalICAO])
|
---|
375 |
|
---|
376 | def finalize(self):
|
---|
377 | """Finalize the page."""
|
---|
378 | self._flightList.set_sensitive(False)
|
---|
379 |
|
---|
380 | def _selectionChanged(self, selection):
|
---|
381 | """Called when the selection is changed."""
|
---|
382 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
383 |
|
---|
384 | def _forwardClicked(self, button):
|
---|
385 | """Called when the forward button was clicked."""
|
---|
386 | if self._completed:
|
---|
387 | self._wizard.jumpPage(self._nextDistance, finalize = False)
|
---|
388 | else:
|
---|
389 | selection = self._flightList.get_selection()
|
---|
390 | (listStore, iter) = selection.get_selected()
|
---|
391 | path = listStore.get_path(iter)
|
---|
392 | [index] = path.get_indices() if pygobject else path
|
---|
393 |
|
---|
394 | flight = self._wizard.loginResult.flights[index]
|
---|
395 | self._wizard._bookedFlight = flight
|
---|
396 | # FIXME: with PyGObject this call causes error messages to
|
---|
397 | # appear on the standard output
|
---|
398 | self._wizard.gui.enableFlightInfo()
|
---|
399 |
|
---|
400 | self._updateDepartureGate()
|
---|
401 |
|
---|
402 | def _updateDepartureGate(self):
|
---|
403 | """Update the departure gate for the booked flight."""
|
---|
404 | flight = self._wizard._bookedFlight
|
---|
405 | if flight.departureICAO=="LHBP":
|
---|
406 | self._wizard._getFleet(self._fleetRetrieved)
|
---|
407 | else:
|
---|
408 | self._nextDistance = 2
|
---|
409 | self._wizard.jumpPage(2)
|
---|
410 |
|
---|
411 | def _fleetRetrieved(self, fleet):
|
---|
412 | """Called when the fleet has been retrieved."""
|
---|
413 | if fleet is None:
|
---|
414 | self._nextDistance = 2
|
---|
415 | self._wizard.jumpPage(2)
|
---|
416 | else:
|
---|
417 | plane = fleet[self._wizard._bookedFlight.tailNumber]
|
---|
418 | if plane is None:
|
---|
419 | self._nextDistance = 2
|
---|
420 | self._wizard.jumpPage(2)
|
---|
421 | elif plane.gateNumber is not None and \
|
---|
422 | not fleet.isGateConflicting(plane):
|
---|
423 | self._wizard._departureGate = plane.gateNumber
|
---|
424 | self._nextDistance = 2
|
---|
425 | self._wizard.jumpPage(2)
|
---|
426 | else:
|
---|
427 | self._nextDistance = 1
|
---|
428 | self._wizard.nextPage()
|
---|
429 |
|
---|
430 | #-----------------------------------------------------------------------------
|
---|
431 |
|
---|
432 | class GateSelectionPage(Page):
|
---|
433 | """Page to select a free gate at LHBP.
|
---|
434 |
|
---|
435 | This page should be displayed only if we have fleet information!."""
|
---|
436 | def __init__(self, wizard):
|
---|
437 | """Construct the gate selection page."""
|
---|
438 | help = "The airplane's gate position is invalid.\n\n" \
|
---|
439 | "Select the gate from which you\n" \
|
---|
440 | "would like to begin the flight."
|
---|
441 | super(GateSelectionPage, self).__init__(wizard,
|
---|
442 | "LHBP gate selection",
|
---|
443 | help)
|
---|
444 |
|
---|
445 | self._listStore = gtk.ListStore(str)
|
---|
446 | self._gateList = gtk.TreeView(self._listStore)
|
---|
447 | column = gtk.TreeViewColumn(None, gtk.CellRendererText(),
|
---|
448 | text = 0)
|
---|
449 | column.set_expand(True)
|
---|
450 | self._gateList.append_column(column)
|
---|
451 | self._gateList.set_headers_visible(False)
|
---|
452 |
|
---|
453 | gateSelection = self._gateList.get_selection()
|
---|
454 | gateSelection.connect("changed", self._selectionChanged)
|
---|
455 |
|
---|
456 | scrolledWindow = gtk.ScrolledWindow()
|
---|
457 | scrolledWindow.add(self._gateList)
|
---|
458 | scrolledWindow.set_size_request(50, -1)
|
---|
459 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
460 | else gtk.POLICY_AUTOMATIC,
|
---|
461 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
462 | else gtk.POLICY_AUTOMATIC)
|
---|
463 | scrolledWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
464 | else gtk.SHADOW_IN)
|
---|
465 |
|
---|
466 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0, xscale = 0.0, yscale = 1.0)
|
---|
467 | alignment.add(scrolledWindow)
|
---|
468 |
|
---|
469 | self.setMainWidget(alignment)
|
---|
470 |
|
---|
471 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
472 | button.set_use_stock(True)
|
---|
473 | button.connect("clicked", self._backClicked)
|
---|
474 |
|
---|
475 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
476 | self._button.set_use_stock(True)
|
---|
477 | self._button.set_sensitive(False)
|
---|
478 | self._button.connect("clicked", self._forwardClicked)
|
---|
479 |
|
---|
480 | def activate(self):
|
---|
481 | """Fill the gate list."""
|
---|
482 | self._listStore.clear()
|
---|
483 | self._gateList.set_sensitive(True)
|
---|
484 | occupiedGateNumbers = self._wizard._fleet.getOccupiedGateNumbers()
|
---|
485 | for gateNumber in const.lhbpGateNumbers:
|
---|
486 | if gateNumber not in occupiedGateNumbers:
|
---|
487 | self._listStore.append([gateNumber])
|
---|
488 |
|
---|
489 | def finalize(self):
|
---|
490 | """Finalize the page."""
|
---|
491 | self._gateList.set_sensitive(False)
|
---|
492 |
|
---|
493 | def _selectionChanged(self, selection):
|
---|
494 | """Called when the selection is changed."""
|
---|
495 | self._button.set_sensitive(selection.count_selected_rows()==1)
|
---|
496 |
|
---|
497 | def _backClicked(self, button):
|
---|
498 | """Called when the Back button is pressed."""
|
---|
499 | self.goBack()
|
---|
500 |
|
---|
501 | def _forwardClicked(self, button):
|
---|
502 | """Called when the forward button is clicked."""
|
---|
503 | if not self._completed:
|
---|
504 | selection = self._gateList.get_selection()
|
---|
505 | (listStore, iter) = selection.get_selected()
|
---|
506 | (gateNumber,) = listStore.get(iter, 0)
|
---|
507 |
|
---|
508 | self._wizard._departureGate = gateNumber
|
---|
509 |
|
---|
510 | #self._wizard._updatePlane(self._planeUpdated,
|
---|
511 | # self._wizard._bookedFlight.tailNumber,
|
---|
512 | # const.PLANE_HOME,
|
---|
513 | # gateNumber)
|
---|
514 |
|
---|
515 | self._wizard.nextPage()
|
---|
516 |
|
---|
517 | def _planeUpdated(self, success):
|
---|
518 | """Callback for the plane updating call."""
|
---|
519 | if success is None or success:
|
---|
520 | self._wizard.nextPage()
|
---|
521 | else:
|
---|
522 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
523 | type = MESSAGETYPE_ERROR,
|
---|
524 | buttons = BUTTONSTYPE_OK,
|
---|
525 | message_format = "Gate conflict detected again")
|
---|
526 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
527 | dialog.format_secondary_markup("Try to select a different gate.")
|
---|
528 | dialog.run()
|
---|
529 | dialog.hide()
|
---|
530 |
|
---|
531 | self._wizard._getFleet(self._fleetRetrieved)
|
---|
532 |
|
---|
533 | def _fleetRetrieved(self, fleet):
|
---|
534 | """Called when the fleet has been retrieved."""
|
---|
535 | if fleet is None:
|
---|
536 | self._wizard.nextPage()
|
---|
537 | else:
|
---|
538 | self.activate()
|
---|
539 |
|
---|
540 | #-----------------------------------------------------------------------------
|
---|
541 |
|
---|
542 | class ConnectPage(Page):
|
---|
543 | """Page which displays the departure airport and gate (if at LHBP)."""
|
---|
544 | def __init__(self, wizard):
|
---|
545 | """Construct the connect page."""
|
---|
546 | help = "Load the aircraft below into the simulator and park it\n" \
|
---|
547 | "at the given airport, at the gate below, if present.\n\n" \
|
---|
548 | "Then press the Connect button to connect to the simulator."
|
---|
549 | completedHelp = "The basic data of your flight can be read below."
|
---|
550 | super(ConnectPage, self).__init__(wizard,
|
---|
551 | "Connect to the simulator",
|
---|
552 | help, completedHelp = completedHelp)
|
---|
553 |
|
---|
554 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
555 | xscale = 0.0, yscale = 0.0)
|
---|
556 |
|
---|
557 | table = gtk.Table(5, 2)
|
---|
558 | table.set_row_spacings(4)
|
---|
559 | table.set_col_spacings(16)
|
---|
560 | table.set_homogeneous(True)
|
---|
561 | alignment.add(table)
|
---|
562 | self.setMainWidget(alignment)
|
---|
563 |
|
---|
564 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
565 | label = gtk.Label("Flight number:")
|
---|
566 | labelAlignment.add(label)
|
---|
567 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
568 |
|
---|
569 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
570 | self._flightNumber = gtk.Label()
|
---|
571 | self._flightNumber.set_width_chars(7)
|
---|
572 | self._flightNumber.set_alignment(0.0, 0.5)
|
---|
573 | labelAlignment.add(self._flightNumber)
|
---|
574 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
575 |
|
---|
576 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
577 | label = gtk.Label("Aircraft:")
|
---|
578 | labelAlignment.add(label)
|
---|
579 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
580 |
|
---|
581 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
582 | self._aircraft = gtk.Label()
|
---|
583 | self._aircraft.set_width_chars(25)
|
---|
584 | self._aircraft.set_alignment(0.0, 0.5)
|
---|
585 | labelAlignment.add(self._aircraft)
|
---|
586 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
587 |
|
---|
588 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
589 | label = gtk.Label("Tail number:")
|
---|
590 | labelAlignment.add(label)
|
---|
591 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
592 |
|
---|
593 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
594 | self._tailNumber = gtk.Label()
|
---|
595 | self._tailNumber.set_width_chars(10)
|
---|
596 | self._tailNumber.set_alignment(0.0, 0.5)
|
---|
597 | labelAlignment.add(self._tailNumber)
|
---|
598 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
599 |
|
---|
600 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
601 | label = gtk.Label("Airport:")
|
---|
602 | labelAlignment.add(label)
|
---|
603 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
604 |
|
---|
605 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
606 | self._departureICAO = gtk.Label()
|
---|
607 | self._departureICAO.set_width_chars(6)
|
---|
608 | self._departureICAO.set_alignment(0.0, 0.5)
|
---|
609 | labelAlignment.add(self._departureICAO)
|
---|
610 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
611 |
|
---|
612 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
613 | label = gtk.Label("Gate:")
|
---|
614 | labelAlignment.add(label)
|
---|
615 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
616 |
|
---|
617 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
618 | self._departureGate = gtk.Label()
|
---|
619 | self._departureGate.set_width_chars(5)
|
---|
620 | self._departureGate.set_alignment(0.0, 0.5)
|
---|
621 | labelAlignment.add(self._departureGate)
|
---|
622 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
623 |
|
---|
624 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
625 | button.set_use_stock(True)
|
---|
626 | button.connect("clicked", self._backClicked)
|
---|
627 |
|
---|
628 | self._button = self.addButton("_Connect", default = True)
|
---|
629 | self._button.set_use_underline(True)
|
---|
630 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
631 |
|
---|
632 | def activate(self):
|
---|
633 | """Setup the departure information."""
|
---|
634 | self._button.set_label("_Connect")
|
---|
635 | self._button.set_use_underline(True)
|
---|
636 | self._button.disconnect(self._clickedID)
|
---|
637 | self._clickedID = self._button.connect("clicked", self._connectClicked)
|
---|
638 |
|
---|
639 | bookedFlight = self._wizard._bookedFlight
|
---|
640 |
|
---|
641 | self._flightNumber.set_markup("<b>" + bookedFlight.callsign + "</b>")
|
---|
642 |
|
---|
643 | aircraftType = acftTypeNames[bookedFlight.aircraftType]
|
---|
644 | self._aircraft.set_markup("<b>" + aircraftType + "</b>")
|
---|
645 |
|
---|
646 | self._tailNumber.set_markup("<b>" + bookedFlight.tailNumber + "</b>")
|
---|
647 |
|
---|
648 | icao = bookedFlight.departureICAO
|
---|
649 | self._departureICAO.set_markup("<b>" + icao + "</b>")
|
---|
650 | gate = self._wizard._departureGate
|
---|
651 | if gate!="-":
|
---|
652 | gate = "<b>" + gate + "</b>"
|
---|
653 | self._departureGate.set_markup(gate)
|
---|
654 |
|
---|
655 | def finalize(self):
|
---|
656 | """Finalize the page."""
|
---|
657 | self._button.set_label(gtk.STOCK_GO_FORWARD)
|
---|
658 | self._button.set_use_stock(True)
|
---|
659 | self._button.disconnect(self._clickedID)
|
---|
660 | self._clickedID = self._button.connect("clicked", self._forwardClicked)
|
---|
661 |
|
---|
662 | def _backClicked(self, button):
|
---|
663 | """Called when the Back button is pressed."""
|
---|
664 | self.goBack()
|
---|
665 |
|
---|
666 | def _connectClicked(self, button):
|
---|
667 | """Called when the Connect button is pressed."""
|
---|
668 | self._wizard._connectSimulator()
|
---|
669 |
|
---|
670 | def _forwardClicked(self, button):
|
---|
671 | """Called when the Forward button is pressed."""
|
---|
672 | self._wizard.nextPage()
|
---|
673 |
|
---|
674 | #-----------------------------------------------------------------------------
|
---|
675 |
|
---|
676 | class PayloadPage(Page):
|
---|
677 | """Page to allow setting up the payload."""
|
---|
678 | def __init__(self, wizard):
|
---|
679 | """Construct the page."""
|
---|
680 | help = "The briefing contains the weights below.\n" \
|
---|
681 | "Setup the cargo weight here and the payload weight in the simulator.\n\n" \
|
---|
682 | "You can also check here what the simulator reports as ZFW."
|
---|
683 | completedHelp = "You can see the weights in the briefing\n" \
|
---|
684 | "and the cargo weight you have selected below.\n\n" \
|
---|
685 | "You can also query the ZFW reported by the simulator."
|
---|
686 | super(PayloadPage, self).__init__(wizard, "Payload", help,
|
---|
687 | completedHelp = completedHelp)
|
---|
688 |
|
---|
689 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
690 | xscale = 0.0, yscale = 0.0)
|
---|
691 |
|
---|
692 | table = gtk.Table(7, 3)
|
---|
693 | table.set_row_spacings(4)
|
---|
694 | table.set_col_spacings(16)
|
---|
695 | table.set_homogeneous(False)
|
---|
696 | alignment.add(table)
|
---|
697 | self.setMainWidget(alignment)
|
---|
698 |
|
---|
699 | label = gtk.Label("Crew:")
|
---|
700 | label.set_alignment(0.0, 0.5)
|
---|
701 | table.attach(label, 0, 1, 0, 1)
|
---|
702 |
|
---|
703 | self._numCrew = gtk.Label()
|
---|
704 | self._numCrew.set_width_chars(6)
|
---|
705 | self._numCrew.set_alignment(1.0, 0.5)
|
---|
706 | table.attach(self._numCrew, 1, 2, 0, 1)
|
---|
707 |
|
---|
708 | label = gtk.Label("Passengers:")
|
---|
709 | label.set_alignment(0.0, 0.5)
|
---|
710 | table.attach(label, 0, 1, 1, 2)
|
---|
711 |
|
---|
712 | self._numPassengers = gtk.Label()
|
---|
713 | self._numPassengers.set_width_chars(6)
|
---|
714 | self._numPassengers.set_alignment(1.0, 0.5)
|
---|
715 | table.attach(self._numPassengers, 1, 2, 1, 2)
|
---|
716 |
|
---|
717 | label = gtk.Label("Baggage:")
|
---|
718 | label.set_alignment(0.0, 0.5)
|
---|
719 | table.attach(label, 0, 1, 2, 3)
|
---|
720 |
|
---|
721 | self._bagWeight = gtk.Label()
|
---|
722 | self._bagWeight.set_width_chars(6)
|
---|
723 | self._bagWeight.set_alignment(1.0, 0.5)
|
---|
724 | table.attach(self._bagWeight, 1, 2, 2, 3)
|
---|
725 |
|
---|
726 | table.attach(gtk.Label("kg"), 2, 3, 2, 3)
|
---|
727 |
|
---|
728 | label = gtk.Label("_Cargo:")
|
---|
729 | label.set_use_underline(True)
|
---|
730 | label.set_alignment(0.0, 0.5)
|
---|
731 | table.attach(label, 0, 1, 3, 4)
|
---|
732 |
|
---|
733 | self._cargoWeight = IntegerEntry(defaultValue = 0)
|
---|
734 | self._cargoWeight.set_width_chars(6)
|
---|
735 | self._cargoWeight.connect("integer-changed", self._cargoWeightChanged)
|
---|
736 | self._cargoWeight.set_tooltip_text("The weight of the cargo for your flight.")
|
---|
737 | table.attach(self._cargoWeight, 1, 2, 3, 4)
|
---|
738 | label.set_mnemonic_widget(self._cargoWeight)
|
---|
739 |
|
---|
740 | table.attach(gtk.Label("kg"), 2, 3, 3, 4)
|
---|
741 |
|
---|
742 | label = gtk.Label("Mail:")
|
---|
743 | label.set_alignment(0.0, 0.5)
|
---|
744 | table.attach(label, 0, 1, 4, 5)
|
---|
745 |
|
---|
746 | self._mailWeight = gtk.Label()
|
---|
747 | self._mailWeight.set_width_chars(6)
|
---|
748 | self._mailWeight.set_alignment(1.0, 0.5)
|
---|
749 | table.attach(self._mailWeight, 1, 2, 4, 5)
|
---|
750 |
|
---|
751 | table.attach(gtk.Label("kg"), 2, 3, 4, 5)
|
---|
752 |
|
---|
753 | label = gtk.Label("<b>Calculated ZFW:</b>")
|
---|
754 | label.set_alignment(0.0, 0.5)
|
---|
755 | label.set_use_markup(True)
|
---|
756 | table.attach(label, 0, 1, 5, 6)
|
---|
757 |
|
---|
758 | self._calculatedZFW = gtk.Label()
|
---|
759 | self._calculatedZFW.set_width_chars(6)
|
---|
760 | self._calculatedZFW.set_alignment(1.0, 0.5)
|
---|
761 | table.attach(self._calculatedZFW, 1, 2, 5, 6)
|
---|
762 |
|
---|
763 | table.attach(gtk.Label("kg"), 2, 3, 5, 6)
|
---|
764 |
|
---|
765 | self._zfwButton = gtk.Button("_ZFW from FS:")
|
---|
766 | self._zfwButton.set_use_underline(True)
|
---|
767 | self._zfwButton.connect("clicked", self._zfwRequested)
|
---|
768 | table.attach(self._zfwButton, 0, 1, 6, 7)
|
---|
769 |
|
---|
770 | self._simulatorZFW = gtk.Label("-")
|
---|
771 | self._simulatorZFW.set_width_chars(6)
|
---|
772 | self._simulatorZFW.set_alignment(1.0, 0.5)
|
---|
773 | table.attach(self._simulatorZFW, 1, 2, 6, 7)
|
---|
774 | self._simulatorZFWValue = None
|
---|
775 |
|
---|
776 | table.attach(gtk.Label("kg"), 2, 3, 6, 7)
|
---|
777 |
|
---|
778 | self._backButton = self.addButton(gtk.STOCK_GO_BACK)
|
---|
779 | self._backButton.set_use_stock(True)
|
---|
780 | self._backButton.connect("clicked", self._backClicked)
|
---|
781 |
|
---|
782 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
783 | self._button.set_use_stock(True)
|
---|
784 | self._button.connect("clicked", self._forwardClicked)
|
---|
785 |
|
---|
786 | @property
|
---|
787 | def cargoWeight(self):
|
---|
788 | """Get the cargo weight entered."""
|
---|
789 | return self._cargoWeight.get_int()
|
---|
790 |
|
---|
791 | def activate(self):
|
---|
792 | """Setup the information."""
|
---|
793 | bookedFlight = self._wizard._bookedFlight
|
---|
794 | self._numCrew.set_text(str(bookedFlight.numCrew))
|
---|
795 | self._numPassengers.set_text(str(bookedFlight.numPassengers))
|
---|
796 | self._bagWeight.set_text(str(bookedFlight.bagWeight))
|
---|
797 | self._cargoWeight.set_int(bookedFlight.cargoWeight)
|
---|
798 | self._cargoWeight.set_sensitive(True)
|
---|
799 | self._mailWeight.set_text(str(bookedFlight.mailWeight))
|
---|
800 | self._simulatorZFW.set_text("-")
|
---|
801 | self._simulatorZFWValue = None
|
---|
802 | self._zfwButton.set_sensitive(True)
|
---|
803 | self._updateCalculatedZFW()
|
---|
804 |
|
---|
805 | def finalize(self):
|
---|
806 | """Finalize the payload page."""
|
---|
807 | self._cargoWeight.set_sensitive(False)
|
---|
808 |
|
---|
809 | def calculateZFW(self):
|
---|
810 | """Calculate the ZFW value."""
|
---|
811 | zfw = self._wizard.gui._flight.aircraft.dow
|
---|
812 | bookedFlight = self._wizard._bookedFlight
|
---|
813 | zfw += (bookedFlight.numCrew + bookedFlight.numPassengers) * 82
|
---|
814 | zfw += bookedFlight.bagWeight
|
---|
815 | zfw += self._cargoWeight.get_int()
|
---|
816 | zfw += bookedFlight.mailWeight
|
---|
817 | return zfw
|
---|
818 |
|
---|
819 | def _updateCalculatedZFW(self):
|
---|
820 | """Update the calculated ZFW"""
|
---|
821 | zfw = self.calculateZFW()
|
---|
822 |
|
---|
823 | markupBegin = "<b>"
|
---|
824 | markupEnd = "</b>"
|
---|
825 | if self._simulatorZFWValue is not None and \
|
---|
826 | PayloadChecker.isZFWFaulty(self._simulatorZFWValue, zfw):
|
---|
827 | markupBegin += '<span foreground="red">'
|
---|
828 | markupEnd = "</span>" + markupEnd
|
---|
829 | self._calculatedZFW.set_markup(markupBegin + str(zfw) + markupEnd)
|
---|
830 |
|
---|
831 | def _cargoWeightChanged(self, entry, weight):
|
---|
832 | """Called when the cargo weight has changed."""
|
---|
833 | self._updateCalculatedZFW()
|
---|
834 |
|
---|
835 | def _zfwRequested(self, button):
|
---|
836 | """Called when the ZFW is requested from the simulator."""
|
---|
837 | self._zfwButton.set_sensitive(False)
|
---|
838 | self._backButton.set_sensitive(False)
|
---|
839 | self._button.set_sensitive(False)
|
---|
840 | gui = self._wizard.gui
|
---|
841 | gui.beginBusy("Querying ZFW...")
|
---|
842 | gui.simulator.requestZFW(self._handleZFW)
|
---|
843 |
|
---|
844 | def _handleZFW(self, zfw):
|
---|
845 | """Called when the ZFW value is retrieved."""
|
---|
846 | gobject.idle_add(self._processZFW, zfw)
|
---|
847 |
|
---|
848 | def _processZFW(self, zfw):
|
---|
849 | """Process the given ZFW value received from the simulator."""
|
---|
850 | self._wizard.gui.endBusy()
|
---|
851 | self._zfwButton.set_sensitive(True)
|
---|
852 | self._backButton.set_sensitive(True)
|
---|
853 | self._button.set_sensitive(True)
|
---|
854 | self._simulatorZFWValue = zfw
|
---|
855 | self._simulatorZFW.set_text("%.0f" % (zfw,))
|
---|
856 | self._updateCalculatedZFW()
|
---|
857 |
|
---|
858 | def _forwardClicked(self, button):
|
---|
859 | """Called when the forward button is clicked."""
|
---|
860 | self._wizard.nextPage()
|
---|
861 |
|
---|
862 | def _backClicked(self, button):
|
---|
863 | """Called when the Back button is pressed."""
|
---|
864 | self.goBack()
|
---|
865 |
|
---|
866 | #-----------------------------------------------------------------------------
|
---|
867 |
|
---|
868 | class TimePage(Page):
|
---|
869 | """Page displaying the departure and arrival times and allows querying the
|
---|
870 | current time from the flight simulator."""
|
---|
871 | def __init__(self, wizard):
|
---|
872 | help = "The departure and arrival times are displayed below in UTC.\n\n" \
|
---|
873 | "You can also query the current UTC time from the simulator.\n" \
|
---|
874 | "Ensure that you have enough time to properly prepare for the flight."
|
---|
875 | completedHelp = "The departure and arrival times are displayed below in UTC.\n\n" \
|
---|
876 | "You can also query the current UTC time from the simulator.\n"
|
---|
877 | super(TimePage, self).__init__(wizard, "Time", help,
|
---|
878 | completedHelp = completedHelp)
|
---|
879 |
|
---|
880 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
881 | xscale = 0.0, yscale = 0.0)
|
---|
882 |
|
---|
883 | table = gtk.Table(3, 2)
|
---|
884 | table.set_row_spacings(4)
|
---|
885 | table.set_col_spacings(16)
|
---|
886 | table.set_homogeneous(False)
|
---|
887 | alignment.add(table)
|
---|
888 | self.setMainWidget(alignment)
|
---|
889 |
|
---|
890 | label = gtk.Label("Departure:")
|
---|
891 | label.set_alignment(0.0, 0.5)
|
---|
892 | table.attach(label, 0, 1, 0, 1)
|
---|
893 |
|
---|
894 | self._departure = gtk.Label()
|
---|
895 | self._departure.set_alignment(0.0, 0.5)
|
---|
896 | table.attach(self._departure, 1, 2, 0, 1)
|
---|
897 |
|
---|
898 | label = gtk.Label("Arrival:")
|
---|
899 | label.set_alignment(0.0, 0.5)
|
---|
900 | table.attach(label, 0, 1, 1, 2)
|
---|
901 |
|
---|
902 | self._arrival = gtk.Label()
|
---|
903 | self._arrival.set_alignment(0.0, 0.5)
|
---|
904 | table.attach(self._arrival, 1, 2, 1, 2)
|
---|
905 |
|
---|
906 | self._timeButton = gtk.Button("_Time from FS:")
|
---|
907 | self._timeButton.set_use_underline(True)
|
---|
908 | self._timeButton.connect("clicked", self._timeRequested)
|
---|
909 | table.attach(self._timeButton, 0, 1, 2, 3)
|
---|
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 |
|
---|
915 | self._backButton = self.addButton(gtk.STOCK_GO_BACK)
|
---|
916 | self._backButton.set_use_stock(True)
|
---|
917 | self._backButton.connect("clicked", self._backClicked)
|
---|
918 |
|
---|
919 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
920 | self._button.set_use_stock(True)
|
---|
921 | self._button.connect("clicked", self._forwardClicked)
|
---|
922 |
|
---|
923 | def activate(self):
|
---|
924 | """Activate the page."""
|
---|
925 | self._timeButton.set_sensitive(True)
|
---|
926 | bookedFlight = self._wizard._bookedFlight
|
---|
927 | self._departure.set_text(str(bookedFlight.departureTime.time()))
|
---|
928 | self._arrival.set_text(str(bookedFlight.arrivalTime.time()))
|
---|
929 | self._simulatorTime.set_text("-")
|
---|
930 |
|
---|
931 | def _timeRequested(self, button):
|
---|
932 | """Request the time from the simulator."""
|
---|
933 | self._timeButton.set_sensitive(False)
|
---|
934 | self._backButton.set_sensitive(False)
|
---|
935 | self._button.set_sensitive(False)
|
---|
936 | self._wizard.gui.beginBusy("Querying time...")
|
---|
937 | self._wizard.gui.simulator.requestTime(self._handleTime)
|
---|
938 |
|
---|
939 | def _handleTime(self, timestamp):
|
---|
940 | """Handle the result of a time retrieval."""
|
---|
941 | gobject.idle_add(self._processTime, timestamp)
|
---|
942 |
|
---|
943 | def _processTime(self, timestamp):
|
---|
944 | """Process the given time."""
|
---|
945 | self._wizard.gui.endBusy()
|
---|
946 | self._timeButton.set_sensitive(True)
|
---|
947 | self._backButton.set_sensitive(True)
|
---|
948 | self._button.set_sensitive(True)
|
---|
949 | tm = time.gmtime(timestamp)
|
---|
950 | t = datetime.time(tm.tm_hour, tm.tm_min, tm.tm_sec)
|
---|
951 | self._simulatorTime.set_text(str(t))
|
---|
952 |
|
---|
953 | ts = tm.tm_hour * 3600 + tm.tm_min * 60 + tm.tm_sec
|
---|
954 | dt = self._wizard._bookedFlight.departureTime.time()
|
---|
955 | dts = dt.hour * 3600 + dt.minute * 60 + dt.second
|
---|
956 | diff = dts-ts
|
---|
957 |
|
---|
958 | markupBegin = ""
|
---|
959 | markupEnd = ""
|
---|
960 | if diff < 0:
|
---|
961 | markupBegin = '<b><span foreground="red">'
|
---|
962 | markupEnd = '</span></b>'
|
---|
963 | elif diff < 3*60 or diff > 30*60:
|
---|
964 | markupBegin = '<b><span foreground="orange">'
|
---|
965 | markupEnd = '</span></b>'
|
---|
966 |
|
---|
967 | self._departure.set_markup(markupBegin + str(dt) + markupEnd)
|
---|
968 |
|
---|
969 | def _backClicked(self, button):
|
---|
970 | """Called when the Back button is pressed."""
|
---|
971 | self.goBack()
|
---|
972 |
|
---|
973 | def _forwardClicked(self, button):
|
---|
974 | """Called when the forward button is clicked."""
|
---|
975 | self._wizard.nextPage()
|
---|
976 |
|
---|
977 | #-----------------------------------------------------------------------------
|
---|
978 |
|
---|
979 | class RoutePage(Page):
|
---|
980 | """The page containing the route and the flight level."""
|
---|
981 | def __init__(self, wizard):
|
---|
982 | help = "Set your cruise flight level below, and\n" \
|
---|
983 | "if necessary, edit the flight plan."
|
---|
984 | completedHelp = "If necessary, you can modify the cruise level and\n" \
|
---|
985 | "the flight plan below during flight.\n" \
|
---|
986 | "If so, please, add a comment on why " \
|
---|
987 | "the modification became necessary."
|
---|
988 | super(RoutePage, self).__init__(wizard, "Route", help,
|
---|
989 | completedHelp = completedHelp)
|
---|
990 |
|
---|
991 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
992 | xscale = 0.0, yscale = 0.0)
|
---|
993 |
|
---|
994 | mainBox = gtk.VBox()
|
---|
995 | alignment.add(mainBox)
|
---|
996 | self.setMainWidget(alignment)
|
---|
997 |
|
---|
998 | levelBox = gtk.HBox()
|
---|
999 |
|
---|
1000 | label = gtk.Label("_Cruise level")
|
---|
1001 | label.set_use_underline(True)
|
---|
1002 | levelBox.pack_start(label, True, True, 0)
|
---|
1003 |
|
---|
1004 | self._cruiseLevel = gtk.SpinButton()
|
---|
1005 | self._cruiseLevel.set_increments(step = 10, page = 100)
|
---|
1006 | self._cruiseLevel.set_range(min = 50, max = 500)
|
---|
1007 | self._cruiseLevel.set_tooltip_text("The cruise flight level.")
|
---|
1008 | self._cruiseLevel.set_numeric(True)
|
---|
1009 | self._cruiseLevel.connect("value-changed", self._cruiseLevelChanged)
|
---|
1010 | label.set_mnemonic_widget(self._cruiseLevel)
|
---|
1011 | self._filedCruiseLevel = 240
|
---|
1012 |
|
---|
1013 | levelBox.pack_start(self._cruiseLevel, False, False, 8)
|
---|
1014 |
|
---|
1015 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
1016 | xscale = 0.0, yscale = 0.0)
|
---|
1017 | alignment.add(levelBox)
|
---|
1018 |
|
---|
1019 | mainBox.pack_start(alignment, False, False, 0)
|
---|
1020 |
|
---|
1021 |
|
---|
1022 | routeBox = gtk.VBox()
|
---|
1023 |
|
---|
1024 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.5,
|
---|
1025 | xscale = 0.0, yscale = 0.0)
|
---|
1026 | label = gtk.Label("_Route")
|
---|
1027 | label.set_use_underline(True)
|
---|
1028 | alignment.add(label)
|
---|
1029 | routeBox.pack_start(alignment, True, True, 0)
|
---|
1030 |
|
---|
1031 | routeWindow = gtk.ScrolledWindow()
|
---|
1032 | routeWindow.set_size_request(400, 80)
|
---|
1033 | routeWindow.set_shadow_type(gtk.ShadowType.IN if pygobject
|
---|
1034 | else gtk.SHADOW_IN)
|
---|
1035 | routeWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
1036 | else gtk.POLICY_AUTOMATIC,
|
---|
1037 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
1038 | else gtk.POLICY_AUTOMATIC)
|
---|
1039 |
|
---|
1040 | self._route = gtk.TextView()
|
---|
1041 | self._route.set_tooltip_text("The planned flight route.")
|
---|
1042 | self._route.get_buffer().connect("changed", self._routeChanged)
|
---|
1043 | routeWindow.add(self._route)
|
---|
1044 |
|
---|
1045 | label.set_mnemonic_widget(self._route)
|
---|
1046 | routeBox.pack_start(routeWindow, True, True, 0)
|
---|
1047 |
|
---|
1048 | mainBox.pack_start(routeBox, True, True, 8)
|
---|
1049 |
|
---|
1050 | self._backButton = self.addButton(gtk.STOCK_GO_BACK)
|
---|
1051 | self._backButton.set_use_stock(True)
|
---|
1052 | self._backButton.connect("clicked", self._backClicked)
|
---|
1053 |
|
---|
1054 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
1055 | self._button.set_use_stock(True)
|
---|
1056 | self._button.connect("clicked", self._forwardClicked)
|
---|
1057 |
|
---|
1058 | @property
|
---|
1059 | def filedCruiseLevel(self):
|
---|
1060 | """Get the filed cruise level."""
|
---|
1061 | return self._filedCruiseLevel
|
---|
1062 |
|
---|
1063 | @property
|
---|
1064 | def cruiseLevel(self):
|
---|
1065 | """Get the cruise level."""
|
---|
1066 | return self._cruiseLevel.get_value_as_int()
|
---|
1067 |
|
---|
1068 | @property
|
---|
1069 | def route(self):
|
---|
1070 | """Get the route."""
|
---|
1071 | return self._getRoute()
|
---|
1072 |
|
---|
1073 | def activate(self):
|
---|
1074 | """Setup the route from the booked flight."""
|
---|
1075 | self._cruiseLevel.set_value(240)
|
---|
1076 | self._filedCruiseLevel = 240
|
---|
1077 | self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
|
---|
1078 | self._updateForwardButton()
|
---|
1079 |
|
---|
1080 | def _getRoute(self):
|
---|
1081 | """Get the text of the route."""
|
---|
1082 | buffer = self._route.get_buffer()
|
---|
1083 | return buffer.get_text(buffer.get_start_iter(),
|
---|
1084 | buffer.get_end_iter(), True)
|
---|
1085 |
|
---|
1086 | def _updateForwardButton(self):
|
---|
1087 | """Update the sensitivity of the forward button."""
|
---|
1088 | self._button.set_sensitive(self._cruiseLevel.get_value_as_int()>=50 and \
|
---|
1089 | self._getRoute()!="")
|
---|
1090 |
|
---|
1091 | def _cruiseLevelChanged(self, spinButton):
|
---|
1092 | """Called when the cruise level has changed."""
|
---|
1093 | self._updateForwardButton()
|
---|
1094 |
|
---|
1095 | def _routeChanged(self, textBuffer):
|
---|
1096 | """Called when the route has changed."""
|
---|
1097 | self._updateForwardButton()
|
---|
1098 |
|
---|
1099 | def _backClicked(self, button):
|
---|
1100 | """Called when the Back button is pressed."""
|
---|
1101 | self.goBack()
|
---|
1102 |
|
---|
1103 | def _forwardClicked(self, button):
|
---|
1104 | """Called when the Forward button is clicked."""
|
---|
1105 | if self._completed:
|
---|
1106 | self._wizard.nextPage()
|
---|
1107 | else:
|
---|
1108 | bookedFlight = self._wizard._bookedFlight
|
---|
1109 | self._filedCruiseLevel = self.cruiseLevel
|
---|
1110 | self._wizard.gui.beginBusy("Downloading NOTAMs...")
|
---|
1111 | self._wizard.gui.webHandler.getNOTAMs(self._notamsCallback,
|
---|
1112 | bookedFlight.departureICAO,
|
---|
1113 | bookedFlight.arrivalICAO)
|
---|
1114 |
|
---|
1115 | def _notamsCallback(self, returned, result):
|
---|
1116 | """Callback for the NOTAMs."""
|
---|
1117 | gobject.idle_add(self._handleNOTAMs, returned, result)
|
---|
1118 |
|
---|
1119 | def _handleNOTAMs(self, returned, result):
|
---|
1120 | """Handle the NOTAMs."""
|
---|
1121 | if returned:
|
---|
1122 | self._wizard._departureNOTAMs = result.departureNOTAMs
|
---|
1123 | self._wizard._arrivalNOTAMs = result.arrivalNOTAMs
|
---|
1124 | else:
|
---|
1125 | self._wizard._departureNOTAMs = None
|
---|
1126 | self._wizard._arrivalNOTAMs = None
|
---|
1127 |
|
---|
1128 | bookedFlight = self._wizard._bookedFlight
|
---|
1129 | self._wizard.gui.beginBusy("Downloading METARs...")
|
---|
1130 | self._wizard.gui.webHandler.getMETARs(self._metarsCallback,
|
---|
1131 | [bookedFlight.departureICAO,
|
---|
1132 | bookedFlight.arrivalICAO])
|
---|
1133 |
|
---|
1134 | def _metarsCallback(self, returned, result):
|
---|
1135 | """Callback for the METARs."""
|
---|
1136 | gobject.idle_add(self._handleMETARs, returned, result)
|
---|
1137 |
|
---|
1138 | def _handleMETARs(self, returned, result):
|
---|
1139 | """Handle the METARs."""
|
---|
1140 | self._wizard._departureMETAR = None
|
---|
1141 | self._wizard._arrivalMETAR = None
|
---|
1142 | bookedFlight = self._wizard._bookedFlight
|
---|
1143 | if returned:
|
---|
1144 | if bookedFlight.departureICAO in result.metars:
|
---|
1145 | self._wizard._departureMETAR = result.metars[bookedFlight.departureICAO]
|
---|
1146 | if bookedFlight.arrivalICAO in result.metars:
|
---|
1147 | self._wizard._arrivalMETAR = result.metars[bookedFlight.arrivalICAO]
|
---|
1148 |
|
---|
1149 | self._wizard.gui.endBusy()
|
---|
1150 | self._backButton.set_sensitive(True)
|
---|
1151 | self._button.set_sensitive(True)
|
---|
1152 | self._wizard.nextPage()
|
---|
1153 |
|
---|
1154 | #-----------------------------------------------------------------------------
|
---|
1155 |
|
---|
1156 | class BriefingPage(Page):
|
---|
1157 | """Page for the briefing."""
|
---|
1158 | def __init__(self, wizard, departure):
|
---|
1159 | """Construct the briefing page."""
|
---|
1160 | self._departure = departure
|
---|
1161 |
|
---|
1162 | title = "Briefing (%d/2): %s" % (1 if departure else 2,
|
---|
1163 | "departure" if departure
|
---|
1164 | else "arrival")
|
---|
1165 |
|
---|
1166 | help = "Read carefully the NOTAMs and METAR below.\n\n" \
|
---|
1167 | "You can edit the METAR if your simulator or network\n" \
|
---|
1168 | "provides different weather."
|
---|
1169 | completedHelp = "If your simulator or network provides a different\n" \
|
---|
1170 | "weather, you can edit the METAR below."
|
---|
1171 | super(BriefingPage, self).__init__(wizard, title, help,
|
---|
1172 | completedHelp = completedHelp)
|
---|
1173 |
|
---|
1174 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
1175 | xscale = 1.0, yscale = 1.0)
|
---|
1176 |
|
---|
1177 | mainBox = gtk.VBox()
|
---|
1178 | alignment.add(mainBox)
|
---|
1179 | self.setMainWidget(alignment)
|
---|
1180 |
|
---|
1181 | self._notamsFrame = gtk.Frame()
|
---|
1182 | self._notamsFrame.set_label("LHBP NOTAMs")
|
---|
1183 | scrolledWindow = gtk.ScrolledWindow()
|
---|
1184 | scrolledWindow.set_size_request(-1, 128)
|
---|
1185 | # FIXME: these constants should be in common
|
---|
1186 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
1187 | else gtk.POLICY_AUTOMATIC,
|
---|
1188 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
1189 | else gtk.POLICY_AUTOMATIC)
|
---|
1190 | self._notams = gtk.TextView()
|
---|
1191 | self._notams.set_editable(False)
|
---|
1192 | self._notams.set_accepts_tab(False)
|
---|
1193 | self._notams.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
1194 | scrolledWindow.add(self._notams)
|
---|
1195 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
1196 | xscale = 1.0, yscale = 1.0)
|
---|
1197 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
1198 | padding_left = 0, padding_right = 0)
|
---|
1199 | alignment.add(scrolledWindow)
|
---|
1200 | self._notamsFrame.add(alignment)
|
---|
1201 | mainBox.pack_start(self._notamsFrame, True, True, 4)
|
---|
1202 |
|
---|
1203 | self._metarFrame = gtk.Frame()
|
---|
1204 | self._metarFrame.set_label("LHBP METAR")
|
---|
1205 | scrolledWindow = gtk.ScrolledWindow()
|
---|
1206 | scrolledWindow.set_size_request(-1, 32)
|
---|
1207 | scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
|
---|
1208 | else gtk.POLICY_AUTOMATIC,
|
---|
1209 | gtk.PolicyType.AUTOMATIC if pygobject
|
---|
1210 | else gtk.POLICY_AUTOMATIC)
|
---|
1211 | self._metar = gtk.TextView()
|
---|
1212 | self._metar.set_accepts_tab(False)
|
---|
1213 | self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
|
---|
1214 | scrolledWindow.add(self._metar)
|
---|
1215 | alignment = gtk.Alignment(xalign = 0.0, yalign = 0.0,
|
---|
1216 | xscale = 1.0, yscale = 1.0)
|
---|
1217 | alignment.set_padding(padding_top = 4, padding_bottom = 0,
|
---|
1218 | padding_left = 0, padding_right = 0)
|
---|
1219 | alignment.add(scrolledWindow)
|
---|
1220 | self._metarFrame.add(alignment)
|
---|
1221 | mainBox.pack_start(self._metarFrame, True, True, 4)
|
---|
1222 |
|
---|
1223 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
1224 | button.set_use_stock(True)
|
---|
1225 | button.connect("clicked", self._backClicked)
|
---|
1226 |
|
---|
1227 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
1228 | self._button.set_use_stock(True)
|
---|
1229 | self._button.connect("clicked", self._forwardClicked)
|
---|
1230 |
|
---|
1231 | @property
|
---|
1232 | def metar(self):
|
---|
1233 | """Get the METAR on the page."""
|
---|
1234 | buffer = self._metar.get_buffer()
|
---|
1235 | return buffer.get_text(buffer.get_start_iter(),
|
---|
1236 | buffer.get_end_iter(), True)
|
---|
1237 |
|
---|
1238 | def activate(self):
|
---|
1239 | """Activate the page."""
|
---|
1240 | if not self._departure:
|
---|
1241 | self._button.set_label("I have read the briefing and am ready to fly!")
|
---|
1242 | self._button.set_use_stock(False)
|
---|
1243 |
|
---|
1244 | bookedFlight = self._wizard._bookedFlight
|
---|
1245 |
|
---|
1246 | icao = bookedFlight.departureICAO if self._departure \
|
---|
1247 | else bookedFlight.arrivalICAO
|
---|
1248 | notams = self._wizard._departureNOTAMs if self._departure \
|
---|
1249 | else self._wizard._arrivalNOTAMs
|
---|
1250 | metar = self._wizard._departureMETAR if self._departure \
|
---|
1251 | else self._wizard._arrivalMETAR
|
---|
1252 |
|
---|
1253 | self._notamsFrame.set_label(icao + " NOTAMs")
|
---|
1254 | buffer = self._notams.get_buffer()
|
---|
1255 | if notams is None:
|
---|
1256 | buffer.set_text("Could not download NOTAMs")
|
---|
1257 | elif not notams:
|
---|
1258 | buffer.set_text("Could not download NOTAM for this airport")
|
---|
1259 | else:
|
---|
1260 | s = ""
|
---|
1261 | for notam in notams:
|
---|
1262 | s += str(notam.begin)
|
---|
1263 | if notam.end is not None:
|
---|
1264 | s += " - " + str(notam.end)
|
---|
1265 | elif notam.permanent:
|
---|
1266 | s += " - PERMANENT"
|
---|
1267 | s += "\n"
|
---|
1268 | if notam.repeatCycle:
|
---|
1269 | s += "Repeat cycle: " + notam.repeatCycle + "\n"
|
---|
1270 | s += notam.notice + "\n"
|
---|
1271 | s += "-------------------- * --------------------\n"
|
---|
1272 | buffer.set_text(s)
|
---|
1273 |
|
---|
1274 | self._metarFrame.set_label(icao + " METAR")
|
---|
1275 | buffer = self._metar.get_buffer()
|
---|
1276 | if metar is None:
|
---|
1277 | buffer.set_text("Could not download METAR")
|
---|
1278 | else:
|
---|
1279 | buffer.set_text(metar)
|
---|
1280 |
|
---|
1281 | def _backClicked(self, button):
|
---|
1282 | """Called when the Back button is pressed."""
|
---|
1283 | self.goBack()
|
---|
1284 |
|
---|
1285 | def _forwardClicked(self, button):
|
---|
1286 | """Called when the forward button is clicked."""
|
---|
1287 | if not self._departure:
|
---|
1288 | if not self._completed:
|
---|
1289 | self._wizard.gui.startMonitoring()
|
---|
1290 | self._button.set_use_stock(True)
|
---|
1291 | self._button.set_label(gtk.STOCK_GO_FORWARD)
|
---|
1292 | self.complete()
|
---|
1293 |
|
---|
1294 | self._wizard.nextPage()
|
---|
1295 |
|
---|
1296 | #-----------------------------------------------------------------------------
|
---|
1297 |
|
---|
1298 | class TakeoffPage(Page):
|
---|
1299 | """Page for entering the takeoff data."""
|
---|
1300 | def __init__(self, wizard):
|
---|
1301 | """Construct the takeoff page."""
|
---|
1302 | help = "Enter the runway and SID used, as well as the speeds."
|
---|
1303 | completedHelp = "The runway, SID and takeoff speeds logged can be seen below."
|
---|
1304 |
|
---|
1305 | super(TakeoffPage, self).__init__(wizard, "Takeoff", help,
|
---|
1306 | completedHelp = completedHelp)
|
---|
1307 |
|
---|
1308 | self._forwardAllowed = False
|
---|
1309 |
|
---|
1310 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
1311 | xscale = 0.0, yscale = 0.0)
|
---|
1312 |
|
---|
1313 | table = gtk.Table(5, 4)
|
---|
1314 | table.set_row_spacings(4)
|
---|
1315 | table.set_col_spacings(16)
|
---|
1316 | table.set_homogeneous(False)
|
---|
1317 | alignment.add(table)
|
---|
1318 | self.setMainWidget(alignment)
|
---|
1319 |
|
---|
1320 | label = gtk.Label("Run_way:")
|
---|
1321 | label.set_use_underline(True)
|
---|
1322 | label.set_alignment(0.0, 0.5)
|
---|
1323 | table.attach(label, 0, 1, 0, 1)
|
---|
1324 |
|
---|
1325 | self._runway = gtk.Entry()
|
---|
1326 | self._runway.set_width_chars(10)
|
---|
1327 | self._runway.set_tooltip_text("The runway the takeoff is performed from.")
|
---|
1328 | self._runway.connect("changed", self._valueChanged)
|
---|
1329 | table.attach(self._runway, 1, 3, 0, 1)
|
---|
1330 | label.set_mnemonic_widget(self._runway)
|
---|
1331 |
|
---|
1332 | label = gtk.Label("_SID:")
|
---|
1333 | label.set_use_underline(True)
|
---|
1334 | label.set_alignment(0.0, 0.5)
|
---|
1335 | table.attach(label, 0, 1, 1, 2)
|
---|
1336 |
|
---|
1337 | self._sid = gtk.Entry()
|
---|
1338 | self._sid.set_width_chars(10)
|
---|
1339 | self._sid.set_tooltip_text("The name of the Standard Instrument Deparature procedure followed.")
|
---|
1340 | self._sid.connect("changed", self._valueChanged)
|
---|
1341 | table.attach(self._sid, 1, 3, 1, 2)
|
---|
1342 | label.set_mnemonic_widget(self._sid)
|
---|
1343 |
|
---|
1344 | label = gtk.Label("V<sub>_1</sub>:")
|
---|
1345 | label.set_use_markup(True)
|
---|
1346 | label.set_use_underline(True)
|
---|
1347 | label.set_alignment(0.0, 0.5)
|
---|
1348 | table.attach(label, 0, 1, 2, 3)
|
---|
1349 |
|
---|
1350 | self._v1 = IntegerEntry()
|
---|
1351 | self._v1.set_width_chars(4)
|
---|
1352 | self._v1.set_tooltip_markup("The takeoff decision speed in knots.")
|
---|
1353 | self._v1.connect("integer-changed", self._valueChanged)
|
---|
1354 | table.attach(self._v1, 2, 3, 2, 3)
|
---|
1355 | label.set_mnemonic_widget(self._v1)
|
---|
1356 |
|
---|
1357 | table.attach(gtk.Label("knots"), 3, 4, 2, 3)
|
---|
1358 |
|
---|
1359 | label = gtk.Label("V<sub>_R</sub>:")
|
---|
1360 | label.set_use_markup(True)
|
---|
1361 | label.set_use_underline(True)
|
---|
1362 | label.set_alignment(0.0, 0.5)
|
---|
1363 | table.attach(label, 0, 1, 3, 4)
|
---|
1364 |
|
---|
1365 | self._vr = IntegerEntry()
|
---|
1366 | self._vr.set_width_chars(4)
|
---|
1367 | self._vr.set_tooltip_markup("The takeoff rotation speed in knots.")
|
---|
1368 | self._vr.connect("integer-changed", self._valueChanged)
|
---|
1369 | table.attach(self._vr, 2, 3, 3, 4)
|
---|
1370 | label.set_mnemonic_widget(self._vr)
|
---|
1371 |
|
---|
1372 | table.attach(gtk.Label("knots"), 3, 4, 3, 4)
|
---|
1373 |
|
---|
1374 | label = gtk.Label("V<sub>_2</sub>:")
|
---|
1375 | label.set_use_markup(True)
|
---|
1376 | label.set_use_underline(True)
|
---|
1377 | label.set_alignment(0.0, 0.5)
|
---|
1378 | table.attach(label, 0, 1, 4, 5)
|
---|
1379 |
|
---|
1380 | self._v2 = IntegerEntry()
|
---|
1381 | self._v2.set_width_chars(4)
|
---|
1382 | self._v2.set_tooltip_markup("The takeoff safety speed in knots.")
|
---|
1383 | self._v2.connect("integer-changed", self._valueChanged)
|
---|
1384 | table.attach(self._v2, 2, 3, 4, 5)
|
---|
1385 | label.set_mnemonic_widget(self._v2)
|
---|
1386 |
|
---|
1387 | table.attach(gtk.Label("knots"), 3, 4, 4, 5)
|
---|
1388 |
|
---|
1389 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
1390 | button.set_use_stock(True)
|
---|
1391 | button.connect("clicked", self._backClicked)
|
---|
1392 |
|
---|
1393 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
1394 | self._button.set_use_stock(True)
|
---|
1395 | self._button.connect("clicked", self._forwardClicked)
|
---|
1396 |
|
---|
1397 | @property
|
---|
1398 | def runway(self):
|
---|
1399 | """Get the runway."""
|
---|
1400 | return self._runway.get_text()
|
---|
1401 |
|
---|
1402 | @property
|
---|
1403 | def sid(self):
|
---|
1404 | """Get the SID."""
|
---|
1405 | return self._sid.get_text()
|
---|
1406 |
|
---|
1407 | @property
|
---|
1408 | def v1(self):
|
---|
1409 | """Get the v1 speed."""
|
---|
1410 | return self._v1.get_int()
|
---|
1411 |
|
---|
1412 | @property
|
---|
1413 | def vr(self):
|
---|
1414 | """Get the vr speed."""
|
---|
1415 | return self._vr.get_int()
|
---|
1416 |
|
---|
1417 | @property
|
---|
1418 | def v2(self):
|
---|
1419 | """Get the v2 speed."""
|
---|
1420 | return self._v2.get_int()
|
---|
1421 |
|
---|
1422 | def activate(self):
|
---|
1423 | """Activate the page."""
|
---|
1424 | self._runway.set_text("")
|
---|
1425 | self._runway.set_sensitive(True)
|
---|
1426 | self._sid.set_text("")
|
---|
1427 | self._sid.set_sensitive(True)
|
---|
1428 | self._v1.set_int(None)
|
---|
1429 | self._v1.set_sensitive(True)
|
---|
1430 | self._vr.set_int(None)
|
---|
1431 | self._vr.set_sensitive(True)
|
---|
1432 | self._v2.set_int(None)
|
---|
1433 | self._v2.set_sensitive(True)
|
---|
1434 | self._button.set_sensitive(False)
|
---|
1435 |
|
---|
1436 | def finalize(self):
|
---|
1437 | """Finalize the page."""
|
---|
1438 | self._runway.set_sensitive(False)
|
---|
1439 | self._sid.set_sensitive(False)
|
---|
1440 | self._v1.set_sensitive(False)
|
---|
1441 | self._vr.set_sensitive(False)
|
---|
1442 | self._v2.set_sensitive(False)
|
---|
1443 | self._wizard.gui.flight.aircraft.updateV1R2()
|
---|
1444 |
|
---|
1445 | def allowForward(self):
|
---|
1446 | """Allow going to the next page."""
|
---|
1447 | self._forwardAllowed = True
|
---|
1448 | self._updateForwardButton()
|
---|
1449 |
|
---|
1450 | def _updateForwardButton(self):
|
---|
1451 | """Update the sensitivity of the forward button based on some conditions."""
|
---|
1452 | sensitive = self._forwardAllowed and \
|
---|
1453 | self._runway.get_text()!="" and \
|
---|
1454 | self._sid.get_text()!="" and \
|
---|
1455 | self.v1 is not None and \
|
---|
1456 | self.vr is not None and \
|
---|
1457 | self.v2 is not None and \
|
---|
1458 | self.v1 <= self.vr and \
|
---|
1459 | self.vr <= self.v2
|
---|
1460 | self._button.set_sensitive(sensitive)
|
---|
1461 |
|
---|
1462 | def _valueChanged(self, widget, arg = None):
|
---|
1463 | """Called when the value of some widget has changed."""
|
---|
1464 | self._updateForwardButton()
|
---|
1465 |
|
---|
1466 | def _backClicked(self, button):
|
---|
1467 | """Called when the Back button is pressed."""
|
---|
1468 | self.goBack()
|
---|
1469 |
|
---|
1470 | def _forwardClicked(self, button):
|
---|
1471 | """Called when the forward button is clicked."""
|
---|
1472 | self._wizard.nextPage()
|
---|
1473 |
|
---|
1474 | #-----------------------------------------------------------------------------
|
---|
1475 |
|
---|
1476 | class LandingPage(Page):
|
---|
1477 | """Page for entering landing data."""
|
---|
1478 | def __init__(self, wizard):
|
---|
1479 | """Construct the landing page."""
|
---|
1480 | help = "Enter the STAR and/or transition, runway,\n" \
|
---|
1481 | "approach type and V<sub>Ref</sub> used."
|
---|
1482 | completedHelp = "The STAR and/or transition, runway, approach\n" \
|
---|
1483 | "type and V<sub>Ref</sub> logged can be seen below."
|
---|
1484 |
|
---|
1485 | super(LandingPage, self).__init__(wizard, "Landing", help,
|
---|
1486 | completedHelp = completedHelp)
|
---|
1487 |
|
---|
1488 | self._flightEnded = False
|
---|
1489 |
|
---|
1490 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
1491 | xscale = 0.0, yscale = 0.0)
|
---|
1492 |
|
---|
1493 | table = gtk.Table(5, 5)
|
---|
1494 | table.set_row_spacings(4)
|
---|
1495 | table.set_col_spacings(16)
|
---|
1496 | table.set_homogeneous(False)
|
---|
1497 | alignment.add(table)
|
---|
1498 | self.setMainWidget(alignment)
|
---|
1499 |
|
---|
1500 | self._starButton = gtk.CheckButton()
|
---|
1501 | self._starButton.connect("clicked", self._starButtonClicked)
|
---|
1502 | table.attach(self._starButton, 0, 1, 0, 1)
|
---|
1503 |
|
---|
1504 | label = gtk.Label("_STAR:")
|
---|
1505 | label.set_use_underline(True)
|
---|
1506 | label.set_alignment(0.0, 0.5)
|
---|
1507 | table.attach(label, 1, 2, 0, 1)
|
---|
1508 |
|
---|
1509 | self._star = gtk.Entry()
|
---|
1510 | self._star.set_width_chars(10)
|
---|
1511 | self._star.set_tooltip_text("The name of Standard Terminal Arrival Route followed.")
|
---|
1512 | self._star.connect("changed", self._updateForwardButton)
|
---|
1513 | self._star.set_sensitive(False)
|
---|
1514 | table.attach(self._star, 2, 4, 0, 1)
|
---|
1515 | label.set_mnemonic_widget(self._starButton)
|
---|
1516 |
|
---|
1517 | self._transitionButton = gtk.CheckButton()
|
---|
1518 | self._transitionButton.connect("clicked", self._transitionButtonClicked)
|
---|
1519 | table.attach(self._transitionButton, 0, 1, 1, 2)
|
---|
1520 |
|
---|
1521 | label = gtk.Label("_Transition:")
|
---|
1522 | label.set_use_underline(True)
|
---|
1523 | label.set_alignment(0.0, 0.5)
|
---|
1524 | table.attach(label, 1, 2, 1, 2)
|
---|
1525 |
|
---|
1526 | self._transition = gtk.Entry()
|
---|
1527 | self._transition.set_width_chars(10)
|
---|
1528 | self._transition.set_tooltip_text("The name of transition executed or VECTORS if vectored by ATC.")
|
---|
1529 | self._transition.connect("changed", self._updateForwardButton)
|
---|
1530 | self._transition.set_sensitive(False)
|
---|
1531 | table.attach(self._transition, 2, 4, 1, 2)
|
---|
1532 | label.set_mnemonic_widget(self._transitionButton)
|
---|
1533 |
|
---|
1534 | label = gtk.Label("Run_way:")
|
---|
1535 | label.set_use_underline(True)
|
---|
1536 | label.set_alignment(0.0, 0.5)
|
---|
1537 | table.attach(label, 1, 2, 2, 3)
|
---|
1538 |
|
---|
1539 | self._runway = gtk.Entry()
|
---|
1540 | self._runway.set_width_chars(10)
|
---|
1541 | self._runway.set_tooltip_text("The runway the landing is performed on.")
|
---|
1542 | self._runway.connect("changed", self._updateForwardButton)
|
---|
1543 | table.attach(self._runway, 2, 4, 2, 3)
|
---|
1544 | label.set_mnemonic_widget(self._runway)
|
---|
1545 |
|
---|
1546 | label = gtk.Label("_Approach type:")
|
---|
1547 | label.set_use_underline(True)
|
---|
1548 | label.set_alignment(0.0, 0.5)
|
---|
1549 | table.attach(label, 1, 2, 3, 4)
|
---|
1550 |
|
---|
1551 | self._approachType = gtk.Entry()
|
---|
1552 | self._approachType.set_width_chars(10)
|
---|
1553 | self._approachType.set_tooltip_text("The type of the approach, e.g. ILS or VISUAL.")
|
---|
1554 | self._approachType.connect("changed", self._updateForwardButton)
|
---|
1555 | table.attach(self._approachType, 2, 4, 3, 4)
|
---|
1556 | label.set_mnemonic_widget(self._approachType)
|
---|
1557 |
|
---|
1558 | label = gtk.Label("V<sub>_Ref</sub>:")
|
---|
1559 | label.set_use_markup(True)
|
---|
1560 | label.set_use_underline(True)
|
---|
1561 | label.set_alignment(0.0, 0.5)
|
---|
1562 | table.attach(label, 1, 2, 5, 6)
|
---|
1563 |
|
---|
1564 | self._vref = IntegerEntry()
|
---|
1565 | self._vref.set_width_chars(5)
|
---|
1566 | self._vref.set_tooltip_markup("The approach reference speed in knots.")
|
---|
1567 | self._vref.connect("integer-changed", self._vrefChanged)
|
---|
1568 | table.attach(self._vref, 3, 4, 5, 6)
|
---|
1569 | label.set_mnemonic_widget(self._vref)
|
---|
1570 |
|
---|
1571 | table.attach(gtk.Label("knots"), 4, 5, 5, 6)
|
---|
1572 |
|
---|
1573 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
1574 | button.set_use_stock(True)
|
---|
1575 | button.connect("clicked", self._backClicked)
|
---|
1576 |
|
---|
1577 | self._button = self.addButton(gtk.STOCK_GO_FORWARD, default = True)
|
---|
1578 | self._button.set_use_stock(True)
|
---|
1579 | self._button.connect("clicked", self._forwardClicked)
|
---|
1580 |
|
---|
1581 | # These are needed for correct size calculations
|
---|
1582 | self._starButton.set_active(True)
|
---|
1583 | self._transitionButton.set_active(True)
|
---|
1584 |
|
---|
1585 | @property
|
---|
1586 | def star(self):
|
---|
1587 | """Get the STAR or None if none entered."""
|
---|
1588 | return self._star.get_text() if self._starButton.get_active() else None
|
---|
1589 |
|
---|
1590 | @property
|
---|
1591 | def transition(self):
|
---|
1592 | """Get the transition or None if none entered."""
|
---|
1593 | return self._transition.get_text() \
|
---|
1594 | if self._transitionButton.get_active() else None
|
---|
1595 |
|
---|
1596 | @property
|
---|
1597 | def approachType(self):
|
---|
1598 | """Get the approach type."""
|
---|
1599 | return self._approachType.get_text()
|
---|
1600 |
|
---|
1601 | @property
|
---|
1602 | def runway(self):
|
---|
1603 | """Get the runway."""
|
---|
1604 | return self._runway.get_text()
|
---|
1605 |
|
---|
1606 | @property
|
---|
1607 | def vref(self):
|
---|
1608 | """Return the landing reference speed."""
|
---|
1609 | return self._vref.get_int()
|
---|
1610 |
|
---|
1611 | def activate(self):
|
---|
1612 | """Called when the page is activated."""
|
---|
1613 | self._starButton.set_sensitive(True)
|
---|
1614 | self._starButton.set_active(False)
|
---|
1615 | self._star.set_text("")
|
---|
1616 |
|
---|
1617 | self._transitionButton.set_sensitive(True)
|
---|
1618 | self._transitionButton.set_active(False)
|
---|
1619 | self._transition.set_text("")
|
---|
1620 |
|
---|
1621 | self._runway.set_text("")
|
---|
1622 | self._runway.set_sensitive(True)
|
---|
1623 |
|
---|
1624 | self._approachType.set_text("")
|
---|
1625 | self._approachType.set_sensitive(True)
|
---|
1626 |
|
---|
1627 | self._vref.set_int(None)
|
---|
1628 | self._vref.set_sensitive(True)
|
---|
1629 |
|
---|
1630 | self._updateForwardButton()
|
---|
1631 |
|
---|
1632 | def flightEnded(self):
|
---|
1633 | """Called when the flight has ended."""
|
---|
1634 | self._flightEnded = True
|
---|
1635 | self._updateForwardButton()
|
---|
1636 |
|
---|
1637 | def finalize(self):
|
---|
1638 | """Finalize the page."""
|
---|
1639 | self._starButton.set_sensitive(False)
|
---|
1640 | self._star.set_sensitive(False)
|
---|
1641 |
|
---|
1642 | self._transitionButton.set_sensitive(False)
|
---|
1643 | self._transition.set_sensitive(False)
|
---|
1644 |
|
---|
1645 | self._runway.set_sensitive(False)
|
---|
1646 |
|
---|
1647 | self._approachType.set_sensitive(False)
|
---|
1648 |
|
---|
1649 | self._vref.set_sensitive(False)
|
---|
1650 | self._wizard.gui.flight.aircraft.updateVRef()
|
---|
1651 | # FIXME: Perhaps a separate initialize() call which would set up
|
---|
1652 | # defaults? -> use reset()
|
---|
1653 | self._flightEnded = False
|
---|
1654 |
|
---|
1655 | def _starButtonClicked(self, button):
|
---|
1656 | """Called when the STAR button is clicked."""
|
---|
1657 | active = button.get_active()
|
---|
1658 | self._star.set_sensitive(active)
|
---|
1659 | if active:
|
---|
1660 | self._star.grab_focus()
|
---|
1661 | self._updateForwardButton()
|
---|
1662 |
|
---|
1663 | def _transitionButtonClicked(self, button):
|
---|
1664 | """Called when the Transition button is clicked."""
|
---|
1665 | active = button.get_active()
|
---|
1666 | self._transition.set_sensitive(active)
|
---|
1667 | if active:
|
---|
1668 | self._transition.grab_focus()
|
---|
1669 | self._updateForwardButton()
|
---|
1670 |
|
---|
1671 | def _updateForwardButton(self, widget = None):
|
---|
1672 | """Update the sensitivity of the forward button."""
|
---|
1673 | sensitive = self._flightEnded and \
|
---|
1674 | (self._starButton.get_active() or \
|
---|
1675 | self._transitionButton.get_active()) and \
|
---|
1676 | (self._star.get_text()!="" or
|
---|
1677 | not self._starButton.get_active()) and \
|
---|
1678 | (self._transition.get_text()!="" or
|
---|
1679 | not self._transitionButton.get_active()) and \
|
---|
1680 | self._runway.get_text()!="" and \
|
---|
1681 | self._approachType.get_text()!="" and \
|
---|
1682 | self.vref is not None
|
---|
1683 | self._button.set_sensitive(sensitive)
|
---|
1684 |
|
---|
1685 | def _vrefChanged(self, widget, value):
|
---|
1686 | """Called when the Vref has changed."""
|
---|
1687 | self._updateForwardButton()
|
---|
1688 |
|
---|
1689 | def _backClicked(self, button):
|
---|
1690 | """Called when the Back button is pressed."""
|
---|
1691 | self.goBack()
|
---|
1692 |
|
---|
1693 | def _forwardClicked(self, button):
|
---|
1694 | """Called when the forward button is clicked."""
|
---|
1695 | self._wizard.nextPage()
|
---|
1696 |
|
---|
1697 | #-----------------------------------------------------------------------------
|
---|
1698 |
|
---|
1699 | class FinishPage(Page):
|
---|
1700 | """Flight finish page."""
|
---|
1701 | _flightTypes = [ ("scheduled", const.FLIGHTTYPE_SCHEDULED),
|
---|
1702 | ("old-timer", const.FLIGHTTYPE_OLDTIMER),
|
---|
1703 | ("VIP", const.FLIGHTTYPE_VIP),
|
---|
1704 | ("charter", const.FLIGHTTYPE_CHARTER) ]
|
---|
1705 |
|
---|
1706 | def __init__(self, wizard):
|
---|
1707 | """Construct the finish page."""
|
---|
1708 | help = "There are some statistics about your flight below.\n\n" \
|
---|
1709 | "Review the data, also on earlier pages, and if you are\n" \
|
---|
1710 | "satisfied, you can save or send your PIREP."
|
---|
1711 |
|
---|
1712 | super(FinishPage, self).__init__(wizard, "Finish", help)
|
---|
1713 |
|
---|
1714 | alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
|
---|
1715 | xscale = 0.0, yscale = 0.0)
|
---|
1716 |
|
---|
1717 | table = gtk.Table(7, 2)
|
---|
1718 | table.set_row_spacings(4)
|
---|
1719 | table.set_col_spacings(16)
|
---|
1720 | table.set_homogeneous(False)
|
---|
1721 | alignment.add(table)
|
---|
1722 | self.setMainWidget(alignment)
|
---|
1723 |
|
---|
1724 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
1725 | label = gtk.Label("Flight rating:")
|
---|
1726 | labelAlignment.add(label)
|
---|
1727 | table.attach(labelAlignment, 0, 1, 0, 1)
|
---|
1728 |
|
---|
1729 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
1730 | self._flightRating = gtk.Label()
|
---|
1731 | self._flightRating.set_width_chars(7)
|
---|
1732 | self._flightRating.set_alignment(0.0, 0.5)
|
---|
1733 | self._flightRating.set_use_markup(True)
|
---|
1734 | labelAlignment.add(self._flightRating)
|
---|
1735 | table.attach(labelAlignment, 1, 2, 0, 1)
|
---|
1736 |
|
---|
1737 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
1738 | label = gtk.Label("Flight time:")
|
---|
1739 | labelAlignment.add(label)
|
---|
1740 | table.attach(labelAlignment, 0, 1, 1, 2)
|
---|
1741 |
|
---|
1742 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
1743 | self._flightTime = gtk.Label()
|
---|
1744 | self._flightTime.set_width_chars(10)
|
---|
1745 | self._flightTime.set_alignment(0.0, 0.5)
|
---|
1746 | self._flightTime.set_use_markup(True)
|
---|
1747 | labelAlignment.add(self._flightTime)
|
---|
1748 | table.attach(labelAlignment, 1, 2, 1, 2)
|
---|
1749 |
|
---|
1750 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
1751 | label = gtk.Label("Block time:")
|
---|
1752 | labelAlignment.add(label)
|
---|
1753 | table.attach(labelAlignment, 0, 1, 2, 3)
|
---|
1754 |
|
---|
1755 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
1756 | self._blockTime = gtk.Label()
|
---|
1757 | self._blockTime.set_width_chars(10)
|
---|
1758 | self._blockTime.set_alignment(0.0, 0.5)
|
---|
1759 | self._blockTime.set_use_markup(True)
|
---|
1760 | labelAlignment.add(self._blockTime)
|
---|
1761 | table.attach(labelAlignment, 1, 2, 2, 3)
|
---|
1762 |
|
---|
1763 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
1764 | label = gtk.Label("Distance flown:")
|
---|
1765 | labelAlignment.add(label)
|
---|
1766 | table.attach(labelAlignment, 0, 1, 3, 4)
|
---|
1767 |
|
---|
1768 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
1769 | self._distanceFlown = gtk.Label()
|
---|
1770 | self._distanceFlown.set_width_chars(10)
|
---|
1771 | self._distanceFlown.set_alignment(0.0, 0.5)
|
---|
1772 | self._distanceFlown.set_use_markup(True)
|
---|
1773 | labelAlignment.add(self._distanceFlown)
|
---|
1774 | table.attach(labelAlignment, 1, 2, 3, 4)
|
---|
1775 |
|
---|
1776 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
1777 | label = gtk.Label("Fuel used:")
|
---|
1778 | labelAlignment.add(label)
|
---|
1779 | table.attach(labelAlignment, 0, 1, 4, 5)
|
---|
1780 |
|
---|
1781 | labelAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
1782 | self._fuelUsed = gtk.Label()
|
---|
1783 | self._fuelUsed.set_width_chars(10)
|
---|
1784 | self._fuelUsed.set_alignment(0.0, 0.5)
|
---|
1785 | self._fuelUsed.set_use_markup(True)
|
---|
1786 | labelAlignment.add(self._fuelUsed)
|
---|
1787 | table.attach(labelAlignment, 1, 2, 4, 5)
|
---|
1788 |
|
---|
1789 | labelAlignment = gtk.Alignment(xalign=1.0, xscale=0.0)
|
---|
1790 | label = gtk.Label("_Type:")
|
---|
1791 | label.set_use_underline(True)
|
---|
1792 | labelAlignment.add(label)
|
---|
1793 | table.attach(labelAlignment, 0, 1, 5, 6)
|
---|
1794 |
|
---|
1795 | flightTypeModel = gtk.ListStore(str, int)
|
---|
1796 | for (name, type) in FinishPage._flightTypes:
|
---|
1797 | flightTypeModel.append([name, type])
|
---|
1798 |
|
---|
1799 | self._flightType = gtk.ComboBox(model = flightTypeModel)
|
---|
1800 | renderer = gtk.CellRendererText()
|
---|
1801 | self._flightType.pack_start(renderer, True)
|
---|
1802 | self._flightType.add_attribute(renderer, "text", 0)
|
---|
1803 | self._flightType.set_tooltip_text("Select the type of the flight.")
|
---|
1804 | self._flightType.set_active(0)
|
---|
1805 | self._flightType.connect("changed", self._flightTypeChanged)
|
---|
1806 | flightTypeAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
1807 | flightTypeAlignment.add(self._flightType)
|
---|
1808 | table.attach(flightTypeAlignment, 1, 2, 5, 6)
|
---|
1809 | label.set_mnemonic_widget(self._flightType)
|
---|
1810 |
|
---|
1811 | self._onlineFlight = gtk.CheckButton("_Online flight")
|
---|
1812 | self._onlineFlight.set_use_underline(True)
|
---|
1813 | self._onlineFlight.set_tooltip_text("Check if your flight was online, uncheck otherwise.")
|
---|
1814 | onlineFlightAlignment = gtk.Alignment(xalign=0.0, xscale=0.0)
|
---|
1815 | onlineFlightAlignment.add(self._onlineFlight)
|
---|
1816 | table.attach(onlineFlightAlignment, 1, 2, 6, 7)
|
---|
1817 |
|
---|
1818 | button = self.addButton(gtk.STOCK_GO_BACK)
|
---|
1819 | button.set_use_stock(True)
|
---|
1820 | button.connect("clicked", self._backClicked)
|
---|
1821 |
|
---|
1822 | self._saveButton = self.addButton("S_ave PIREP...")
|
---|
1823 | self._saveButton.set_use_underline(True)
|
---|
1824 | self._saveButton.set_sensitive(False)
|
---|
1825 | #self._saveButton.connect("clicked", self._saveClicked)
|
---|
1826 |
|
---|
1827 | self._sendButton = self.addButton("_Send PIREP...", True)
|
---|
1828 | self._sendButton.set_use_underline(True)
|
---|
1829 | self._sendButton.set_sensitive(False)
|
---|
1830 | self._sendButton.connect("clicked", self._sendClicked)
|
---|
1831 |
|
---|
1832 | @property
|
---|
1833 | def flightType(self):
|
---|
1834 | """Get the flight type."""
|
---|
1835 | index = self._flightType.get_active()
|
---|
1836 | return None if index<0 else self._flightType.get_model()[index][1]
|
---|
1837 |
|
---|
1838 | @property
|
---|
1839 | def online(self):
|
---|
1840 | """Get whether the flight was an online flight or not."""
|
---|
1841 | return self._onlineFlight.get_active()
|
---|
1842 |
|
---|
1843 | def activate(self):
|
---|
1844 | """Activate the page."""
|
---|
1845 | flight = self._wizard.gui._flight
|
---|
1846 | rating = flight.logger.getRating()
|
---|
1847 | if rating<0:
|
---|
1848 | self._flightRating.set_markup('<b><span foreground="red">NO GO</span></b>')
|
---|
1849 | else:
|
---|
1850 | self._flightRating.set_markup("<b>%.1f %%</b>" % (rating,))
|
---|
1851 |
|
---|
1852 | flightLength = flight.flightTimeEnd - flight.flightTimeStart
|
---|
1853 | self._flightTime.set_markup("<b>%s</b>" % \
|
---|
1854 | (util.getTimeIntervalString(flightLength),))
|
---|
1855 |
|
---|
1856 | blockLength = flight.blockTimeEnd - flight.blockTimeStart
|
---|
1857 | self._blockTime.set_markup("<b>%s</b>" % \
|
---|
1858 | (util.getTimeIntervalString(blockLength),))
|
---|
1859 |
|
---|
1860 | self._distanceFlown.set_markup("<b>%.2f NM</b>" % \
|
---|
1861 | (flight.flownDistance,))
|
---|
1862 |
|
---|
1863 | self._fuelUsed.set_markup("<b>%.0f kg</b>" % \
|
---|
1864 | (flight.startFuel - flight.endFuel,))
|
---|
1865 |
|
---|
1866 | self._flightType.set_active(-1)
|
---|
1867 | self._onlineFlight.set_active(True)
|
---|
1868 |
|
---|
1869 | def _backClicked(self, button):
|
---|
1870 | """Called when the Back button is pressed."""
|
---|
1871 | self.goBack()
|
---|
1872 |
|
---|
1873 | def _flightTypeChanged(self, comboBox):
|
---|
1874 | """Called when the flight type has changed."""
|
---|
1875 | index = self._flightType.get_active()
|
---|
1876 | flightTypeIsValid = index>=0
|
---|
1877 | #self._saveButton.set_sensitive(flightTypeIsValid)
|
---|
1878 | self._sendButton.set_sensitive(flightTypeIsValid)
|
---|
1879 |
|
---|
1880 | def _sendClicked(self, button):
|
---|
1881 | """Called when the Send button is clicked."""
|
---|
1882 | pirep = PIREP(self._wizard.gui)
|
---|
1883 | gui = self._wizard.gui
|
---|
1884 | gui.beginBusy("Sending PIREP...")
|
---|
1885 | gui.webHandler.sendPIREP(self._pirepSentCallback, pirep)
|
---|
1886 |
|
---|
1887 | def _pirepSentCallback(self, returned, result):
|
---|
1888 | """Callback for the PIREP sending result."""
|
---|
1889 | gobject.idle_add(self._handlePIREPSent, returned, result)
|
---|
1890 |
|
---|
1891 | def _handlePIREPSent(self, returned, result):
|
---|
1892 | """Callback for the PIREP sending result."""
|
---|
1893 | self._wizard.gui.endBusy()
|
---|
1894 | secondaryMarkup = None
|
---|
1895 | type = MESSAGETYPE_ERROR
|
---|
1896 | if returned:
|
---|
1897 | if result.success:
|
---|
1898 | type = MESSAGETYPE_INFO
|
---|
1899 | messageFormat = "The PIREP was sent successfully."
|
---|
1900 | secondaryMarkup = "Await the thorough scrutiny by our fearless PIREP correctors! :)"
|
---|
1901 | elif result.alreadyFlown:
|
---|
1902 | messageFormat = "The PIREP for this flight has already been sent!"
|
---|
1903 | secondaryMarkup = "You may clear the old PIREP on the MAVA website."
|
---|
1904 | elif result.notAvailable:
|
---|
1905 | messageFormat = "This flight is not available anymore!"
|
---|
1906 | else:
|
---|
1907 | messageFormat = "The MAVA website returned with an unknown error."
|
---|
1908 | secondaryMarkup = "See the debug log for more information."
|
---|
1909 | else:
|
---|
1910 | print "PIREP sending failed", result
|
---|
1911 | messageFormat = "Could not send the PIREP to the MAVA website."
|
---|
1912 | secondaryMarkup = "This can be a network problem, in which case\n" \
|
---|
1913 | "you may try again later. Or it can be a bug;\n" \
|
---|
1914 | "see the debug log for more information."
|
---|
1915 |
|
---|
1916 | dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow,
|
---|
1917 | type = type, buttons = BUTTONSTYPE_OK,
|
---|
1918 | message_format = messageFormat)
|
---|
1919 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
1920 | if secondaryMarkup is not None:
|
---|
1921 | dialog.format_secondary_markup(secondaryMarkup)
|
---|
1922 |
|
---|
1923 | dialog.run()
|
---|
1924 | dialog.hide()
|
---|
1925 |
|
---|
1926 | #-----------------------------------------------------------------------------
|
---|
1927 |
|
---|
1928 | class Wizard(gtk.VBox):
|
---|
1929 | """The flight wizard."""
|
---|
1930 | def __init__(self, gui):
|
---|
1931 | """Construct the wizard."""
|
---|
1932 | super(Wizard, self).__init__()
|
---|
1933 |
|
---|
1934 | self.gui = gui
|
---|
1935 |
|
---|
1936 | self._pages = []
|
---|
1937 | self._currentPage = None
|
---|
1938 |
|
---|
1939 | self._pages.append(LoginPage(self))
|
---|
1940 | self._pages.append(FlightSelectionPage(self))
|
---|
1941 | self._pages.append(GateSelectionPage(self))
|
---|
1942 | self._pages.append(ConnectPage(self))
|
---|
1943 | self._payloadPage = PayloadPage(self)
|
---|
1944 | self._pages.append(self._payloadPage)
|
---|
1945 | self._pages.append(TimePage(self))
|
---|
1946 | self._routePage = RoutePage(self)
|
---|
1947 | self._pages.append(self._routePage)
|
---|
1948 | self._departureBriefingPage = BriefingPage(self, True)
|
---|
1949 | self._pages.append(self._departureBriefingPage)
|
---|
1950 | self._arrivalBriefingPage = BriefingPage(self, False)
|
---|
1951 | self._pages.append(self._arrivalBriefingPage)
|
---|
1952 | self._takeoffPage = TakeoffPage(self)
|
---|
1953 | self._pages.append(self._takeoffPage)
|
---|
1954 | self._landingPage = LandingPage(self)
|
---|
1955 | self._pages.append(self._landingPage)
|
---|
1956 | self._finishPage = FinishPage(self)
|
---|
1957 | self._pages.append(self._finishPage)
|
---|
1958 |
|
---|
1959 | maxWidth = 0
|
---|
1960 | maxHeight = 0
|
---|
1961 | for page in self._pages:
|
---|
1962 | page.show_all()
|
---|
1963 | pageSizeRequest = page.size_request()
|
---|
1964 | width = pageSizeRequest.width if pygobject else pageSizeRequest[0]
|
---|
1965 | height = pageSizeRequest.height if pygobject else pageSizeRequest[1]
|
---|
1966 | maxWidth = max(maxWidth, width)
|
---|
1967 | maxHeight = max(maxHeight, height)
|
---|
1968 | maxWidth += 16
|
---|
1969 | maxHeight += 32
|
---|
1970 | self.set_size_request(maxWidth, maxHeight)
|
---|
1971 |
|
---|
1972 | self._initialize()
|
---|
1973 |
|
---|
1974 | @property
|
---|
1975 | def loginResult(self):
|
---|
1976 | """Get the login result."""
|
---|
1977 | return self._loginResult
|
---|
1978 |
|
---|
1979 | def setCurrentPage(self, index, finalize = False):
|
---|
1980 | """Set the current page to the one with the given index."""
|
---|
1981 | assert index < len(self._pages)
|
---|
1982 |
|
---|
1983 | fromPage = self._currentPage
|
---|
1984 | if fromPage is not None:
|
---|
1985 | page = self._pages[fromPage]
|
---|
1986 | if finalize and not page._completed:
|
---|
1987 | page.complete()
|
---|
1988 | self.remove(page)
|
---|
1989 |
|
---|
1990 | self._currentPage = index
|
---|
1991 | page = self._pages[index]
|
---|
1992 | self.add(page)
|
---|
1993 | if page._fromPage is None:
|
---|
1994 | page._fromPage = fromPage
|
---|
1995 | page.initialize()
|
---|
1996 | self.show_all()
|
---|
1997 | if fromPage is not None:
|
---|
1998 | self.grabDefault()
|
---|
1999 |
|
---|
2000 | @property
|
---|
2001 | def bookedFlight(self):
|
---|
2002 | """Get the booked flight selected."""
|
---|
2003 | return self._bookedFlight
|
---|
2004 |
|
---|
2005 | @property
|
---|
2006 | def cargoWeight(self):
|
---|
2007 | """Get the calculated ZFW value."""
|
---|
2008 | return self._payloadPage.cargoWeight
|
---|
2009 |
|
---|
2010 | @property
|
---|
2011 | def zfw(self):
|
---|
2012 | """Get the calculated ZFW value."""
|
---|
2013 | return 0 if self._bookedFlight is None \
|
---|
2014 | else self._payloadPage.calculateZFW()
|
---|
2015 |
|
---|
2016 | @property
|
---|
2017 | def filedCruiseAltitude(self):
|
---|
2018 | """Get the filed cruise altitude."""
|
---|
2019 | return self._routePage.filedCruiseLevel * 100
|
---|
2020 |
|
---|
2021 | @property
|
---|
2022 | def cruiseAltitude(self):
|
---|
2023 | """Get the cruise altitude."""
|
---|
2024 | return self._routePage.cruiseLevel * 100
|
---|
2025 |
|
---|
2026 | @property
|
---|
2027 | def route(self):
|
---|
2028 | """Get the route."""
|
---|
2029 | return self._routePage.route
|
---|
2030 |
|
---|
2031 | @property
|
---|
2032 | def departureMETAR(self):
|
---|
2033 | """Get the METAR of the departure airport."""
|
---|
2034 | return self._departureBriefingPage.metar
|
---|
2035 |
|
---|
2036 | @property
|
---|
2037 | def arrivalMETAR(self):
|
---|
2038 | """Get the METAR of the arrival airport."""
|
---|
2039 | return self._arrivalBriefingPage.metar
|
---|
2040 |
|
---|
2041 | @property
|
---|
2042 | def departureRunway(self):
|
---|
2043 | """Get the departure runway."""
|
---|
2044 | return self._takeoffPage.runway
|
---|
2045 |
|
---|
2046 | @property
|
---|
2047 | def sid(self):
|
---|
2048 | """Get the SID."""
|
---|
2049 | return self._takeoffPage.sid
|
---|
2050 |
|
---|
2051 | @property
|
---|
2052 | def v1(self):
|
---|
2053 | """Get the V1 speed."""
|
---|
2054 | return self._takeoffPage.v1
|
---|
2055 |
|
---|
2056 | @property
|
---|
2057 | def vr(self):
|
---|
2058 | """Get the Vr speed."""
|
---|
2059 | return self._takeoffPage.vr
|
---|
2060 |
|
---|
2061 | @property
|
---|
2062 | def v2(self):
|
---|
2063 | """Get the V2 speed."""
|
---|
2064 | return self._takeoffPage.v2
|
---|
2065 |
|
---|
2066 | @property
|
---|
2067 | def arrivalRunway(self):
|
---|
2068 | """Get the arrival runway."""
|
---|
2069 | return self._landingPage.runway
|
---|
2070 |
|
---|
2071 | @property
|
---|
2072 | def star(self):
|
---|
2073 | """Get the STAR."""
|
---|
2074 | return self._landingPage.star
|
---|
2075 |
|
---|
2076 | @property
|
---|
2077 | def transition(self):
|
---|
2078 | """Get the transition."""
|
---|
2079 | return self._landingPage.transition
|
---|
2080 |
|
---|
2081 | @property
|
---|
2082 | def approachType(self):
|
---|
2083 | """Get the approach type."""
|
---|
2084 | return self._landingPage.approachType
|
---|
2085 |
|
---|
2086 | @property
|
---|
2087 | def vref(self):
|
---|
2088 | """Get the Vref speed."""
|
---|
2089 | return self._landingPage.vref
|
---|
2090 |
|
---|
2091 | @property
|
---|
2092 | def flightType(self):
|
---|
2093 | """Get the flight type."""
|
---|
2094 | return self._finishPage.flightType
|
---|
2095 |
|
---|
2096 | @property
|
---|
2097 | def online(self):
|
---|
2098 | """Get whether the flight was online or not."""
|
---|
2099 | return self._finishPage.online
|
---|
2100 |
|
---|
2101 | def nextPage(self, finalize = True):
|
---|
2102 | """Go to the next page."""
|
---|
2103 | self.jumpPage(1, finalize)
|
---|
2104 |
|
---|
2105 | def jumpPage(self, count, finalize = True):
|
---|
2106 | """Go to the page which is 'count' pages after the current one."""
|
---|
2107 | self.setCurrentPage(self._currentPage + count, finalize = finalize)
|
---|
2108 |
|
---|
2109 | def grabDefault(self):
|
---|
2110 | """Make the default button of the current page the default."""
|
---|
2111 | self._pages[self._currentPage].grabDefault()
|
---|
2112 |
|
---|
2113 | def connected(self, fsType, descriptor):
|
---|
2114 | """Called when the connection could be made to the simulator."""
|
---|
2115 | self.nextPage()
|
---|
2116 |
|
---|
2117 | def reset(self):
|
---|
2118 | """Resets the wizard to go back to the login page."""
|
---|
2119 | self._initialize()
|
---|
2120 |
|
---|
2121 | def setStage(self, stage):
|
---|
2122 | """Set the flight stage to the given one."""
|
---|
2123 | if stage==const.STAGE_TAKEOFF:
|
---|
2124 | self._takeoffPage.allowForward()
|
---|
2125 | elif stage==const.STAGE_END:
|
---|
2126 | self._landingPage.flightEnded()
|
---|
2127 |
|
---|
2128 | def _initialize(self):
|
---|
2129 | """Initialize the wizard."""
|
---|
2130 | self._fleet = None
|
---|
2131 | self._fleetCallback = None
|
---|
2132 | self._updatePlaneCallback = None
|
---|
2133 |
|
---|
2134 | self._loginResult = None
|
---|
2135 | self._bookedFlight = None
|
---|
2136 | self._departureGate = "-"
|
---|
2137 | self._departureNOTAMs = None
|
---|
2138 | self._departureMETAR = None
|
---|
2139 | self._arrivalNOTAMs = None
|
---|
2140 | self._arrivalMETAR = None
|
---|
2141 |
|
---|
2142 | for page in self._pages:
|
---|
2143 | page.reset()
|
---|
2144 |
|
---|
2145 | self.setCurrentPage(0)
|
---|
2146 |
|
---|
2147 | def _getFleet(self, callback, force = False):
|
---|
2148 | """Get the fleet, if needed.
|
---|
2149 |
|
---|
2150 | callback is function that will be called, when the feet is retrieved,
|
---|
2151 | or the retrieval fails. It should have a single argument that will
|
---|
2152 | receive the fleet object on success, None otherwise.
|
---|
2153 | """
|
---|
2154 | if self._fleet is not None and not force:
|
---|
2155 | callback(self._fleet)
|
---|
2156 |
|
---|
2157 | self.gui.beginBusy("Retrieving fleet...")
|
---|
2158 | self._fleetCallback = callback
|
---|
2159 | self.gui.webHandler.getFleet(self._fleetResultCallback)
|
---|
2160 |
|
---|
2161 | def _fleetResultCallback(self, returned, result):
|
---|
2162 | """Called when the fleet has been queried."""
|
---|
2163 | gobject.idle_add(self._handleFleetResult, returned, result)
|
---|
2164 |
|
---|
2165 | def _handleFleetResult(self, returned, result):
|
---|
2166 | """Handle the fleet result."""
|
---|
2167 | self.gui.endBusy()
|
---|
2168 | if returned:
|
---|
2169 | self._fleet = result.fleet
|
---|
2170 | else:
|
---|
2171 | self._fleet = None
|
---|
2172 |
|
---|
2173 | dialog = gtk.MessageDialog(parent = self.gui.mainWindow,
|
---|
2174 | type = MESSAGETYPE_ERROR,
|
---|
2175 | buttons = BUTTONSTYPE_OK,
|
---|
2176 | message_format =
|
---|
2177 | "Failed to retrieve the information on "
|
---|
2178 | "the fleet.")
|
---|
2179 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
2180 | dialog.run()
|
---|
2181 | dialog.hide()
|
---|
2182 |
|
---|
2183 | self._fleetCallback(self._fleet)
|
---|
2184 |
|
---|
2185 | def _updatePlane(self, callback, tailNumber, status, gateNumber = None):
|
---|
2186 | """Update the given plane's gate information."""
|
---|
2187 | self.gui.beginBusy("Updating plane status...")
|
---|
2188 | self._updatePlaneCallback = callback
|
---|
2189 | self.gui.webHandler.updatePlane(self._updatePlaneResultCallback,
|
---|
2190 | tailNumber, status, gateNumber)
|
---|
2191 |
|
---|
2192 | def _updatePlaneResultCallback(self, returned, result):
|
---|
2193 | """Callback for the plane updating operation."""
|
---|
2194 | gobject.idle_add(self._handleUpdatePlaneResult, returned, result)
|
---|
2195 |
|
---|
2196 | def _handleUpdatePlaneResult(self, returned, result):
|
---|
2197 | """Handle the result of a plane update operation."""
|
---|
2198 | self.gui.endBusy()
|
---|
2199 | if returned:
|
---|
2200 | success = result.success
|
---|
2201 | else:
|
---|
2202 | success = None
|
---|
2203 |
|
---|
2204 | dialog = gtk.MessageDialog(parent = self.gui.mainWindow,
|
---|
2205 | type = MESSAGETYPE_ERROR,
|
---|
2206 | buttons = BUTTONSTYPE_OK,
|
---|
2207 | message_format =
|
---|
2208 | "Failed to update the statuis of "
|
---|
2209 | "the airplane.")
|
---|
2210 | dialog.set_title(WINDOW_TITLE_BASE)
|
---|
2211 | dialog.run()
|
---|
2212 | dialog.hide()
|
---|
2213 |
|
---|
2214 | self._updatePlaneCallback(success)
|
---|
2215 |
|
---|
2216 | def _connectSimulator(self):
|
---|
2217 | """Connect to the simulator."""
|
---|
2218 | self.gui.connectSimulator(self._bookedFlight.aircraftType)
|
---|
2219 |
|
---|
2220 | #-----------------------------------------------------------------------------
|
---|
2221 |
|
---|