Ignore:
Timestamp:
12/23/14 08:38:54 (10 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

Added the arrival METAR field to the landing page (re #235)

File:
1 edited

Legend:

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

    r588 r589  
    26692669                                  xscale = 0.0, yscale = 0.0)
    26702670
    2671         table = gtk.Table(6, 5)
     2671        table = gtk.Table(7, 24)
    26722672        table.set_row_spacings(4)
    26732673        table.set_col_spacings(16)
     
    26762676        self.setMainWidget(alignment)
    26772677
     2678        row = 0
     2679
     2680        label = gtk.Label(xstr("landing_metar"))
     2681        label.set_use_underline(True)
     2682        label.set_alignment(0.0, 0.5)
     2683        table.attach(label, 0, 1, row, row+1)
     2684
     2685        self._metar = gtk.Entry()
     2686        self._metar.set_width_chars(40)
     2687        self._metar.connect("changed", self._metarChanged)
     2688        self._metar.get_buffer().connect_after("inserted-text", self._metarInserted)
     2689        table.attach(self._metar, 1, 24, row, row+1)
     2690        label.set_mnemonic_widget(self._metar)
     2691
     2692        self._updatingMETAR = False
     2693
     2694        row += 1
     2695
    26782696        self._starButton = gtk.CheckButton()
    26792697        self._starButton.connect("clicked", self._starButtonClicked)
    2680         table.attach(self._starButton, 0, 1, 0, 1)
     2698        table.attach(self._starButton, 0, 1, row, row + 1)
    26812699
    26822700        label = gtk.Label(xstr("landing_star"))
    26832701        label.set_use_underline(True)
    26842702        label.set_alignment(0.0, 0.5)
    2685         table.attach(label, 1, 2, 0, 1)
     2703        table.attach(label, 1, 2, row, row + 1)
    26862704
    26872705        self._star = gtk.Entry()
     
    26902708        self._star.connect("changed", self._upperChanged)
    26912709        self._star.set_sensitive(False)
    2692         table.attach(self._star, 2, 4, 0, 1)
     2710        table.attach(self._star, 2, 4, row, row + 1)
    26932711        label.set_mnemonic_widget(self._starButton)
     2712
     2713        row += 1
    26942714
    26952715        self._transitionButton = gtk.CheckButton()
    26962716        self._transitionButton.connect("clicked", self._transitionButtonClicked)
    2697         table.attach(self._transitionButton, 0, 1, 1, 2)
     2717        table.attach(self._transitionButton, 0, 1, row, row + 1)
    26982718
    26992719        label = gtk.Label(xstr("landing_transition"))
    27002720        label.set_use_underline(True)
    27012721        label.set_alignment(0.0, 0.5)
    2702         table.attach(label, 1, 2, 1, 2)
     2722        table.attach(label, 1, 2, row, row + 1)
    27032723
    27042724        self._transition = gtk.Entry()
     
    27072727        self._transition.connect("changed", self._upperChanged)
    27082728        self._transition.set_sensitive(False)
    2709         table.attach(self._transition, 2, 4, 1, 2)
     2729        table.attach(self._transition, 2, 4, row, row + 1)
    27102730        label.set_mnemonic_widget(self._transitionButton)
     2731
     2732        row += 1
    27112733
    27122734        label = gtk.Label(xstr("landing_runway"))
    27132735        label.set_use_underline(True)
    27142736        label.set_alignment(0.0, 0.5)
    2715         table.attach(label, 1, 2, 2, 3)
     2737        table.attach(label, 1, 2, row, row + 1)
    27162738
    27172739        self._runway = gtk.Entry()
     
    27192741        self._runway.set_tooltip_text(xstr("landing_runway_tooltip"))
    27202742        self._runway.connect("changed", self._upperChanged)
    2721         table.attach(self._runway, 2, 4, 2, 3)
     2743        table.attach(self._runway, 2, 4, row, row + 1)
    27222744        label.set_mnemonic_widget(self._runway)
     2745
     2746        row += 1
    27232747
    27242748        label = gtk.Label(xstr("landing_approach"))
    27252749        label.set_use_underline(True)
    27262750        label.set_alignment(0.0, 0.5)
    2727         table.attach(label, 1, 2, 3, 4)
     2751        table.attach(label, 1, 2, row, row + 1)
    27282752
    27292753        self._approachType = gtk.Entry()
     
    27312755        self._approachType.set_tooltip_text(xstr("landing_approach_tooltip"))
    27322756        self._approachType.connect("changed", self._upperChanged)
    2733         table.attach(self._approachType, 2, 4, 3, 4)
     2757        table.attach(self._approachType, 2, 4, row, row + 1)
    27342758        label.set_mnemonic_widget(self._approachType)
     2759
     2760        row += 1
    27352761
    27362762        label = gtk.Label(xstr("landing_vref"))
     
    27382764        label.set_use_underline(True)
    27392765        label.set_alignment(0.0, 0.5)
    2740         table.attach(label, 1, 2, 4, 5)
     2766        table.attach(label, 1, 2, row, row + 1)
    27412767
    27422768        self._vref = IntegerEntry()
     
    27442770        self._vref.set_tooltip_markup(xstr("landing_vref_tooltip_knots"))
    27452771        self._vref.connect("integer-changed", self._vrefChanged)
    2746         table.attach(self._vref, 3, 4, 4, 5)
     2772        table.attach(self._vref, 3, 4, row, row + 1)
    27472773        label.set_mnemonic_widget(self._vref)
    27482774
    27492775        self._vrefUnit = gtk.Label(xstr("label_knots"))
    2750         table.attach(self._vrefUnit, 4, 5, 4, 5)
     2776        table.attach(self._vrefUnit, 4, 5, row, row + 1)
     2777
     2778        row += 1
    27512779
    27522780        self._antiIceOn = gtk.CheckButton(xstr("landing_antiice"))
    27532781        self._antiIceOn.set_use_underline(True)
    27542782        self._antiIceOn.set_tooltip_text(xstr("landing_antiice_tooltip"))
    2755         table.attach(self._antiIceOn, 3, 5, 5, 6)
     2783        table.attach(self._antiIceOn, 3, 5, row, row + 1)
    27562784
    27572785        self.addCancelFlightButton()
     
    27642792        self._starButton.set_active(True)
    27652793        self._transitionButton.set_active(True)
     2794
     2795        self._active = False
    27662796
    27672797    @property
     
    28072837        self._antiIceOn.set_active(False)
    28082838        self._flightEnded = False
     2839        self._active = False
    28092840
    28102841    def activate(self):
    28112842        """Called when the page is activated."""
     2843        self._updatingMETAR = True
     2844        self._metar.get_buffer().set_text(self._wizard.arrivalMETAR, -1)
     2845        self._updatingMETAR = False
     2846
    28122847        self._starButton.set_sensitive(True)
    28132848        self._starButton.set_active(False)
     
    28352870
    28362871        self._updateForwardButton()
     2872
     2873        self._active = True
    28372874
    28382875    def flightEnded(self):
     
    28412878        self._flightEnded = True
    28422879        self._updateForwardButton()
     2880
     2881    def changeMETAR(self, metar):
     2882        """Change the METAR as a result of an edit on one of the other
     2883        pages."""
     2884        if self._active:
     2885            print "LandingPage.changeMETAR"
     2886            self._updatingMETAR = True
     2887            self._metar.get_buffer().set_text(metar, -1)
     2888            self._updatingMETAR = False
     2889
     2890            self._updateForwardButton()
    28432891
    28442892    def _starButtonClicked(self, button):
     
    28612909        """Update the sensitivity of the forward button."""
    28622910        sensitive = self._flightEnded and \
     2911                    self._metar.get_text()!="" and \
    28632912                    (self._starButton.get_active() or \
    28642913                     self._transitionButton.get_active()) and \
     
    29022951        """Callback for the fleet retrieval."""
    29032952        self._wizard.nextPage()
     2953
     2954    def _metarChanged(self, entry):
     2955        """Called when the METAR has changed."""
     2956        print "LandingPage.metarChanged", self._updatingMETAR
     2957        if not self._updatingMETAR:
     2958            self._updateForwardButton()
     2959            self._wizard.metarChanged(entry.get_text(), self)
     2960
     2961    def _metarInserted(self, buffer, position, text, length):
     2962        """Called when new characters are inserted into the METAR.
     2963
     2964        It uppercases all characters."""
     2965        print "LandingPage.metarInserted", self._updatingMETAR
     2966        if not self._updatingMETAR:
     2967            self._updatingMETAR = True
     2968
     2969            buffer.delete_text(position, length)
     2970            buffer.insert_text(position, text.upper(), length)
     2971
     2972            self._updatingMETAR = False
    29042973
    29052974#-----------------------------------------------------------------------------
     
    38463915        originator is the page that originated the change. It will not be
    38473916        called to set the METAR, while others will be."""
    3848         for page in [self._arrivalBriefingPage]:
     3917        for page in [self._arrivalBriefingPage, self._landingPage]:
    38493918            if page is not originator:
    38503919                page.changeMETAR(metar)
Note: See TracChangeset for help on using the changeset viewer.