Fix #1918 : Drag'n'Drop not working in Windows

This commit is contained in:
Calum Lind 2011-11-22 03:23:22 +00:00
parent d98231a713
commit 3c3f93db3e
2 changed files with 15 additions and 10 deletions

View File

@ -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

View File

@ -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):