mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Add #891 remove torrents by pressing the Delete key
This commit is contained in:
parent
b69e25e308
commit
0042fb1767
1 changed files with 20 additions and 5 deletions
|
@ -49,6 +49,7 @@ from deluge.ui.client import client
|
||||||
from deluge.log import LOG as log
|
from deluge.log import LOG as log
|
||||||
import listview
|
import listview
|
||||||
from deluge.ui.tracker_icons import TrackerIcons
|
from deluge.ui.tracker_icons import TrackerIcons
|
||||||
|
from removetorrentdialog import RemoveTorrentDialog
|
||||||
|
|
||||||
# Status icons.. Create them from file only once to avoid constantly
|
# Status icons.. Create them from file only once to avoid constantly
|
||||||
# re-creating them.
|
# re-creating them.
|
||||||
|
@ -146,7 +147,7 @@ def eta_column_sort(model, iter1, iter2, data):
|
||||||
return 1
|
return 1
|
||||||
if v2 > v1:
|
if v2 > v1:
|
||||||
return -1
|
return -1
|
||||||
|
|
||||||
class TorrentView(listview.ListView, component.Component):
|
class TorrentView(listview.ListView, component.Component):
|
||||||
"""TorrentView handles the listing of torrents."""
|
"""TorrentView handles the listing of torrents."""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -238,6 +239,7 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
self.on_selection_changed)
|
self.on_selection_changed)
|
||||||
|
|
||||||
self.treeview.connect("drag-drop", self.on_drag_drop)
|
self.treeview.connect("drag-drop", self.on_drag_drop)
|
||||||
|
self.treeview.connect("key_press_event", self.on_key_press_event)
|
||||||
|
|
||||||
client.register_event_handler("TorrentStateChangedEvent", self.on_torrentstatechanged_event)
|
client.register_event_handler("TorrentStateChangedEvent", self.on_torrentstatechanged_event)
|
||||||
client.register_event_handler("TorrentAddedEvent", self.on_torrentadded_event)
|
client.register_event_handler("TorrentAddedEvent", self.on_torrentadded_event)
|
||||||
|
@ -279,7 +281,7 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
Saves the state of the torrent view.
|
Saves the state of the torrent view.
|
||||||
"""
|
"""
|
||||||
listview.ListView.save_state(self, "torrentview.state")
|
listview.ListView.save_state(self, "torrentview.state")
|
||||||
|
|
||||||
def set_filter(self, filter_dict):
|
def set_filter(self, filter_dict):
|
||||||
"""Sets filters for the torrentview..
|
"""Sets filters for the torrentview..
|
||||||
see: core.get_torrents_status
|
see: core.get_torrents_status
|
||||||
|
@ -477,15 +479,15 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
torrentmenu = component.get("MenuBar").torrentmenu
|
torrentmenu = component.get("MenuBar").torrentmenu
|
||||||
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):
|
def on_key_press_event(self, widget, event):
|
||||||
# Menu key
|
# Menu key
|
||||||
if gtk.gdk.keyval_name(event.keyval) != "Menu":
|
if gtk.gdk.keyval_name(event.keyval) != "Menu":
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.get_selected_torrent():
|
if not self.get_selected_torrent():
|
||||||
return
|
return
|
||||||
|
|
||||||
torrentmenu = component.get("MenuBar").torrentmenu
|
torrentmenu = component.get("MenuBar").torrentmenu
|
||||||
torrentmenu.popup(None, None, None, 3, event.time)
|
torrentmenu.popup(None, None, None, 3, event.time)
|
||||||
return True
|
return True
|
||||||
|
@ -526,3 +528,16 @@ class TorrentView(listview.ListView, component.Component):
|
||||||
def on_torrentqueuechanged_event(self):
|
def on_torrentqueuechanged_event(self):
|
||||||
self.mark_dirty()
|
self.mark_dirty()
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
|
# Handle keyboard shortcuts
|
||||||
|
def on_key_press_event(self, widget, event):
|
||||||
|
keyname = gtk.gdk.keyval_name(event.keyval)
|
||||||
|
func = getattr(self, 'keypress_' + keyname, None)
|
||||||
|
if func:
|
||||||
|
return func()
|
||||||
|
|
||||||
|
def keypress_Delete(self):
|
||||||
|
log.debug("keypress_Delete")
|
||||||
|
torrents = self.get_selected_torrents()
|
||||||
|
if torrents:
|
||||||
|
RemoveTorrentDialog(torrents).run()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue