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