clean up adding via url and make enter submit it instead of having to click ok
This commit is contained in:
parent
234e6827e8
commit
466292d38e
|
@ -42,14 +42,24 @@ import pkg_resources
|
||||||
class AddTorrentUrl:
|
class AddTorrentUrl:
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
"""Set up url dialog"""
|
"""Set up url dialog"""
|
||||||
self.dlg = gtk.Dialog(title=_("Add torrent from URL"), parent=None,
|
self.dlg = gtk.Dialog(_("Add torrent from URL"), None, 0, \
|
||||||
buttons=(gtk.STOCK_CANCEL, 0, gtk.STOCK_OK, 1))
|
(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,gtk.STOCK_OK, gtk.RESPONSE_OK))
|
||||||
|
self.dlg.set_default_response(gtk.RESPONSE_OK)
|
||||||
self.dlg.set_icon(deluge.common.get_logo(32))
|
self.dlg.set_icon(deluge.common.get_logo(32))
|
||||||
self.dlg.set_default_response(1)
|
self.dlg.set_default_response(1)
|
||||||
label = gtk.Label(_("Enter the URL of the .torrent to download"))
|
label = gtk.Label(_("Enter the URL of the .torrent to download"))
|
||||||
self.entry = gtk.Entry()
|
self.entry = gtk.Entry()
|
||||||
|
self.entry.connect("activate", lambda w : self.dlg.response\
|
||||||
|
(gtk.RESPONSE_OK))
|
||||||
self.dlg.vbox.pack_start(label)
|
self.dlg.vbox.pack_start(label)
|
||||||
self.dlg.vbox.pack_start(self.entry)
|
self.dlg.vbox.pack_start(self.entry)
|
||||||
|
if deluge.common.windows_check():
|
||||||
|
import win32clipboard as clip
|
||||||
|
import win32con
|
||||||
|
clip.OpenClipboard()
|
||||||
|
text = clip.GetClipboardData(win32con.CF_UNICODETEXT)
|
||||||
|
clip.CloseClipboard()
|
||||||
|
else:
|
||||||
clip = gtk.clipboard_get(selection='PRIMARY')
|
clip = gtk.clipboard_get(selection='PRIMARY')
|
||||||
text = clip.wait_for_text()
|
text = clip.wait_for_text()
|
||||||
if text:
|
if text:
|
||||||
|
@ -61,9 +71,10 @@ class AddTorrentUrl:
|
||||||
"""Show url dialog and add torrent"""
|
"""Show url dialog and add torrent"""
|
||||||
self.dlg.show_all()
|
self.dlg.show_all()
|
||||||
self.response = self.dlg.run()
|
self.response = self.dlg.run()
|
||||||
url = self.entry.get_text()
|
if self.response == gtk.RESPONSE_OK:
|
||||||
|
url = self.entry.get_text().decode("utf_8")
|
||||||
self.dlg.destroy()
|
self.dlg.destroy()
|
||||||
if self.response == 1:
|
|
||||||
return url
|
return url
|
||||||
else:
|
else:
|
||||||
|
self.dlg.destroy()
|
||||||
return None
|
return None
|
||||||
|
|
Loading…
Reference in New Issue