mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-02 22:48:40 +00:00
Fix #577 adding torrents by drag n' drop in windows
This commit is contained in:
parent
be70707149
commit
b3cda61961
2 changed files with 33 additions and 32 deletions
|
@ -2,19 +2,19 @@
|
||||||
# ipcinterface.py
|
# ipcinterface.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Andrew Resch ('andar') <andrewresch@gmail.com>
|
# Copyright (C) 2008 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
# You may redistribute it and/or modify it under the terms of the
|
# You may redistribute it and/or modify it under the terms of the
|
||||||
# GNU General Public License, as published by the Free Software
|
# GNU General Public License, as published by the Free Software
|
||||||
# Foundation; either version 3 of the License, or (at your option)
|
# Foundation; either version 3 of the License, or (at your option)
|
||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# deluge is distributed in the hope that it will be useful,
|
# deluge is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
|
@ -43,7 +43,7 @@ from deluge.log import LOG as log
|
||||||
class IPCInterface(component.Component):
|
class IPCInterface(component.Component):
|
||||||
def __init__(self, args):
|
def __init__(self, args):
|
||||||
component.Component.__init__(self, "IPCInterface")
|
component.Component.__init__(self, "IPCInterface")
|
||||||
|
|
||||||
if deluge.common.windows_check():
|
if deluge.common.windows_check():
|
||||||
# If we're on windows we need to check the global mutex to see if deluge is
|
# If we're on windows we need to check the global mutex to see if deluge is
|
||||||
# already running.
|
# already running.
|
||||||
|
@ -72,7 +72,7 @@ class IPCInterface(component.Component):
|
||||||
if deluge.common.windows_check():
|
if deluge.common.windows_check():
|
||||||
import win32api
|
import win32api
|
||||||
win32api.CloseHandle(self.mutex)
|
win32api.CloseHandle(self.mutex)
|
||||||
|
|
||||||
def process_args(args):
|
def process_args(args):
|
||||||
"""Process arguments sent to already running Deluge"""
|
"""Process arguments sent to already running Deluge"""
|
||||||
# Pythonize the values from Dbus
|
# Pythonize the values from Dbus
|
||||||
|
@ -86,8 +86,10 @@ def process_args(args):
|
||||||
log.debug("Not connected to host.. Adding to queue.")
|
log.debug("Not connected to host.. Adding to queue.")
|
||||||
component.get("QueuedTorrents").add_to_queue(args)
|
component.get("QueuedTorrents").add_to_queue(args)
|
||||||
return
|
return
|
||||||
config = ConfigManager("gtkui.conf")
|
config = ConfigManager("gtkui.conf")
|
||||||
for arg in args:
|
for arg in args:
|
||||||
|
if not arg:
|
||||||
|
continue
|
||||||
log.debug("arg: %s", arg)
|
log.debug("arg: %s", arg)
|
||||||
if deluge.common.is_url(arg):
|
if deluge.common.is_url(arg):
|
||||||
log.debug("Attempting to add %s from external source..",
|
log.debug("Attempting to add %s from external source..",
|
||||||
|
@ -106,11 +108,10 @@ def process_args(args):
|
||||||
client.add_torrent_magnets([arg], [])
|
client.add_torrent_magnets([arg], [])
|
||||||
else:
|
else:
|
||||||
# Just a file
|
# Just a file
|
||||||
log.debug("Attempting to add %s from external source..",
|
log.debug("Attempting to add %s from external source..",
|
||||||
os.path.abspath(arg))
|
os.path.abspath(arg))
|
||||||
if config["interactive_add"]:
|
if config["interactive_add"]:
|
||||||
component.get("AddTorrentDialog").add_from_files([os.path.abspath(arg)])
|
component.get("AddTorrentDialog").add_from_files([os.path.abspath(arg)])
|
||||||
component.get("AddTorrentDialog").show(config["focus_add_dialog"])
|
component.get("AddTorrentDialog").show(config["focus_add_dialog"])
|
||||||
else:
|
else:
|
||||||
client.add_torrent_file([os.path.abspath(arg)])
|
client.add_torrent_file([os.path.abspath(arg)])
|
||||||
|
|
||||||
|
|
|
@ -2,19 +2,19 @@
|
||||||
# mainwindow.py
|
# mainwindow.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
# Copyright (C) 2007 Andrew Resch ('andar') <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
# You may redistribute it and/or modify it under the terms of the
|
# You may redistribute it and/or modify it under the terms of the
|
||||||
# GNU General Public License, as published by the Free Software
|
# GNU General Public License, as published by the Free Software
|
||||||
# Foundation; either version 3 of the License, or (at your option)
|
# Foundation; either version 3 of the License, or (at your option)
|
||||||
# any later version.
|
# any later version.
|
||||||
#
|
#
|
||||||
# deluge is distributed in the hope that it will be useful,
|
# deluge is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
# See the GNU General Public License for more details.
|
# See the GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with deluge. If not, write to:
|
# along with deluge. If not, write to:
|
||||||
# The Free Software Foundation, Inc.,
|
# The Free Software Foundation, Inc.,
|
||||||
|
@ -55,23 +55,23 @@ class MainWindow(component.Component):
|
||||||
self.config = ConfigManager("gtkui.conf")
|
self.config = ConfigManager("gtkui.conf")
|
||||||
# Get the glade file for the main window
|
# Get the glade file for the main window
|
||||||
self.main_glade = gtk.glade.XML(
|
self.main_glade = gtk.glade.XML(
|
||||||
pkg_resources.resource_filename("deluge.ui.gtkui",
|
pkg_resources.resource_filename("deluge.ui.gtkui",
|
||||||
"glade/main_window.glade"))
|
"glade/main_window.glade"))
|
||||||
|
|
||||||
self.window = self.main_glade.get_widget("main_window")
|
self.window = self.main_glade.get_widget("main_window")
|
||||||
self.window.set_icon(common.get_logo(32))
|
self.window.set_icon(common.get_logo(32))
|
||||||
self.vpaned = self.main_glade.get_widget("vpaned")
|
self.vpaned = self.main_glade.get_widget("vpaned")
|
||||||
|
|
||||||
# Load the window state
|
# Load the window state
|
||||||
self.load_window_state()
|
self.load_window_state()
|
||||||
|
|
||||||
# Keep track of window's minimization state so that we don't update the
|
# Keep track of window's minimization state so that we don't update the
|
||||||
# UI when it is minimized.
|
# UI when it is minimized.
|
||||||
self.is_minimized = False
|
self.is_minimized = False
|
||||||
|
|
||||||
self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0,
|
self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL, [('text/uri-list', 0,
|
||||||
80)], gtk.gdk.ACTION_COPY)
|
80)], gtk.gdk.ACTION_COPY)
|
||||||
|
|
||||||
# Connect events
|
# Connect events
|
||||||
self.window.connect("window-state-event", self.on_window_state_event)
|
self.window.connect("window-state-event", self.on_window_state_event)
|
||||||
self.window.connect("configure-event", self.on_window_configure_event)
|
self.window.connect("configure-event", self.on_window_configure_event)
|
||||||
|
@ -95,7 +95,7 @@ class MainWindow(component.Component):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
self.window.show()
|
self.window.show()
|
||||||
|
|
||||||
def hide(self):
|
def hide(self):
|
||||||
component.pause("TorrentView")
|
component.pause("TorrentView")
|
||||||
component.pause("StatusBar")
|
component.pause("StatusBar")
|
||||||
|
@ -104,7 +104,7 @@ class MainWindow(component.Component):
|
||||||
self.window_x_pos = self.window.get_position()[0]
|
self.window_x_pos = self.window.get_position()[0]
|
||||||
self.window_y_pos = self.window.get_position()[1]
|
self.window_y_pos = self.window.get_position()[1]
|
||||||
self.window.hide()
|
self.window.hide()
|
||||||
|
|
||||||
def present(self):
|
def present(self):
|
||||||
# Restore the proper x,y coords for the window prior to showing it
|
# Restore the proper x,y coords for the window prior to showing it
|
||||||
try:
|
try:
|
||||||
|
@ -121,23 +121,23 @@ class MainWindow(component.Component):
|
||||||
|
|
||||||
self.window.present()
|
self.window.present()
|
||||||
self.load_window_state()
|
self.load_window_state()
|
||||||
|
|
||||||
def active(self):
|
def active(self):
|
||||||
"""Returns True if the window is active, False if not."""
|
"""Returns True if the window is active, False if not."""
|
||||||
return self.window.is_active()
|
return self.window.is_active()
|
||||||
|
|
||||||
def visible(self):
|
def visible(self):
|
||||||
"""Returns True if window is visible, False if not."""
|
"""Returns True if window is visible, False if not."""
|
||||||
return self.window.get_property("visible")
|
return self.window.get_property("visible")
|
||||||
|
|
||||||
def get_glade(self):
|
def get_glade(self):
|
||||||
"""Returns a reference to the main window glade object."""
|
"""Returns a reference to the main window glade object."""
|
||||||
return self.main_glade
|
return self.main_glade
|
||||||
|
|
||||||
def quit(self):
|
def quit(self):
|
||||||
del self.config
|
del self.config
|
||||||
gtk.main_quit()
|
gtk.main_quit()
|
||||||
|
|
||||||
def load_window_state(self):
|
def load_window_state(self):
|
||||||
x = self.config["window_x_pos"]
|
x = self.config["window_x_pos"]
|
||||||
y = self.config["window_y_pos"]
|
y = self.config["window_y_pos"]
|
||||||
|
@ -149,7 +149,7 @@ class MainWindow(component.Component):
|
||||||
self.window.maximize()
|
self.window.maximize()
|
||||||
self.vpaned.set_position(
|
self.vpaned.set_position(
|
||||||
self.config["window_height"] - self.config["window_pane_position"])
|
self.config["window_height"] - self.config["window_pane_position"])
|
||||||
|
|
||||||
def on_window_configure_event(self, widget, event):
|
def on_window_configure_event(self, widget, event):
|
||||||
if not self.config["window_maximized"] and self.visible:
|
if not self.config["window_maximized"] and self.visible:
|
||||||
self.config.set("window_x_pos", self.window.get_position()[0])
|
self.config.set("window_x_pos", self.window.get_position()[0])
|
||||||
|
@ -185,20 +185,20 @@ class MainWindow(component.Component):
|
||||||
self.hide()
|
self.hide()
|
||||||
else:
|
else:
|
||||||
self.quit()
|
self.quit()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def on_vpaned_position_event(self, obj, param):
|
def on_vpaned_position_event(self, obj, param):
|
||||||
self.config.set("window_pane_position",
|
self.config.set("window_pane_position",
|
||||||
self.config["window_height"] - self.vpaned.get_position())
|
self.config["window_height"] - self.vpaned.get_position())
|
||||||
|
|
||||||
def on_drag_data_received_event(self, widget, drag_context, x, y, selection_data, info, timestamp):
|
def on_drag_data_received_event(self, widget, drag_context, x, y, selection_data, info, timestamp):
|
||||||
args = []
|
args = []
|
||||||
for uri in selection_data.data.split():
|
for uri in selection_data.data.split():
|
||||||
if deluge.common.windows_check():
|
if deluge.common.windows_check():
|
||||||
uri = uri[7:]
|
args.append(urllib.url2pathname(uri[7:]))
|
||||||
uri = urllib.url2pathname(uri).strip("\r\n\x00")
|
else:
|
||||||
args.append(urllib.unquote(urlparse(uri).path))
|
args.append(urllib.unquote(urlparse(uri).path))
|
||||||
process_args(args)
|
process_args(args)
|
||||||
drag_context.finish(True, True)
|
drag_context.finish(True, True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue