Ignore:
Timestamp:
12/30/16 15:39:17 (8 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

A PIREP for a pending flight can be viewed (re #307)

Location:
src/mlx/gui
Files:
2 edited

Legend:

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

    r828 r830  
    243243    ]
    244244
    245     def __init__(self, which, wizard, window):
     245    def __init__(self, which, wizard, window, pirepEditable = False):
    246246        """Construct the frame with the given title."""
    247247        super(PendingFlightsFrame, self).__init__(xstr("pendflt_title_" + which))
     
    250250        self._wizard = wizard
    251251        self._window = window
     252        self._pirepEditable = pirepEditable
    252253
    253254        alignment = gtk.Alignment(xscale = 1.0, yscale = 1.0)
     
    267268        buttonBox = gtk.VBox()
    268269
    269         self._editButton = gtk.Button(xstr("pendflt_edit_" + which))
     270        self._editButton = gtk.Button(xstr("pendflt_" +
     271                                           ("edit" if pirepEditable else
     272                                            "view") + "_" + which))
    270273        self._editButton.set_sensitive(False)
     274        self._editButton.connect("clicked", self._editClicked)
    271275        buttonBox.pack_start(self._editButton, False, False, 2)
    272276
     
    306310        self._reflyButton.set_sensitive(len(selectedIndexes)>0)
    307311        self._deleteButton.set_sensitive(len(selectedIndexes)>0)
     312
     313    def _editClicked(self, button):
     314        """Called when the Edit button is clicked."""
     315        gui = self._wizard.gui
     316        gui.beginBusy(xstr("pendflt_pirep_busy"))
     317        self.set_sensitive(False)
     318
     319        indexes = self._flightList.selectedIndexes
     320        assert(len(indexes)==1)
     321
     322        flightID = self._flights[indexes[0]].id
     323        gui.webHandler.getPIREP(self._pirepResultCallback, flightID)
     324
     325    def _pirepResultCallback(self, returned, result):
     326        """Called when the PIREP query result is available."""
     327        gobject.idle_add(self._handlePIREPResult, returned, result)
     328
     329    def _handlePIREPResult(self, returned, result):
     330        """Handle the refly result."""
     331
     332        self.set_sensitive(True)
     333        gui = self._wizard.gui
     334        gui.endBusy()
     335
     336        if returned:
     337            if self._pirepEditable:
     338                gui.editPIREP(result.pirep)
     339            else:
     340                gui.viewPIREP(result.pirep)
    308341
    309342    def _reflyClicked(self, button):
     
    408441        vbox = gtk.VBox()
    409442
    410         self._reportedFrame = PendingFlightsFrame("reported", wizard, self)
     443        self._reportedFrame = PendingFlightsFrame("reported", wizard, self,
     444                                                  True)
    411445        vbox.pack_start(self._reportedFrame, True, True, 2)
    412446
  • src/mlx/gui/gui.py

    r805 r830  
    12521252            else:
    12531253                simulator.disableTimeSync()
     1254
     1255    def viewPIREP(self, pirep):
     1256        """Display the PIREP viewer window with the given PIREP."""
     1257        self._pirepViewer.setPIREP(pirep)
     1258        self._pirepViewer.show_all()
     1259        self._pirepViewer.run()
     1260        self._pirepViewer.hide()
     1261
     1262    def editPIREP(self, pirep):
     1263        """Display the PIREP editor window and allow editing the PIREP."""
     1264        self.viewPIREP(pirep)
    12541265
    12551266    def _loadPIREP(self, menuItem):
Note: See TracChangeset for help on using the changeset viewer.