Changeset 280:4d2a277c703b for src


Ignore:
Timestamp:
07/07/12 09:40:23 (12 years ago)
Author:
István Váradi <ivaradi@…>
Branch:
default
Phase:
public
Message:

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

Location:
src/mlx/gui
Files:
2 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#------------------------------------------------------------------------------
  • src/mlx/gui/checklist.py

    r279 r280  
    318318            return
    319319
    320         # (path, _, _, _) = self._flightList.get_path_at_pos(int(event.x),
    321         #                                                    int(event.y))
    322         # selection = self._flightList.get_selection()
    323         # selection.unselect_all()
    324         # selection.select_path(path)
    325 
    326320        menu = self._fileListPopupMenu
    327321        if pygobject:
     
    331325
    332326    def _buildFileListPopupMenu(self):
    333         """Get the file list popup menu."""
     327        """Build the file list popup menu."""
    334328        menu = gtk.Menu()
    335329
Note: See TracChangeset for help on using the changeset viewer.