diff --git a/deluge/ui/gtkui/ipcinterface.py b/deluge/ui/gtkui/ipcinterface.py index 0c98e0f4d..aefdf4973 100644 --- a/deluge/ui/gtkui/ipcinterface.py +++ b/deluge/ui/gtkui/ipcinterface.py @@ -38,6 +38,8 @@ import sys import os import base64 import logging +from urllib import url2pathname +from urlparse import urlparse try: import rencode @@ -190,29 +192,34 @@ def process_args(args): component.get("QueuedTorrents").add_to_queue(args) return config = ConfigManager("gtkui.conf") + for arg in args: if not arg.strip(): continue log.debug("arg: %s", arg) + if deluge.common.is_url(arg): - log.debug("Attempting to add %s from external source..", - arg) + log.debug("Attempting to add url (%s) from external source...", arg) if config["interactive_add"]: component.get("AddTorrentDialog").add_from_url(arg) component.get("AddTorrentDialog").show(config["focus_add_dialog"]) else: client.core.add_torrent_url(arg, None) + elif deluge.common.is_magnet(arg): - log.debug("Attempting to add %s from external source..", arg) + log.debug("Attempting to add magnet (%s) from external source...", arg) if config["interactive_add"]: component.get("AddTorrentDialog").add_from_magnets([arg]) component.get("AddTorrentDialog").show(config["focus_add_dialog"]) else: client.core.add_torrent_magnet(arg, {}) + else: - # Just a file - path = os.path.abspath(arg.replace('file://', '', 1)) - log.debug("Attempting to add %s from external source..", path) + log.debug("Attempting to add file (%s) from external source...", arg) + if urlparse(arg).scheme == "file": + arg = url2pathname(urlparse(arg).path) + path = os.path.abspath(arg) + if not os.path.exists(path): log.error("No such file: %s", path) continue diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py index 182f835f0..4d7a56c3b 100644 --- a/deluge/ui/gtkui/mainwindow.py +++ b/deluge/ui/gtkui/mainwindow.py @@ -284,10 +284,8 @@ class MainWindow(component.Component): self.config["window_pane_position"] = self.vpaned.get_position() def on_drag_data_received_event(self, widget, drag_context, x, y, selection_data, info, timestamp): - args = [] - for uri in selection_data.data.split(): - args.append(urllib.unquote(uri)) - process_args(args) + log.debug("Selection(s) dropped on main window %s", selection_data.get_uris()) + process_args(selection_data.get_uris()) drag_context.finish(True, True) def on_expose_event(self, widget, event):