Changeset 621:4f7dbaa010d1


Ignore:
Timestamp:
04/04/15 08:47:36 (10 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

SID, STAR and transition are input using combo boxes (re #258)

File:
1 edited

Legend:

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

    r619 r621  
    5050#-----------------------------------------------------------------------------
    5151
     52comboModel = gtk.ListStore(gobject.TYPE_STRING)
     53comboModel.append(("N/A",))
     54comboModel.append(("VECTORS",))
     55
     56#-----------------------------------------------------------------------------
     57
    5258class Page(gtk.Alignment):
    5359    """A page in the flight wizard."""
     
    21512157        table.attach(label, 0, 1, row, row+1)
    21522158
    2153         self._sid = gtk.Entry()
    2154         self._sid.set_width_chars(10)
     2159        if pygobject:
     2160            self._sid = gtk.ComboBox.new_with_model_and_entry(comboModel)
     2161        else:
     2162            self._sid = gtk.ComboBoxEntry(comboModel)
     2163
     2164        self._sid.set_entry_text_column(0)
     2165        self._sid.get_child().set_width_chars(10)
    21552166        self._sid.set_tooltip_text(xstr("takeoff_sid_tooltip"))
    2156         self._sid.connect("changed", self._upperChanged)
     2167        self._sid.connect("changed", self._upperChangedComboBox)
    21572168        table.attach(self._sid, 1, 3, row, row+1)
    21582169        label.set_mnemonic_widget(self._sid)
     
    22632274    def sid(self):
    22642275        """Get the SID."""
    2265         return self._sid.get_text()
     2276        text = self._sid.get_child().get_text()
     2277        return text if self._sid.get_active()!=0 and text and text!="N/A" \
     2278               else None
    22662279
    22672280    @property
     
    23252338        self._runway.set_text("")
    23262339        self._runway.set_sensitive(True)
    2327         self._sid.set_text("")
     2340        self._sid.set_active(0)
    23282341        self._sid.set_sensitive(True)
    23292342        self._v1.set_int(None)
     
    23932406    def _updateForwardButton(self):
    23942407        """Update the sensitivity of the forward button based on some conditions."""
    2395 
    23962408        sensitive = self._forwardAllowed and \
    23972409                    self._metar.get_text()!="" and \
    23982410                    self._runway.get_text()!="" and \
    2399                     self._sid.get_text()!="" and \
     2411                    self.sid is not None and \
    24002412                    self.v1 is not None and \
    24012413                    self.vr is not None and \
     
    24222434        entry.set_text(entry.get_text().upper())
    24232435        self._valueChanged(entry, arg)
     2436
     2437    def _upperChangedComboBox(self, comboBox):
     2438        """Called for combo box widgets that must be converted to uppercase."""
     2439        entry = comboBox.get_child()
     2440        if comboBox.get_active()==-1:
     2441            entry.set_text(entry.get_text().upper())
     2442        self._valueChanged(entry)
    24242443
    24252444    def _derateChanged(self, entry):
     
    27092728        row += 1
    27102729
    2711         self._starButton = gtk.CheckButton()
    2712         self._starButton.connect("clicked", self._starButtonClicked)
    2713         table.attach(self._starButton, 0, 1, row, row + 1)
    2714 
    27152730        label = gtk.Label(xstr("landing_star"))
    27162731        label.set_use_underline(True)
     
    27182733        table.attach(label, 1, 2, row, row + 1)
    27192734
    2720         self._star = gtk.Entry()
    2721         self._star.set_width_chars(10)
     2735        if pygobject:
     2736            self._star = gtk.ComboBox.new_with_model_and_entry(comboModel)
     2737        else:
     2738            self._star = gtk.ComboBoxEntry(comboModel)
     2739
     2740        self._star.set_entry_text_column(0)
     2741        self._star.get_child().set_width_chars(10)
    27222742        self._star.set_tooltip_text(xstr("landing_star_tooltip"))
    2723         self._star.connect("changed", self._upperChanged)
     2743        self._star.connect("changed", self._upperChangedComboBox)
    27242744        self._star.set_sensitive(False)
    27252745        table.attach(self._star, 2, 4, row, row + 1)
    2726         label.set_mnemonic_widget(self._starButton)
     2746        label.set_mnemonic_widget(self._star)
    27272747
    27282748        row += 1
    2729 
    2730         self._transitionButton = gtk.CheckButton()
    2731         self._transitionButton.connect("clicked", self._transitionButtonClicked)
    2732         table.attach(self._transitionButton, 0, 1, row, row + 1)
    27332749
    27342750        label = gtk.Label(xstr("landing_transition"))
     
    27372753        table.attach(label, 1, 2, row, row + 1)
    27382754
    2739         self._transition = gtk.Entry()
    2740         self._transition.set_width_chars(10)
     2755        if pygobject:
     2756            self._transition = gtk.ComboBox.new_with_model_and_entry(comboModel)
     2757        else:
     2758            self._transition = gtk.ComboBoxEntry(comboModel)
     2759
     2760        self._transition.set_entry_text_column(0)
     2761        self._transition.get_child().set_width_chars(10)
    27412762        self._transition.set_tooltip_text(xstr("landing_transition_tooltip"))
    2742         self._transition.connect("changed", self._upperChanged)
     2763        self._transition.connect("changed", self._upperChangedComboBox)
    27432764        self._transition.set_sensitive(False)
    27442765        table.attach(self._transition, 2, 4, row, row + 1)
    2745         label.set_mnemonic_widget(self._transitionButton)
     2766        label.set_mnemonic_widget(self._transition)
    27462767
    27472768        row += 1
     
    28042825        self._button = self.addNextButton(clicked = self._forwardClicked)
    28052826
    2806         # These are needed for correct size calculations
    2807         self._starButton.set_active(True)
    2808         self._transitionButton.set_active(True)
    2809 
    28102827        self._active = False
    28112828
     
    28132830    def star(self):
    28142831        """Get the STAR or None if none entered."""
    2815         return self._star.get_text() if self._starButton.get_active() else None
     2832        text = self._star.get_child().get_text()
     2833        return text if self._star.get_active()!=0 and text and text!="N/A" \
     2834               else None
    28162835
    28172836    @property
    28182837    def transition(self):
    28192838        """Get the transition or None if none entered."""
    2820         return self._transition.get_text() \
    2821                if self._transitionButton.get_active() else None
     2839        text = self._transition.get_child().get_text()
     2840        return text if self._transition.get_active()!=0 and text and text!="N/A" \
     2841               else None
    28222842
    28232843    @property
     
    28602880        self._updatingMETAR = False
    28612881
    2862         self._starButton.set_sensitive(True)
    2863         self._starButton.set_active(False)
    2864         self._star.set_text("")
    2865 
    2866         self._transitionButton.set_sensitive(True)
    2867         self._transitionButton.set_active(False)
    2868         self._transition.set_text("")
     2882        self._star.set_active(0)
     2883        self._star.set_sensitive(True)
     2884
     2885        self._transition.set_active(0)
     2886        self._transition.set_sensitive(True)
    28692887
    28702888        self._runway.set_text("")
     
    29052923            self._updateForwardButton()
    29062924
    2907     def _starButtonClicked(self, button):
    2908         """Called when the STAR button is clicked."""
    2909         active = button.get_active()
    2910         self._star.set_sensitive(active)
    2911         if active:
    2912             self._star.grab_focus()
    2913         self._updateForwardButton()
    2914 
    2915     def _transitionButtonClicked(self, button):
    2916         """Called when the Transition button is clicked."""
    2917         active = button.get_active()
    2918         self._transition.set_sensitive(active)
    2919         if active:
    2920             self._transition.grab_focus()
    2921         self._updateForwardButton()
    2922 
    29232925    def _updateForwardButton(self):
    29242926        """Update the sensitivity of the forward button."""
     2927        self._flightEnded = True
    29252928        sensitive = self._flightEnded and \
    29262929                    self._metar.get_text()!="" and \
    2927                     (self._starButton.get_active() or \
    2928                      self._transitionButton.get_active()) and \
    2929                     (self._star.get_text()!="" or
    2930                      not self._starButton.get_active()) and \
    2931                     (self._transition.get_text()!="" or
    2932                      not self._transitionButton.get_active()) and \
     2930                    (self.star is not None or
     2931                     self.transition is not None) and \
    29332932                    self._runway.get_text()!="" and \
    29342933                    self._approachType.get_text()!="" and \
     
    29392938        """Called for entry widgets that must be converted to uppercase."""
    29402939        entry.set_text(entry.get_text().upper())
     2940        self._updateForwardButton()
     2941
     2942    def _upperChangedComboBox(self, comboBox):
     2943        """Called for combo box widgets that must be converted to uppercase."""
     2944        if comboBox.get_active()==-1:
     2945            entry = comboBox.get_child()
     2946            entry.set_text(entry.get_text().upper())
    29412947        self._updateForwardButton()
    29422948
     
    38833889
    38843890        self.setCurrentPage(firstPage)
    3885         #self.setCurrentPage(13)
     3891        #self.setCurrentPage(10)
    38863892
    38873893    def login(self, callback, pilotID, password, entranceExam):
Note: See TracChangeset for help on using the changeset viewer.