Add drag n' drop support for torrent file adding

This commit is contained in:
Andrew Resch 2008-07-26 04:06:35 +00:00
commit 63ede39505
3 changed files with 27 additions and 2 deletions

View file

@ -1,8 +1,10 @@
Deluge 0.9.04 - "1.0.0_RC4" (In Development) Deluge 0.9.04 - "1.0.0_RC4" (In Development)
Core: Core:
* Fix building with gcc 4.3 * Fix building with gcc 4.3
* Fix do not create torrentfiles folder unless 'copy_torrent_file' is True
GtkUI: GtkUI:
* Add drag n' drop support for adding .torrent files
* Fix selecting torrents when right-clicking on them in torrentview and filestab * Fix selecting torrents when right-clicking on them in torrentview and filestab
* Fix new release check * Fix new release check
* Display 'total_wanted' instead of 'total_size' in Size column * Display 'total_wanted' instead of 'total_size' in Size column

View file

@ -36,10 +36,13 @@ pygtk.require('2.0')
import gtk, gtk.glade import gtk, gtk.glade
import gobject import gobject
import pkg_resources import pkg_resources
from urlparse import urlparse
import urllib
from deluge.ui.client import aclient as client from deluge.ui.client import aclient as client
import deluge.component as component import deluge.component as component
from deluge.configmanager import ConfigManager from deluge.configmanager import ConfigManager
from deluge.ui.gtkui.ipcinterface import process_arg
import deluge.common import deluge.common
@ -65,17 +68,26 @@ class MainWindow(component.Component):
# 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,
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)
self.window.connect("delete-event", self.on_window_delete_event) self.window.connect("delete-event", self.on_window_delete_event)
self.window.connect("drag-data-received", self.on_drag_data_received_event)
self.vpaned.connect("notify::position", self.on_vpaned_position_event) self.vpaned.connect("notify::position", self.on_vpaned_position_event)
if not(self.config["start_in_tray"] and \ if not(self.config["start_in_tray"] and \
self.config["enable_system_tray"]) and not \ self.config["enable_system_tray"]) and not \
self.window.get_property("visible"): self.window.get_property("visible"):
log.debug("Showing window") log.debug("Showing window")
self.show() self.show() 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(urlparse(uri).path))
process_args(args)
drag_context.finish(True, True)
def show(self): def show(self):
try: try:
@ -139,7 +151,7 @@ class MainWindow(component.Component):
if self.config["window_maximized"] == True: if self.config["window_maximized"] == True:
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_heighfrom deluge.ui.gtkui.ipcinterface import process_argt"] - self.config["window_pane_position"])
def on_window_configure_event(self, widget, event): def on_window_configure_event(self, widget, event):
if self.config["window_maximized"] == False and self.visible: if self.config["window_maximized"] == False and self.visible:
@ -183,3 +195,9 @@ class MainWindow(component.Component):
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):
args = []
for uri in selection_data.data.split():
args.append(urllib.unquote(urlparse(uri).path))
process_args(args)
drag_context.finish(True, True)

View file

@ -183,6 +183,8 @@ class TorrentView(listview.ListView, component.Component):
self.treeview.get_selection().connect("changed", self.treeview.get_selection().connect("changed",
self.on_selection_changed) self.on_selection_changed)
self.treeview.connect("drag-drop", self.on_drag_drop)
def start(self): def start(self):
"""Start the torrentview""" """Start the torrentview"""
# We need to get the core session state to know which torrents are in # We need to get the core session state to know which torrents are in
@ -466,3 +468,6 @@ class TorrentView(listview.ListView, component.Component):
component.get("TorrentDetails").update() component.get("TorrentDetails").update()
component.get("ToolBar").update_buttons() component.get("ToolBar").update_buttons()
component.get("MenuBar").update_menu() component.get("MenuBar").update_menu()
def on_drag_drop(self, widget, drag_context, x, y, timestamp):
widget.stop_emission("drag-drop")