Changeset 754:8547ad78cc29 for src/mlx
- Timestamp:
- 01/06/16 13:36:31 (9 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r753 r754 62 62 class Page(gtk.Alignment): 63 63 """A page in the flight wizard.""" 64 def __init__(self, wizard, title, help, completedHelp = None):64 def __init__(self, wizard, id, title, help, completedHelp = None): 65 65 """Construct the page.""" 66 66 super(Page, self).__init__(xalign = 0.0, yalign = 0.0, … … 140 140 141 141 self._wizard = wizard 142 self._id = id 143 self._nextPageID = None 142 144 143 145 self._cancelFlightButton = None … … 145 147 self._completed = False 146 148 self._fromPage = None 149 150 @property 151 def id(self): 152 """Get the identifier of the page.""" 153 return self._id 154 155 @property 156 def nextPageID(self): 157 """Get the identifier of the next page, if set.""" 158 return self._nextPageID 159 160 @nextPageID.setter 161 def nextPageID(self, nextPageID): 162 """Set the identifier of the next page.""" 163 self._nextPageID = nextPageID 147 164 148 165 def setMainWidget(self, widget): … … 278 295 def __init__(self, wizard): 279 296 """Construct the login page.""" 280 super(LoginPage, self).__init__(wizard, xstr("login"),281 xstr("login Help"))297 super(LoginPage, self).__init__(wizard, "login", 298 xstr("login"), xstr("loginHelp")) 282 299 283 300 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 393 410 def _registerClicked(self, button): 394 411 """Called when the Register button was clicked.""" 395 self._wizard.jumpPage( 3)412 self._wizard.jumpPage("register") 396 413 397 414 def _offlineClicked(self, button): … … 432 449 help = xstr("flightsel_help") 433 450 completedHelp = xstr("flightsel_chelp") 434 super(FlightSelectionPage, self).__init__(wizard, xstr("flightsel_title"), 451 super(FlightSelectionPage, self).__init__(wizard, "flightsel", 452 xstr("flightsel_title"), 435 453 help, completedHelp = completedHelp) 436 454 … … 612 630 """Called when the forward button was clicked.""" 613 631 if self._completed: 614 self._wizard.jumpPage(self._next Distance, finalize = False)632 self._wizard.jumpPage(self._nextID, finalize = False) 615 633 else: 616 634 self._flightSelected() … … 667 685 const.PLANE_AWAY) 668 686 else: 669 self._next Distance = 4670 self._wizard.jumpPage( 4)687 self._nextID = "connect" 688 self._wizard.jumpPage("connect") 671 689 672 690 def _fleetRetrieved(self, fleet): 673 691 """Called when the fleet has been retrieved.""" 674 692 if fleet is None: 675 self._next Distance = 4676 self._wizard.jumpPage( 4)693 self._nextID = "connect" 694 self._wizard.jumpPage("connect") 677 695 else: 678 696 plane = fleet[self._wizard._bookedFlight.tailNumber] 679 697 if plane is None: 680 self._next Distance = 4681 self._wizard.jumpPage( 4)698 self._nextID = "connect" 699 self._wizard.jumpPage("connect") 682 700 elif plane.gateNumber is not None and \ 683 701 not fleet.isGateConflicting(plane): 684 702 self._wizard._departureGate = plane.gateNumber 685 self._next Distance = 4686 self._wizard.jumpPage( 4)703 self._nextID = "connect" 704 self._wizard.jumpPage("connect") 687 705 else: 688 self._next Distance = 1689 self._wizard. nextPage()706 self._nextID = "gatesel" 707 self._wizard.jumpPage("gatesel") 690 708 691 709 def _planeUpdated(self, success): 692 710 """Callback for the plane updating.""" 693 self._next Distance = 4694 self._wizard.jumpPage( 4)711 self._nextID = "connect" 712 self._wizard.jumpPage("connect") 695 713 696 714 def _getSaveDialog(self): … … 795 813 def __init__(self, wizard): 796 814 """Construct the gate selection page.""" 797 super(GateSelectionPage, self).__init__(wizard, xstr("gatesel_title"), 815 super(GateSelectionPage, self).__init__(wizard, "gatesel", 816 xstr("gatesel_title"), 798 817 xstr("gatesel_help")) 799 818 … … 858 877 self._gateSelected() 859 878 else: 860 self._wizard.jumpPage( 3)879 self._wizard.jumpPage("connect") 861 880 862 881 def _rowActivated(self, flightList, path, column): … … 880 899 """Callback for the plane updating call.""" 881 900 if success is None or success: 882 self._wizard.jumpPage( 3)901 self._wizard.jumpPage("connect") 883 902 else: 884 903 dialog = gtk.MessageDialog(parent = self._wizard.gui.mainWindow, … … 896 915 """Called when the fleet has been retrieved.""" 897 916 if fleet is None: 898 self._wizard.jumpPage( 3)917 self._wizard.jumpPage("connect") 899 918 else: 900 919 self.activate() … … 916 935 def __init__(self, wizard): 917 936 """Construct the registration page.""" 918 super(RegisterPage, self).__init__(wizard, xstr("register_title"), 937 super(RegisterPage, self).__init__(wizard, "register", 938 xstr("register_title"), 919 939 xstr("register_help")) 920 940 … … 1170 1190 def __init__(self, wizard): 1171 1191 """Construct the student page.""" 1172 super(StudentPage, self).__init__(wizard, xstr("student_title"), 1192 super(StudentPage, self).__init__(wizard, "student", 1193 xstr("student_title"), 1173 1194 xstr("student_help")) 1174 1195 … … 1183 1204 "Then press the Connect button to connect to the simulator." 1184 1205 completedHelp = "The basic data of your flight can be read below." 1185 super(ConnectPage, self).__init__(wizard, xstr("connect_title"), 1206 super(ConnectPage, self).__init__(wizard, "connect", 1207 xstr("connect_title"), 1186 1208 xstr("connect_help"), 1187 1209 completedHelp = xstr("connect_chelp")) … … 1366 1388 def __init__(self, wizard): 1367 1389 """Construct the page.""" 1368 super(PayloadPage, self).__init__(wizard, xstr("payload_title"), 1390 super(PayloadPage, self).__init__(wizard, "payload", 1391 xstr("payload_title"), 1369 1392 xstr("payload_help"), 1370 1393 completedHelp = xstr("payload_chelp")) … … 1593 1616 current time from the flight simulator.""" 1594 1617 def __init__(self, wizard): 1595 super(TimePage, self).__init__(wizard, xstr("time_title"), 1618 super(TimePage, self).__init__(wizard, "time", 1619 xstr("time_title"), 1596 1620 xstr("time_help"), 1597 1621 completedHelp = xstr("time_chelp")) … … 1714 1738 def __init__(self, wizard): 1715 1739 """Construct the page.""" 1716 super(RoutePage, self).__init__(wizard, xstr("route_title"), 1740 super(RoutePage, self).__init__(wizard, "route", 1741 xstr("route_title"), 1717 1742 xstr("route_help"), 1718 1743 completedHelp = xstr("route_chelp")) … … 1882 1907 if self._wizard.gui.config.useSimBrief and \ 1883 1908 self._wizard.usingSimBrief is not False: 1884 self._wizard. nextPage()1909 self._wizard.jumpPage("simbrief_setup") 1885 1910 else: 1886 1911 self._wizard.usingSimBrief = False 1887 self._wizard.jumpPage( 3)1912 self._wizard.jumpPage("fuel") 1888 1913 1889 1914 #----------------------------------------------------------------------------- … … 2044 2069 """Construct the setup page.""" 2045 2070 2046 super(SimBriefSetupPage, self).__init__(wizard, 2071 super(SimBriefSetupPage, self).__init__(wizard, "simbrief_setup", 2047 2072 xstr("simbrief_setup_title"), 2048 2073 xstr("simbrief_setup_help"), … … 2363 2388 2364 2389 self._wizard.usingSimBrief = False 2365 self._wizard.jumpPage( 2, fromPageShift = 1)2390 self._wizard.jumpPage("fuel", fromPageShift = 1) 2366 2391 2367 2392 def _getPlan(self): … … 2448 2473 """Construct the setup page.""" 2449 2474 2450 super(SimBriefingPage, self).__init__(wizard, 2475 super(SimBriefingPage, self).__init__(wizard, "simbrief_result", 2451 2476 xstr("simbrief_result_title"), "") 2452 2477 … … 2704 2729 def __init__(self, wizard): 2705 2730 """Construct the page.""" 2706 super(FuelPage, self).__init__(wizard, xstr("fuel_title"), 2731 super(FuelPage, self).__init__(wizard, "fuel", 2732 xstr("fuel_title"), 2707 2733 xstr("fuel_help_pre") + 2708 2734 xstr("fuel_help_post"), … … 2756 2782 self._pump() 2757 2783 elif self._wizard.usingSimBrief: 2758 self._wizard.jumpPage( 3)2784 self._wizard.jumpPage("takeoff") 2759 2785 else: 2760 self._wizard. nextPage()2786 self._wizard.jumpPage("briefing1") 2761 2787 2762 2788 def _setupTanks(self, tankData): … … 2804 2830 if self._wizard.usingSimBrief: 2805 2831 self._wizard.gui.startMonitoring() 2806 self._wizard.jumpPage( 3)2832 self._wizard.jumpPage("takeoff") 2807 2833 else: 2808 2834 bookedFlight = self._wizard._bookedFlight … … 2873 2899 self._departure = departure 2874 2900 2875 title = xstr("briefing_title") % (1 if departure else 2, 2901 number = 1 if departure else 2 2902 2903 title = xstr("briefing_title") % (number, 2876 2904 xstr("briefing_departure") 2877 2905 if departure 2878 2906 else xstr("briefing_arrival")) 2879 super(BriefingPage, self).__init__(wizard, title, xstr("briefing_help"), 2907 super(BriefingPage, self).__init__(wizard, 2908 "briefing%d" % (number,), 2909 title, xstr("briefing_help"), 2880 2910 completedHelp = xstr("briefing_chelp")) 2881 2911 … … 3064 3094 def __init__(self, wizard): 3065 3095 """Construct the takeoff page.""" 3066 super(TakeoffPage, self).__init__(wizard, xstr("takeoff_title"), 3096 super(TakeoffPage, self).__init__(wizard, "takeoff", 3097 xstr("takeoff_title"), 3067 3098 xstr("takeoff_help"), 3068 3099 completedHelp = xstr("takeoff_chelp")) … … 3552 3583 def __init__(self, wizard): 3553 3584 """Construct the page.""" 3554 super(CruisePage, self).__init__(wizard, xstr("cruise_title"), 3585 super(CruisePage, self).__init__(wizard, "cruise", 3586 xstr("cruise_title"), 3555 3587 xstr("cruise_help")) 3556 3588 … … 3666 3698 def __init__(self, wizard): 3667 3699 """Construct the landing page.""" 3668 super(LandingPage, self).__init__(wizard, xstr("landing_title"), 3700 super(LandingPage, self).__init__(wizard, "landing", 3701 xstr("landing_title"), 3669 3702 xstr("landing_help"), 3670 3703 completedHelp = xstr("landing_chelp")) … … 3980 4013 """Construct the finish page.""" 3981 4014 help = xstr("finish_help") + xstr("finish_help_goodtime") 3982 super(FinishPage, self).__init__(wizard, xstr("finish_title"), help) 4015 super(FinishPage, self).__init__(wizard, "finish", 4016 xstr("finish_title"), help) 3983 4017 3984 4018 alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5, … … 4835 4869 def nextPage(self, finalize = True): 4836 4870 """Go to the next page.""" 4837 self.jumpPage(1, finalize) 4838 4839 def jumpPage(self, count, finalize = True, fromPageShift = None): 4871 nextPageID = self._pages[self._currentPage].nextPageID 4872 self.jumpPage(1 if nextPageID is None else nextPageID, finalize) 4873 4874 def jumpPage(self, countOrID, finalize = True, fromPageShift = None): 4840 4875 """Go to the page which is 'count' pages after the current one.""" 4841 self.setCurrentPage(self._currentPage + count, 4876 if isinstance(countOrID, str): 4877 targetIndex = self._getIndexOf(countOrID) 4878 else: 4879 targetIndex = self._currentPage + countOrID 4880 self.setCurrentPage(targetIndex, 4842 4881 finalize = finalize, fromPageShift = fromPageShift) 4843 4882 … … 5071 5110 self._arrivalBriefingPage.setMETAR(metar) 5072 5111 5112 def _getIndexOf(self, pageID): 5113 """Get the index for the given page ID. 5114 5115 It is an assertion failure if the ID is not found.""" 5116 for index in range(0, len(self._pages)): 5117 page = self._pages[index] 5118 if page.id==pageID: 5119 return index 5120 assert False 5121 5073 5122 #-----------------------------------------------------------------------------
Note:
See TracChangeset
for help on using the changeset viewer.