open_url_in_browser() tweaks.
This commit is contained in:
parent
681e43ef9d
commit
30b69cd85a
|
@ -126,7 +126,7 @@ class plugin_Search:
|
|||
url = url.replace('${query}', entry)
|
||||
print 'URL =', url
|
||||
print 'Entry =', entry
|
||||
common.open_url_in_browser(None, url)
|
||||
common.open_url_in_browser(url)
|
||||
|
||||
def populate_search_menu(self):
|
||||
import gtk
|
||||
|
|
|
@ -113,7 +113,7 @@ def get_glade_file(fname):
|
|||
def get_pixmap(fname):
|
||||
return os.path.join(PIXMAP_DIR, fname)
|
||||
|
||||
def open_url_in_browser(dialog, link):
|
||||
def open_url_in_browser(link):
|
||||
class LaunchBrowser(threading.Thread):
|
||||
def run(self):
|
||||
try:
|
||||
|
@ -122,6 +122,11 @@ def open_url_in_browser(dialog, link):
|
|||
print _("Error: no webbrowser found")
|
||||
LaunchBrowser().start()
|
||||
|
||||
def is_url(url):
|
||||
import re
|
||||
|
||||
return bool(re.search('^(https?|ftp)://', url))
|
||||
|
||||
def fetch_url(url):
|
||||
import urllib
|
||||
|
||||
|
|
|
@ -150,8 +150,7 @@ class PreferencesDlg:
|
|||
return r
|
||||
|
||||
def TestPort(self, widget):
|
||||
common.open_url_in_browser(self.dialog,
|
||||
'http://www.deluge-torrent.org/test-port.php?port=%s' % self.active_port)
|
||||
common.open_url_in_browser('http://www.deluge-torrent.org/test-port.php?port=%s' % self.active_port)
|
||||
|
||||
|
||||
def tray_toggle(self, widget):
|
||||
|
@ -273,7 +272,10 @@ class PluginDlg:
|
|||
|
||||
|
||||
def show_about_dialog(parent=None):
|
||||
gtk.about_dialog_set_url_hook(common.open_url_in_browser)
|
||||
def url_hook(dialog, url):
|
||||
common.open_url_in_browser(url)
|
||||
|
||||
gtk.about_dialog_set_url_hook(url_hook)
|
||||
abt = gtk.glade.XML(common.get_glade_file("aboutdialog.glade")).get_widget("aboutdialog")
|
||||
abt.set_name(common.PROGRAM_NAME)
|
||||
abt.set_version(common.PROGRAM_VERSION)
|
||||
|
|
|
@ -1109,7 +1109,7 @@ class DelugeGTK:
|
|||
self.torrent_model_append(unique_id)
|
||||
|
||||
def launchpad(self, obj=None):
|
||||
common.open_url_in_browser('self', 'https://translations.launchpad.net/deluge/trunk/+pots/deluge')
|
||||
common.open_url_in_browser('https://translations.launchpad.net/deluge/trunk/+pots/deluge')
|
||||
|
||||
def add_torrent_clicked(self, obj=None):
|
||||
torrent = dialogs.show_file_open_dialog()
|
||||
|
@ -1130,7 +1130,7 @@ class DelugeGTK:
|
|||
text = clip.wait_for_text()
|
||||
if text:
|
||||
text = text.strip()
|
||||
if re.search('^(https?|ftp)://', text):
|
||||
if common.is_url(text):
|
||||
entry.set_text(text)
|
||||
dlg.show_all()
|
||||
result = dlg.run()
|
||||
|
|
Loading…
Reference in New Issue