From d1a3cbebbe28255b513dcbdb87f065b1266ca49e Mon Sep 17 00:00:00 2001 From: Calum Lind Date: Tue, 22 Nov 2011 03:21:33 +0000 Subject: [PATCH] Remove code duplication in queuedtorrents.py, use ipcinterface process_args() instead --- deluge/ui/gtkui/queuedtorrents.py | 37 +++---------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) diff --git a/deluge/ui/gtkui/queuedtorrents.py b/deluge/ui/gtkui/queuedtorrents.py index ae26ad6ba..08f411d94 100644 --- a/deluge/ui/gtkui/queuedtorrents.py +++ b/deluge/ui/gtkui/queuedtorrents.py @@ -42,6 +42,7 @@ import pkg_resources import deluge.component as component from deluge.ui.client import client +from deluge.ui.gtkui.ipcinterface import process_args import deluge.common from deluge.configmanager import ConfigManager from deluge.log import LOG as log @@ -172,40 +173,8 @@ class QueuedTorrents(component.Component): # Add all the torrents in the liststore def add_torrent(model, path, iter, data): torrent_path = model.get_value(iter, 1) - if deluge.common.is_url(torrent_path): - if self.config["interactive_add"]: - def on_show(result): - component.get("AddTorrentDialog").add_from_url(torrent_path) - - d = component.get("AddTorrentDialog").show(self.config["focus_add_dialog"]) - d.addCallback(on_show) - else: - client.core.add_torrent_url(torrent_path, None) - elif deluge.common.is_magnet(torrent_path): - if self.config["interactive_add"]: - def on_show(result): - component.get("AddTorrentDialog").add_from_magnets([torrent_path]) - d = component.get("AddTorrentDialog").show(self.config["focus_add_dialog"]) - d.addCallback(on_show) - else: - client.core.add_magnet_uris([torrent_path], []) - else: - torrent_path = os.path.abspath(torrent_path.replace('file://', '', 1)) - if not os.path.exists(torrent_path): - log.error("No such file: %s", torrent_path) - return - - if self.config["interactive_add"]: - def on_show(result): - component.get("AddTorrentDialog").add_from_files([torrent_path]) - d = component.get("AddTorrentDialog").show(self.config["focus_add_dialog"]) - d.addCallback(on_show) - else: - client.core.add_torrent_file( - os.path.split(torrent_path)[-1], - base64.encodestring(open(torrent_path, "rb").read()), - None) - + process_args([torrent_path]) + self.liststore.foreach(add_torrent, None) del self.queue[:] self.dialog.hide()