Ignore:
Timestamp:
07/07/12 09:40:23 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
hg-Phase:
(<MercurialRepository 1 'hg:/home/ivaradi/mlx/hg' '/'>, 'public')
Message:

Added a popup menu to the callouts editor's file list

File:
1 edited

Legend:

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

    r272 r280  
    156156        self._fileList.set_size_request(300, -1)
    157157        self._fileList.set_reorderable(False)
     158        self._fileList.connect("button-press-event",
     159                               self._fileListButtonPressed)
    158160        selection = self._fileList.get_selection()
    159161        selection.set_mode(SELECTION_MULTIPLE)
    160162        selection.connect("changed", self._fileListSelectionChanged)
    161        
     163
     164        self._buildFileListPopupMenu()
     165
    162166        scrolledWindow = gtk.ScrolledWindow()
    163167        scrolledWindow.add(self._fileList)
     
    228232    def _removeButtonClicked(self, button):
    229233        """Called when the Remove button is clicked."""
     234        self._removeSelected()
     235       
     236    def _removeSelected(self):
     237        """Remove the selected files."""
    230238        selection = self._fileList.get_selection()
    231239        (model, paths) = selection.get_selected_rows()
     
    436444        return value
    437445       
     446    def _fileListButtonPressed(self, widget, event):
     447        """Called when a mouse button is pressed on the file list."""
     448        if event.type!=EVENT_BUTTON_PRESS or event.button!=3:
     449            return
     450
     451        menu = self._fileListPopupMenu
     452        if pygobject:
     453            menu.popup(None, None, None, None, event.button, event.time)
     454        else:
     455            menu.popup(None, None, None, event.button, event.time)
     456
     457    def _buildFileListPopupMenu(self):
     458        """Build the file list popup menu."""
     459        menu = gtk.Menu()
     460
     461        menuItem = gtk.MenuItem()
     462        menuItem.set_label(xstr("callouts_remove"))
     463        menuItem.set_use_underline(True)
     464        menuItem.connect("activate", self._popupRemove)
     465        menuItem.show()
     466        self._popupRemoveItem = menuItem
     467
     468        menu.append(menuItem)
     469
     470        self._fileListPopupMenu = menu
     471
     472    def _popupRemove(self, menuItem):
     473        """Remove the currently selected menu items."""
     474        self._removeSelected()
     475
    438476#------------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.