mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-04 07:33:31 +00:00
connect up the key-press-event and have the context menus pop up when the menu key is pressed
This commit is contained in:
parent
bcbe3108c9
commit
32ed499b2a
@ -34,7 +34,7 @@
|
||||
#
|
||||
|
||||
|
||||
import gtk, gtk.glade
|
||||
import gtk, gtk.glade, gtk.gdk
|
||||
import gobject
|
||||
import gettext
|
||||
import os.path
|
||||
@ -187,6 +187,7 @@ class FilesTab(Tab):
|
||||
]
|
||||
|
||||
self.listview.connect("row-activated", self._on_row_activated)
|
||||
self.listview.connect("key-press-event", self._on_key_press_event)
|
||||
self.listview.connect("button-press-event", self._on_button_press_event)
|
||||
|
||||
self.listview.enable_model_drag_source(
|
||||
@ -471,6 +472,17 @@ class FilesTab(Tab):
|
||||
|
||||
self.file_menu.popup(None, None, None, event.button, event.time)
|
||||
return True
|
||||
|
||||
def _on_key_press_event(self, widget, event):
|
||||
# Menu key
|
||||
if gtk.gdk.keyval_name(event.keyval) != "Menu":
|
||||
return
|
||||
|
||||
if not self.get_selected_files():
|
||||
return
|
||||
|
||||
self.file_menu.popup(None, None, None, 3, event.time)
|
||||
return True
|
||||
|
||||
def _on_menuitem_open_file_activate(self, menuitem):
|
||||
self._on_row_activated(None, None, None)
|
||||
|
@ -214,6 +214,9 @@ class TorrentView(listview.ListView, component.Component):
|
||||
# torrent menu popup.
|
||||
self.treeview.connect("button-press-event",
|
||||
self.on_button_press_event)
|
||||
# Connect to the 'key-press-event' to know when the bring up the
|
||||
# torrent menu popup via keypress.
|
||||
self.treeview.connect("key-press-event", self.on_key_press_event)
|
||||
# Connect to the 'changed' event of TreeViewSelection to get selection
|
||||
# changes.
|
||||
self.treeview.get_selection().connect("changed",
|
||||
@ -459,6 +462,18 @@ class TorrentView(listview.ListView, component.Component):
|
||||
torrentmenu = component.get("MenuBar").torrentmenu
|
||||
torrentmenu.popup(None, None, None, event.button, event.time)
|
||||
return True
|
||||
|
||||
def on_key_press_event(self, widget, event):
|
||||
# Menu key
|
||||
if gtk.gdk.keyval_name(event.keyval) != "Menu":
|
||||
return
|
||||
|
||||
if not self.get_selected_torrent():
|
||||
return
|
||||
|
||||
torrentmenu = component.get("MenuBar").torrentmenu
|
||||
torrentmenu.popup(None, None, None, 3, event.time)
|
||||
return True
|
||||
|
||||
def on_selection_changed(self, treeselection):
|
||||
"""This callback is know when the selection has changed."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user