mirror of
https://git.deluge-torrent.org/deluge
synced 2025-04-21 03:54:50 +00:00
Can now change queue order in the UI.
This commit is contained in:
parent
ca5297e20d
commit
7c36587f23
9 changed files with 99 additions and 42 deletions
|
@ -188,29 +188,29 @@ class Core(dbus.service.Object):
|
|||
in_signature="s", out_signature="")
|
||||
def queue_top(self, torrent_id):
|
||||
# If the queue method returns True, then we should emit a signal
|
||||
if self.queue.top(torrent_id):
|
||||
self.torrent_queue_top()
|
||||
if self.torrents.queue.top(torrent_id):
|
||||
self.torrent_queue_changed()
|
||||
|
||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
||||
in_signature="s", out_signature="")
|
||||
def queue_up(self, torrent_id):
|
||||
# If the queue method returns True, then we should emit a signal
|
||||
if self.queue.up(torrent_id):
|
||||
self.torrent_queue_up()
|
||||
|
||||
if self.torrents.queue.up(torrent_id):
|
||||
self.torrent_queue_changed()
|
||||
|
||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
||||
in_signature="s", out_signature="")
|
||||
def queue_down(self, torrent_id):
|
||||
# If the queue method returns True, then we should emit a signal
|
||||
if self.queue.down(torrent_id):
|
||||
self.torrent_queue_down()
|
||||
if self.torrents.queue.down(torrent_id):
|
||||
self.torrent_queue_changed()
|
||||
|
||||
@dbus.service.method(dbus_interface="org.deluge_torrent.Deluge",
|
||||
in_signature="s", out_signature="")
|
||||
def queue_bottom(self, torrent_id):
|
||||
# If the queue method returns True, then we should emit a signal
|
||||
if self.queue.bottom(torrent_id):
|
||||
self.torrent_queue_bottom()
|
||||
if self.torrents.queue.bottom(torrent_id):
|
||||
self.torrent_queue_changed()
|
||||
|
||||
# Signals
|
||||
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
||||
|
@ -232,25 +232,7 @@ class Core(dbus.service.Object):
|
|||
log.debug("torrent_remove signal emitted")
|
||||
|
||||
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
||||
signature="s")
|
||||
def torrent_queue_top(self, torrent_id):
|
||||
"""Emitted when a torrent is queued to the top"""
|
||||
log.debug("torrent_queue_top signal emitted")
|
||||
|
||||
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
||||
signature="s")
|
||||
def torrent_queue_up(self, torrent_id):
|
||||
"""Emitted when a torrent is queued up"""
|
||||
log.debug("torrent_queue_up signal emitted")
|
||||
|
||||
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
||||
signature="s")
|
||||
def torrent_queue_down(self, torrent_id):
|
||||
"""Emitted when a torrent is queued down"""
|
||||
log.debug("torrent_queue_down signal emitted")
|
||||
|
||||
@dbus.service.signal(dbus_interface="org.deluge_torrent.Deluge",
|
||||
signature="s")
|
||||
def torrent_queue_bottom(self, torrent_id):
|
||||
"""Emitted when a torrent is queued to the bottom"""
|
||||
log.debug("torrent_queue_bottom signal emitted")
|
||||
signature="")
|
||||
def torrent_queue_changed(self):
|
||||
"""Emitted when a torrent queue position is changed"""
|
||||
log.debug("torrent_queue_changed signal emitted")
|
||||
|
|
|
@ -55,6 +55,9 @@ class Torrent:
|
|||
left = self.handle.status().total_wanted \
|
||||
- self.handle.status().total_done
|
||||
|
||||
if left == 0 or self.handle.status().download_payload_rate == 0:
|
||||
return 0
|
||||
|
||||
try:
|
||||
eta = left / self.handle.status().download_payload_rate
|
||||
except ZeroDivisionError:
|
||||
|
|
|
@ -70,7 +70,6 @@ class AddTorrentDialog:
|
|||
self.chooser.set_current_folder(
|
||||
self.config.get("default_load_path"))
|
||||
|
||||
|
||||
def run(self):
|
||||
"""Returns a list of selected files or None if no files were selected.
|
||||
"""
|
||||
|
|
|
@ -93,6 +93,34 @@ def remove_torrent(torrent_ids):
|
|||
for torrent_id in torrent_ids:
|
||||
core.remove_torrent(torrent_id)
|
||||
|
||||
def queue_top(torrent_ids):
|
||||
"""Attempts to queue all torrent_ids to the top"""
|
||||
log.debug("Attempting to queue to top these torrents: %s", torrent_ids)
|
||||
core = get_core()
|
||||
for torrent_id in torrent_ids:
|
||||
core.queue_top(torrent_id)
|
||||
|
||||
def queue_up(torrent_ids):
|
||||
"""Attempts to queue all torrent_ids up"""
|
||||
log.debug("Attempting to queue up these torrents: %s", torrent_ids)
|
||||
core = get_core()
|
||||
for torrent_id in torrent_ids:
|
||||
core.queue_up(torrent_id)
|
||||
|
||||
def queue_down(torrent_ids):
|
||||
"""Attempts to queue all torrent_ids down"""
|
||||
log.debug("Attempting to queue down these torrents: %s", torrent_ids)
|
||||
core = get_core()
|
||||
for torrent_id in torrent_ids:
|
||||
core.queue_down(torrent_id)
|
||||
|
||||
def queue_bottom(torrent_ids):
|
||||
"""Attempts to queue all torrent_ids to the bottom"""
|
||||
log.debug("Attempting to queue to bottom these torrents: %s", torrent_ids)
|
||||
core = get_core()
|
||||
for torrent_id in torrent_ids:
|
||||
core.queue_bottom(torrent_id)
|
||||
|
||||
def get_torrent_status_dict(core, torrent_id):
|
||||
"""Builds and returns a status dictionary using the status template"""
|
||||
status = core.get_torrent_status(torrent_id)
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Up</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="queue_up"/>
|
||||
<signal name="activate" handler="on_menuitem_queueup_activate"/>
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="menu-item-image6">
|
||||
<property name="visible">True</property>
|
||||
|
@ -122,7 +122,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Down</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="activate" handler="queue_down"/>
|
||||
<signal name="activate" handler="on_menuitem_queuedown_activate"/>
|
||||
<child internal-child="image">
|
||||
<widget class="GtkImage" id="menu-item-image7">
|
||||
<property name="visible">True</property>
|
||||
|
|
|
@ -102,10 +102,13 @@ class MenuBar:
|
|||
def on_menuitem_addtorrent_activate(self, data=None):
|
||||
log.debug("on_menuitem_addtorrent_activate")
|
||||
functions.add_torrent_file()
|
||||
|
||||
def on_menuitem_addurl_activate(self, data=None):
|
||||
log.debug("on_menuitem_addurl_activate")
|
||||
|
||||
def on_menuitem_clear_activate(self, data=None):
|
||||
log.debug("on_menuitem_clear_activate")
|
||||
|
||||
def on_menuitem_quit_activate(self, data=None):
|
||||
log.debug("on_menuitem_quit_activate")
|
||||
self.window.quit()
|
||||
|
@ -113,36 +116,48 @@ class MenuBar:
|
|||
## Edit Menu ##
|
||||
def on_menuitem_preferences_activate(self, data=None):
|
||||
log.debug("on_menuitem_preferences_activate")
|
||||
|
||||
def on_menuitem_plugins_activate(self, data=None):
|
||||
log.debug("on_menuitem_plugins_activate")
|
||||
|
||||
## Torrent Menu ##
|
||||
def on_menuitem_pause_activate(self, data=None):
|
||||
log.debug("on_menuitem_pause_activate")
|
||||
|
||||
def on_menuitem_updatetracker_activate(self, data=None):
|
||||
log.debug("on_menuitem_updatetracker_activate")
|
||||
|
||||
def on_menuitem_edittrackers_activate(self, data=None):
|
||||
log.debug("on_menuitem_edittrackers_activate")
|
||||
|
||||
def on_menuitem_remove_activate(self, data=None):
|
||||
log.debug("on_menuitem_remove_activate")
|
||||
functions.remove_torrent(
|
||||
self.window.torrentview.get_selected_torrents())
|
||||
|
||||
def on_menuitem_queuetop_activate(self, data=None):
|
||||
log.debug("on_menuitem_queuetop_activate")
|
||||
functions.queue_top(self.window.torrentview.get_selected_torrents())
|
||||
|
||||
def on_menuitem_queueup_activate(self, data=None):
|
||||
log.debug("on_menuitem_queueup_activate")
|
||||
functions.queue_up(self.window.torrentview.get_selected_torrents())
|
||||
|
||||
def on_menuitem_queuedown_activate(self, data=None):
|
||||
log.debug("on_menuitem_queuedown_activate")
|
||||
functions.queue_down(self.window.torrentview.get_selected_torrents())
|
||||
|
||||
def on_menuitem_queuebottom_activate(self, data=None):
|
||||
log.debug("on_menuitem_queuebottom_activate")
|
||||
|
||||
functions.queue_bottom(self.window.torrentview.get_selected_torrents())
|
||||
|
||||
## View Menu ##
|
||||
def on_menuitem_toolbar_toggled(self, data=None):
|
||||
log.debug("on_menuitem_toolbar_toggled")
|
||||
|
||||
def on_menuitem_infopane_toggled(self, data=None):
|
||||
log.debug("on_menuitem_infopane_toggled")
|
||||
|
||||
## Help Menu ##
|
||||
def on_menuitem_about_activate(self, data=None):
|
||||
log.debug("on_menuitem_about_activate")
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ class Signals:
|
|||
self.core.connect_to_signal("torrent_added", self.torrent_added_signal)
|
||||
self.core.connect_to_signal("torrent_removed",
|
||||
self.torrent_removed_signal)
|
||||
self.core.connect_to_signal("torrent_queue_changed",
|
||||
self.torrent_queue_changed_signal)
|
||||
|
||||
def torrent_added_signal(self, torrent_id):
|
||||
log.debug("torrent_added signal received..")
|
||||
|
@ -75,3 +77,8 @@ class Signals:
|
|||
log.debug("torrent id: %s", torrent_id)
|
||||
# Remove the torrent from the treeview
|
||||
self.ui.main_window.torrentview.remove_row(torrent_id)
|
||||
|
||||
def torrent_queue_changed_signal(self):
|
||||
log.debug("torrent_queue_changed signal received..")
|
||||
# Force an update of the torrent view
|
||||
self.ui.main_window.torrentview.update()
|
||||
|
|
|
@ -66,19 +66,40 @@ class ToolBar:
|
|||
### Callbacks ###
|
||||
def on_toolbutton_add_clicked(self, data):
|
||||
log.debug("on_toolbutton_add_clicked")
|
||||
functions.add_torrent_file()
|
||||
# Use the menubar's callback
|
||||
self.window.menubar.on_menuitem_addtorrent_activate(data)
|
||||
|
||||
def on_toolbutton_remove_clicked(self, data):
|
||||
log.debug("on_toolbutton_remove_clicked")
|
||||
# Use the menubar's callbacks
|
||||
self.window.menubar.on_menuitem_remove_activate(data)
|
||||
|
||||
def on_toolbutton_clear_clicked(self, data):
|
||||
log.debug("on_toolbutton_clear_clicked")
|
||||
# Use the menubar's callbacks
|
||||
self.window.menubar.on_menuitem_clear_activate(data)
|
||||
|
||||
def on_toolbutton_pause_clicked(self, data):
|
||||
log.debug("on_toolbutton_pause_clicked")
|
||||
# Use the menubar's callbacks
|
||||
self.window.menubar.on_menuitem_pause_activate(data)
|
||||
|
||||
def on_toolbutton_queueup_clicked(self, data):
|
||||
log.debug("on_toolbutton_queueup_clicked")
|
||||
# Use the menubar's callbacks
|
||||
self.window.menubar.on_menuitem_queueup_activate(data)
|
||||
|
||||
def on_toolbutton_queuedown_clicked(self, data):
|
||||
log.debug("on_toolbutton_queuedown_clicked")
|
||||
# Use the menubar's callbacks
|
||||
self.window.menubar.on_menuitem_queuedown_activate(data)
|
||||
|
||||
def on_toolbutton_preferences_clicked(self, data):
|
||||
log.debug("on_toolbutton_preferences_clicked")
|
||||
# Use the menubar's callbacks
|
||||
self.window.menubar.on_menuitem_preferences_activate(data)
|
||||
|
||||
def on_toolbutton_plugins_clicked(self, data):
|
||||
log.debug("on_toolbutton_plugins_clicked")
|
||||
|
||||
# Use the menubar's callbacks
|
||||
self.window.menubar.on_menuitem_preferences_activate(data)
|
||||
|
|
|
@ -153,9 +153,9 @@ class TorrentView:
|
|||
|
||||
def update(self):
|
||||
"""Update the view, this is likely called by a timer"""
|
||||
# Iterate through the torrent_model and update rows
|
||||
row = self.torrent_model.get_iter_first()
|
||||
while row is not None:
|
||||
|
||||
# This function is used for the foreach method of the treemodel
|
||||
def update_row(model, path, row, user_data):
|
||||
torrent_id = self.torrent_model.get_value(row, 0)
|
||||
status = functions.get_torrent_status_dict(self.core, torrent_id)
|
||||
# Set values for each column in the row
|
||||
|
@ -179,7 +179,9 @@ class TorrentView:
|
|||
status["upload_payload_rate"])
|
||||
self.torrent_model.set_value(row, TORRENT_VIEW_COL_ETA,
|
||||
status["eta"])
|
||||
row = self.torrent_model.iter_next(row)
|
||||
|
||||
# Iterates through every row and updates them accordingly
|
||||
self.torrent_model.foreach(update_row, None)
|
||||
|
||||
def add_row(self, torrent_id):
|
||||
"""Adds a new torrent row to the treeview"""
|
||||
|
|
Loading…
Add table
Reference in a new issue