From d98231a7131ff409883ec49123e686b7c55ff2bf 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 | 35 ++----------------------------- 1 file changed, 2 insertions(+), 33 deletions(-) diff --git a/deluge/ui/gtkui/queuedtorrents.py b/deluge/ui/gtkui/queuedtorrents.py index 60cbb62ad..3b63934c5 100644 --- a/deluge/ui/gtkui/queuedtorrents.py +++ b/deluge/ui/gtkui/queuedtorrents.py @@ -42,6 +42,7 @@ import gobject 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 import common @@ -173,39 +174,7 @@ 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[:]