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