From 1e96d2c49ced22abadbdda760513f8d43b650b98 Mon Sep 17 00:00:00 2001 From: Zach Tibbitts Date: Fri, 16 Feb 2007 02:03:16 +0000 Subject: [PATCH] - --- scripts/deluge | 4 ++++ src/delugegtk.py | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/deluge b/scripts/deluge index 3b5900a85..d70d2f7f4 100755 --- a/scripts/deluge +++ b/scripts/deluge @@ -45,6 +45,10 @@ interface = None if not "org.deluge_torrent.Deluge" in dbus_objects: print "no existing Deluge session" import deluge, deluge.delugegtk + import gettext + gettext.install(gettext_name) + print _('message') + interface = deluge.delugegtk.DelugeGTK() for arg in args: apath = os.path.abspath(arg) diff --git a/src/delugegtk.py b/src/delugegtk.py index df896a807..0126b2072 100755 --- a/src/delugegtk.py +++ b/src/delugegtk.py @@ -30,8 +30,6 @@ import dbus, dbus.service if getattr(dbus, 'version', (0,0,0)) >= (0,41,0): import dbus.glib -_ = gettext.gettext - class DelugeGTK(dbus.service.Object): ## external_add_torrent should only be called from outside the class @dbus.service.method('org.deluge_torrent.DelugeInterface') @@ -77,8 +75,9 @@ class DelugeGTK(dbus.service.Object): self.window = self.wtree.get_widget("main_window") self.window.hide() self.toolbar = self.wtree.get_widget("tb_middle") - if(self.window): - self.window.connect("destroy", self.close_clicked) + self.window.drag_dest_set(gtk.DEST_DEFAULT_ALL,[('text/uri-list', 0, 80)], gtk.gdk.ACTION_COPY) + self.window.connect("destroy", self.close_clicked) + self.window.connect("drag_data_received", self.on_drag_data) self.window.set_title('%s %s'%(dcommon.PROGRAM_NAME, dcommon.PROGRAM_VERSION)) self.window.set_icon_from_file(dcommon.get_pixmap("deluge32.png")) @@ -595,6 +594,20 @@ class DelugeGTK(dbus.service.Object): return self.store.get_value(self.view.get_selection().get_selected()[1], 0) except TypeError: return None + + def on_drag_data(self, widget, drag_context, x, y, selection_data, info, timestamp): + uri_split = selection_data.data.strip().split() + for uri in uri_split: + path = urllib.url2pathname(uri).strip('\r\n\x00') + if path.startswith('file:\\\\\\'): + path = path[8:] + elif path.startswith('file://'): + path = path[7:] + elif path.startswith('file:'): + path = path[5:] + if path.endswith('.torrent'): + self.interactive_add_torrent(path) + def interactive_add_torrent(self, torrent):