Changeset 94:dc8fbc53a90c


Ignore:
Timestamp:
04/21/12 08:32:39 (13 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Implemented the beginnings of the main menu and the separate debug log tab

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/mlx/gui/flight.py

    r93 r94  
    3333class Page(gtk.Alignment):
    3434    """A page in the flight wizard."""
    35     def __init__(self, wizard, title, help):
     35    def __init__(self, wizard, title, help, completedHelp = None):
    3636        """Construct the page."""
    3737        super(Page, self).__init__(xalign = 0.0, yalign = 0.0,
     
    7575       
    7676        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.0,
    77                                   xscale = 0, yscale = 0.0)
     77                                  xscale = 0.0, yscale = 0.0)
    7878        alignment.set_padding(padding_top = 0, padding_bottom = 16,
    7979                              padding_left = 0, padding_right = 0)
    8080
    81         label = gtk.Label(help)
    82         label.set_justify(gtk.Justification.CENTER if pygobject
    83                           else gtk.JUSTIFY_CENTER)
    84         label.set_use_markup(True)
    85         alignment.add(label)
     81        self._help = help
     82        self._completedHelp = completedHelp
     83
     84        if self._completedHelp is None or \
     85           len(help.splitlines())>=len(completedHelp.splitlines()):
     86            longerHelp = help
     87        else:
     88            longerHelp = completedHelp
     89       
     90        self._helpLabel = gtk.Label(completedHelp)
     91        # FIXME: should be a constant in common
     92        self._helpLabel.set_justify(gtk.Justification.CENTER if pygobject
     93                                    else gtk.JUSTIFY_CENTER)
     94        self._helpLabel.set_use_markup(True)
     95        alignment.add(self._helpLabel)
    8696        mainBox.pack_start(alignment, False, False, 0)
    8797
     
    103113        self._wizard = wizard
    104114
    105         self._finalized = False
     115        self._completed = False
    106116        self._fromPage = None
    107117
     
    122132        return button
    123133
     134    def initialize(self):
     135        """Initialize the page.
     136
     137        It sets up the primary help, and calls the activate() function."""
     138        self._helpLabel.set_markup(self._help)
     139        self._helpLabel.set_sensitive(True)
     140        self.activate()
     141
    124142    def activate(self):
    125143        """Called when this page becomes active.
     
    127145        This default implementation does nothing."""
    128146        pass
     147
     148    def complete(self):
     149        """Called when the page is completed.
     150
     151        It greys out/changes the help text and then calls finalize()."""
     152        self.finalize()
     153        if self._completedHelp is None:
     154            self._helpLabel.set_sensitive(False)
     155        else:
     156            self._helpLabel.set_markup(self._completedHelp)
     157        self._completed = True
    129158
    130159    def finalize(self):
     
    139168    def reset(self):
    140169        """Reset the page if the wizard is reset."""
    141         self._finalized = False
     170        self._completed = False
    142171        self._fromPage = None
    143172
     
    282311    def __init__(self, wizard):
    283312        """Construct the flight selection page."""
     313        help = "Select the flight you want to perform."
     314        completedHelp = "You have selected the flight highlighted below."
    284315        super(FlightSelectionPage, self).__init__(wizard, "Flight selection",
    285                                                   "Select the flight you want "
    286                                                   "to perform.")
     316                                                  help, completedHelp = completedHelp)
    287317
    288318
     
    349379    def _forwardClicked(self, button):
    350380        """Called when the forward button was clicked."""
    351         if self._finalized:
     381        if self._completed:
    352382            self._wizard.jumpPage(self._nextDistance, finalize = False)
    353383        else:
     
    466496    def _forwardClicked(self, button):
    467497        """Called when the forward button is clicked."""
    468         if not self._finalized:
     498        if not self._completed:
    469499            selection = self._gateList.get_selection()
    470500            (listStore, iter) = selection.get_selected()
     
    510540               "at the given airport, at the gate below, if present.\n\n" \
    511541               "Then press the Connect button to connect to the simulator."
     542        completedHelp = "The basic data of your flight can be read below."
    512543        super(ConnectPage, self).__init__(wizard,
    513544                                          "Connect to the simulator",
    514                                           help)
     545                                          help, completedHelp = completedHelp)
    515546       
    516547        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     
    643674               "Setup the cargo weight here and the payload weight in the simulator.\n\n" \
    644675               "You can also check here what the simulator reports as ZFW."
    645                
    646         super(PayloadPage, self).__init__(wizard, "Payload", help)
     676        completedHelp = "You can see the weights in the briefing\n" \
     677                        "and the cargo weight you have selected below.\n\n" \
     678                        "You can also query the ZFW reported by the simulator."
     679        super(PayloadPage, self).__init__(wizard, "Payload", help,
     680                                          completedHelp = completedHelp)
    647681
    648682        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     
    760794        """Finalize the payload page."""
    761795        self._cargoWeight.set_sensitive(False)
    762         self._zfwButton.set_sensitive(False)
    763796
    764797    def calculateZFW(self):
     
    828861               "You can also query the current UTC time from the simulator.\n" \
    829862               "Ensure that you have enough time to properly prepare for the flight."
    830                
    831         super(TimePage, self).__init__(wizard, "Time", help)
     863        completedHelp = "The departure and arrival times are displayed below in UTC.\n\n" \
     864                        "You can also query the current UTC time from the simulator.\n"
     865        super(TimePage, self).__init__(wizard, "Time", help,
     866                                       completedHelp = completedHelp)
    832867
    833868        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     
    881916        self._arrival.set_text(str(bookedFlight.arrivalTime.time()))
    882917        self._simulatorTime.set_text("-")
    883 
    884     def finalize(self):
    885         """Finalize the page."""
    886         self._timeButton.set_sensitive(False)
    887918
    888919    def _timeRequested(self, button):
     
    939970        help = "Set your cruise flight level below, and\n" \
    940971               "if necessary, edit the flight plan."
    941                
    942         super(RoutePage, self).__init__(wizard, "Route", help)
     972        completedHelp = "If necessary, you can modify the cruise level and\n" \
     973                        "the flight plan below during flight.\n" \
     974                        "If so, please, add a comment on why " \
     975                        "the modification became necessary."
     976        super(RoutePage, self).__init__(wizard, "Route", help,
     977                                        completedHelp = completedHelp)
    943978
    944979        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     
    10151050    def activate(self):
    10161051        """Setup the route from the booked flight."""
    1017         self._route.set_sensitive(True)
    10181052        self._cruiseLevel.set_value(240)
    1019         self._cruiseLevel.set_sensitive(True)
    10201053        self._route.get_buffer().set_text(self._wizard._bookedFlight.route)
    10211054        self._updateForwardButton()
    1022 
    1023     def finalize(self):
    1024         """Finalize the page."""
    1025         self._route.set_sensitive(False)
    1026         self._cruiseLevel.set_sensitive(False)
    10271055
    10281056    def _getRoute(self):
     
    10511079    def _forwardClicked(self, button):
    10521080        """Called when the Forward button is clicked."""
    1053         if self._finalized:
     1081        if self._completed:
    10541082            self._wizard.nextPage()
    10551083        else:
    1056             self._backButton.set_sensitive(False)
    1057             self._button.set_sensitive(False)
    1058             self._cruiseLevel.set_sensitive(False)
    1059             self._route.set_sensitive(False)
    1060 
    10611084            bookedFlight = self._wizard._bookedFlight
    10621085            self._wizard.gui.beginBusy("Downloading NOTAMs...")
     
    11161139                                         else "arrival")
    11171140                                                               
    1118         help = "Read carefully the NOTAMs and METAR below."
    1119 
    1120         super(BriefingPage, self).__init__(wizard, title, help)
     1141        help = "Read carefully the NOTAMs and METAR below.\n\n" \
     1142               "You can edit the METAR if your simulator or network\n" \
     1143               "provides different weather."
     1144        completedHelp = "If your simulator or network provides a different\n" \
     1145                        "weather, you can edit the METAR below."
     1146        super(BriefingPage, self).__init__(wizard, title, help,
     1147                                           completedHelp = completedHelp)
    11211148
    11221149        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     
    11311158        scrolledWindow = gtk.ScrolledWindow()
    11321159        scrolledWindow.set_size_request(-1, 128)
     1160        # FIXME: these constants should be in common
    11331161        scrolledWindow.set_policy(gtk.PolicyType.AUTOMATIC if pygobject
    11341162                                  else gtk.POLICY_AUTOMATIC,
     
    11571185                                  else gtk.POLICY_AUTOMATIC)
    11581186        self._metar = gtk.TextView()
    1159         self._metar.set_editable(False)
    11601187        self._metar.set_accepts_tab(False)
    11611188        self._metar.set_wrap_mode(gtk.WrapMode.WORD if pygobject else gtk.WRAP_WORD)
     
    12271254        """Called when the forward button is clicked."""
    12281255        if not self._departure:
    1229             if not self._finalized:
     1256            if not self._completed:
    12301257                self._wizard.gui.startMonitoring()
    12311258                self._button.set_use_stock(True)
    12321259                self._button.set_label(gtk.STOCK_GO_FORWARD)
    1233                 self._finalized = True
     1260                self.complete()
    12341261
    12351262        self._wizard.nextPage()
     
    12421269        """Construct the takeoff page."""
    12431270        help = "Enter the runway and SID used, as well as the speeds."
    1244 
    1245         super(TakeoffPage, self).__init__(wizard, "Takeoff", help)
     1271        completedHelp = "The runway, SID and takeoff speeds logged can be seen below."
     1272
     1273        super(TakeoffPage, self).__init__(wizard, "Takeoff", help,
     1274                                          completedHelp = completedHelp)
    12461275
    12471276        alignment = gtk.Alignment(xalign = 0.5, yalign = 0.5,
     
    13811410        help = "Enter the STAR and/or transition, runway,\n" \
    13821411               "approach type and V<sub>Ref</sub> used."
    1383 
    1384         super(LandingPage, self).__init__(wizard, "Landing", help)
     1412        completedHelp = "The STAR and/or transition, runway, approach\n" \
     1413                        "type and V<sub>Ref</sub> logged can be seen below."
     1414
     1415        super(LandingPage, self).__init__(wizard, "Landing", help,
     1416                                          completedHelp = completedHelp)
    13851417
    13861418        self._flightEnded = False
     
    16581690        table.attach(labelAlignment, 1, 2, 4, 5)
    16591691
     1692        button = self.addButton(gtk.STOCK_GO_BACK)
     1693        button.set_use_stock(True)
     1694        button.connect("clicked", self._backClicked)
     1695
    16601696        self._saveButton = self.addButton("S_ave PIREP...")
    16611697        self._saveButton.set_use_underline(True)
     1698        self._saveButton.set_sensitive(False)
    16621699        #self._saveButton.connect("clicked", self._saveClicked)
    16631700       
    16641701        self._sendButton = self.addButton("_Send PIREP...", True)
    16651702        self._sendButton.set_use_underline(True)
     1703        self._sendButton.set_sensitive(False)
    16661704        #self._sendButton.connect("clicked", self._sendClicked)
    16671705
     
    16891727                                  (flight.endFuel - flight.startFuel,))
    16901728
     1729    def _backClicked(self, button):
     1730        """Called when the Back button is pressed."""
     1731        self.goBack()
     1732       
    16911733#-----------------------------------------------------------------------------
    16921734
     
    17461788        if fromPage is not None:
    17471789            page = self._pages[fromPage]
    1748             if finalize and not page._finalized:
    1749                 page.finalize()
    1750                 page._finalized = True
     1790            if finalize and not page._completed:
     1791                page.complete()
    17511792            self.remove(page)
    17521793
     
    17561797        if page._fromPage is None:
    17571798            page._fromPage = fromPage
    1758             page.activate()
     1799            page.initialize()
    17591800        self.show_all()
    17601801        if fromPage is not None:
Note: See TracChangeset for help on using the changeset viewer.