Ignore:
Timestamp:
03/19/23 13:28:59 (20 months ago)
Author:
István Váradi <ivaradi@…>
Branch:
python3
Phase:
public
amend_source:
0d69ca1836814137b601f24493e4d718c56b12b7
Message:

It is possible to provide an extra parameter for the SimBrief cruise profile.

File:
1 edited

Legend:

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

    r1086 r1087  
    33803380        self._cruiseProfile.add_attribute(renderer, "text", 0)
    33813381        self._cruiseProfile.set_tooltip_text(xstr("simbrief_cruise_profile_tooltip"))
     3382        self._cruiseProfile.connect("changed", self._cruiseProfileChanged)
    33823383        table.attach(self._cruiseProfile, 1, 2, row, row+1)
    33833384        label.set_mnemonic_widget(self._cruiseProfile)
     3385
     3386        self._cruiseParameter = Gtk.Entry()
     3387        self._cruiseParameter.set_width_chars(5)
     3388        self._cruiseParameter.set_tooltip_text(xstr("simbrief_cruise_parameter_tooltip"))
     3389        self._cruiseParameter.set_sensitive(False)
     3390        self._cruiseParameter.connect("changed", self._cruiseParameterChanged)
     3391        table.attach(self._cruiseParameter, 2, 3, row, row+1)
     3392
    33843393        row += 1
    33853394
     
    34543463        """Update the sensitivity of the forward button."""
    34553464        self._button.set_sensitive(True)
    3456         self._button.set_sensitive(len(self._userName.get_text())>0 and
    3457                                    len(self._password.get_text())>0)
     3465
     3466        sensitive = not self._useInternalBrowser.get_active() or \
     3467           (len(self._userName.get_text())>0 and
     3468            len(self._password.get_text())>0)
     3469        if sensitive:
     3470            simBriefData = self._wizard.gui.flight.aircraft.simBriefData
     3471            cruiseProfileIndex = self._cruiseProfile.get_active()
     3472            sensitive = \
     3473                cruiseProfileIndex not in simBriefData.cruiseParameters or \
     3474                not simBriefData.cruiseParameters[cruiseProfileIndex][0] or \
     3475                len(self._cruiseParameter.get_text())>0
     3476
     3477        self._button.set_sensitive(sensitive)
    34583478
    34593479    def _backClicked(self, button):
     
    35173537        self._climbProfile.set_sensitive(False)
    35183538        self._cruiseProfile.set_sensitive(False)
     3539        self._cruiseParameter.set_sensitive(False)
    35193540        self._descentProfile.set_sensitive(False)
    35203541
     
    36943715            plan[key] = value
    36953716
     3717        cruiseParameters = self._wizard.gui.flight.aircraft.simBriefData.cruiseParameters
     3718        cruiseProfileIndex = self._cruiseProfile.get_active()
     3719        if cruiseProfileIndex in cruiseParameters:
     3720            value = self._cruiseParameter.get_text()
     3721            if value:
     3722                plan[cruiseParameters[cruiseProfileIndex][1]] = value
     3723
    36963724        return plan
    36973725
     
    37303758        should be converted to uppercase."""
    37313759        entry.set_text(entry.get_text().upper())
     3760
     3761    def _cruiseProfileChanged(self, comboBox):
     3762        """Called when the cruise profile has changed.
     3763
     3764        It updates the sensitivity of the cruise parameter entry field"""
     3765        simBriefData = self._wizard.gui.flight.aircraft.simBriefData
     3766
     3767        activeIndex = self._cruiseProfile.get_active()
     3768        self._cruiseParameter.set_sensitive(activeIndex in
     3769                                            simBriefData.cruiseParameters)
     3770
     3771        self._updateForwardButton()
     3772
     3773    def _cruiseParameterChanged(self, entry):
     3774        """Called when the cruise parameter has changed.
     3775
     3776        The sensitivty of the Forward button will be updated"""
     3777        self._updateForwardButton()
    37323778
    37333779    def _getResults(self, link):
Note: See TracChangeset for help on using the changeset viewer.