Module: deluge
Branch: 1.3-stable
Commit: 00900fef1c996b72bbef674c8cae19cce1952db1

Author: Calum Lind <[email protected]>
Date:   Fri Jun 17 19:42:08 2011 +0100

Fix uri handling when dragged to gtk window

---

 deluge/ui/gtkui/ipcinterface.py   |   22 +++++++---------------
 deluge/ui/gtkui/mainwindow.py     |    5 +----
 deluge/ui/gtkui/queuedtorrents.py |    1 +
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/deluge/ui/gtkui/ipcinterface.py b/deluge/ui/gtkui/ipcinterface.py
index b7837d1..ef6b104 100644
--- a/deluge/ui/gtkui/ipcinterface.py
+++ b/deluge/ui/gtkui/ipcinterface.py
@@ -85,15 +85,6 @@ class IPCInterface(component.Component):
         if not os.path.exists(deluge.configmanager.get_config_dir("ipc")):
             os.makedirs(deluge.configmanager.get_config_dir("ipc"))
 
-        # Make the args absolute paths
-        _args = []
-        for arg in args:
-            if arg.strip():
-                if not deluge.common.is_magnet(arg) and not 
deluge.common.is_url(arg):
-                    arg = os.path.abspath(arg.replace('file://', '', 1))
-                _args.append(arg)
-        args = _args
-
         socket = os.path.join(deluge.configmanager.get_config_dir("ipc"), 
"deluge-gtk")
 
         if deluge.common.windows_check():
@@ -198,7 +189,7 @@ def process_args(args):
         return
     config = ConfigManager("gtkui.conf")
     for arg in args:
-        if not arg:
+        if not arg.strip():
             continue
         log.debug("arg: %s", arg)
         if deluge.common.is_url(arg):
@@ -218,13 +209,14 @@ def process_args(args):
                 client.core.add_torrent_magnet(arg, {})
         else:
             # Just a file
-            log.debug("Attempting to add %s from external source..", arg)
-            if not os.path.exists(arg):
-                log.error("No such file: %s", arg)
+            path = os.path.abspath(arg.replace('file://', '', 1))
+            log.debug("Attempting to add %s from external source..", path)
+            if not os.path.exists(path):
+                log.error("No such file: %s", path)
                 continue
 
             if config["interactive_add"]:
-                component.get("AddTorrentDialog").add_from_files([arg])
+                component.get("AddTorrentDialog").add_from_files([path])
                 
component.get("AddTorrentDialog").show(config["focus_add_dialog"])
             else:
-                client.core.add_torrent_file(os.path.split(arg)[-1], 
base64.encodestring(open(arg, "rb").read()), None)
+                client.core.add_torrent_file(os.path.split(path)[-1], 
base64.encodestring(open(path, "rb").read()), None)
diff --git a/deluge/ui/gtkui/mainwindow.py b/deluge/ui/gtkui/mainwindow.py
index 344359f..ebe5d14 100644
--- a/deluge/ui/gtkui/mainwindow.py
+++ b/deluge/ui/gtkui/mainwindow.py
@@ -217,10 +217,7 @@ class MainWindow(component.Component):
     def on_drag_data_received_event(self, widget, drag_context, x, y, 
selection_data, info, timestamp):
         args = []
         for uri in selection_data.data.split():
-            if deluge.common.windows_check():
-                args.append(urllib.url2pathname(uri[7:]))
-            else:
-                args.append(urllib.unquote(urlparse(uri).path))
+            args.append(urllib.unquote(uri))
         process_args(args)
         drag_context.finish(True, True)
 
diff --git a/deluge/ui/gtkui/queuedtorrents.py 
b/deluge/ui/gtkui/queuedtorrents.py
index adddccd..ae26ad6 100644
--- a/deluge/ui/gtkui/queuedtorrents.py
+++ b/deluge/ui/gtkui/queuedtorrents.py
@@ -190,6 +190,7 @@ class QueuedTorrents(component.Component):
                 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

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to