Changeset 867:0db1c4089615 for src/mlx


Ignore:
Timestamp:
06/18/17 18:15:40 (7 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

A popup menu is added to the pending flights browser (re #307)

File:
1 edited

Legend:

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

    r859 r867  
    287287        self._flightList = FlightList(columnDescriptors =
    288288                                      PendingFlightsFrame.columnDescriptors,
    289                                       widthRequest = 500, multiSelection = True)
     289                                      widthRequest = 500, multiSelection = True,
     290                                      popupMenuProducer =
     291                                      self._producePopupMenu)
    290292        self._flightList.connect("selection-changed", self._selectionChanged)
    291293
     
    298300                                            "view") + "_" + which))
    299301        self._editButton.set_sensitive(False)
     302        self._editButton.set_use_underline(True)
    300303        self._editButton.connect("clicked", self._editClicked)
    301304        buttonBox.pack_start(self._editButton, False, False, 2)
     
    303306        self._reflyButton = gtk.Button(xstr("pendflt_refly_" + which))
    304307        self._reflyButton.set_sensitive(False)
     308        self._reflyButton.set_use_underline(True)
    305309        self._reflyButton.connect("clicked", self._reflyClicked)
    306310        buttonBox.pack_start(self._reflyButton, False, False, 2)
     
    308312        self._deleteButton = gtk.Button(xstr("pendflt_delete_" + which))
    309313        self._deleteButton.set_sensitive(False)
     314        self._deleteButton.set_use_underline(True)
    310315        self._deleteButton.connect("clicked", self._deleteClicked)
    311316        buttonBox.pack_start(self._deleteButton, False, False, 2)
     
    339344    def _editClicked(self, button):
    340345        """Called when the Edit button is clicked."""
     346        self._editSelected()
     347
     348    def _editSelected(self):
     349        """Edit or view the selected flight."""
    341350        gui = self._wizard.gui
    342351        gui.beginBusy(xstr("pendflt_pirep_busy"))
     
    368377    def _reflyClicked(self, button):
    369378        """Called when the Refly button is clicked."""
     379        self._reflySelected()
     380
     381    def _reflySelected(self):
     382        """Mark the selected flight(s) to refly."""
    370383        if askYesNo(xstr("pendflt_refly_question"), parent = self._window):
    371384            gui = self._wizard.gui
     
    407420    def _deleteClicked(self, button):
    408421        """Called when the Delete button is clicked."""
     422        self._deleteSelected()
     423
     424    def _deleteSelected(self):
     425        """Delete the selected flight."""
    409426        if askYesNo(xstr("flight_delete_question"), parent = self._window):
    410427            gui = self._wizard.gui
     
    443460        else:
    444461            communicationErrorDialog()
     462
     463    def _producePopupMenu(self):
     464        """Create the popup menu for the flights."""
     465        menu = gtk.Menu()
     466
     467        menuItem = gtk.MenuItem()
     468        menuItem.set_label(xstr("pendflt_" +
     469                                ("edit" if self._pirepEditable else "view") +
     470                                "_" + self._which))
     471        menuItem.set_use_underline(True)
     472        menuItem.connect("activate", self._popupEdit)
     473        menuItem.show()
     474
     475        menu.append(menuItem)
     476
     477        menuItem = gtk.MenuItem()
     478        menuItem.set_label(xstr("pendflt_refly_" + self._which))
     479        menuItem.set_use_underline(True)
     480        menuItem.connect("activate", self._popupRefly)
     481        menuItem.show()
     482
     483        menu.append(menuItem)
     484
     485        menuItem = gtk.MenuItem()
     486        menuItem.set_label(xstr("pendflt_delete_" + self._which))
     487        menuItem.set_use_underline(True)
     488        menuItem.connect("activate", self._popupDelete)
     489        menuItem.show()
     490
     491        menu.append(menuItem)
     492
     493        return menu
     494
     495    def _popupEdit(self, menuitem):
     496        """Called when the Edit or View menu item is selected from the popup
     497        menu."""
     498        self._editSelected()
     499
     500    def _popupRefly(self, menuitem):
     501        """Called when the Refly menu item is selected from the popup menu."""
     502        self._reflySelected()
     503
     504    def _popupDelete(self, menuitem):
     505        """Called when the Delete menu item is selected from the popup menu."""
     506        self._deleteSelected()
    445507
    446508#-----------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.