mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-10 10:26:46 +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 gobject
|
||||||
import gettext
|
import gettext
|
||||||
import os.path
|
import os.path
|
||||||
@ -187,6 +187,7 @@ class FilesTab(Tab):
|
|||||||
]
|
]
|
||||||
|
|
||||||
self.listview.connect("row-activated", self._on_row_activated)
|
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.connect("button-press-event", self._on_button_press_event)
|
||||||
|
|
||||||
self.listview.enable_model_drag_source(
|
self.listview.enable_model_drag_source(
|
||||||
@ -472,6 +473,17 @@ class FilesTab(Tab):
|
|||||||
self.file_menu.popup(None, None, None, event.button, event.time)
|
self.file_menu.popup(None, None, None, event.button, event.time)
|
||||||
return True
|
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):
|
def _on_menuitem_open_file_activate(self, menuitem):
|
||||||
self._on_row_activated(None, None, None)
|
self._on_row_activated(None, None, None)
|
||||||
|
|
||||||
|
@ -214,6 +214,9 @@ class TorrentView(listview.ListView, component.Component):
|
|||||||
# torrent menu popup.
|
# torrent menu popup.
|
||||||
self.treeview.connect("button-press-event",
|
self.treeview.connect("button-press-event",
|
||||||
self.on_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
|
# Connect to the 'changed' event of TreeViewSelection to get selection
|
||||||
# changes.
|
# changes.
|
||||||
self.treeview.get_selection().connect("changed",
|
self.treeview.get_selection().connect("changed",
|
||||||
@ -460,6 +463,18 @@ class TorrentView(listview.ListView, component.Component):
|
|||||||
torrentmenu.popup(None, None, None, event.button, event.time)
|
torrentmenu.popup(None, None, None, event.button, event.time)
|
||||||
return True
|
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):
|
def on_selection_changed(self, treeselection):
|
||||||
"""This callback is know when the selection has changed."""
|
"""This callback is know when the selection has changed."""
|
||||||
log.debug("on_selection_changed")
|
log.debug("on_selection_changed")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user