Handle older gtk versions that lack gtk.show_uri(), making them use xdg-open with a fallback to webbrowser.open(). Closes LP#554571

This commit is contained in:
Chris Jones 2010-04-07 12:27:39 +01:00
parent 240d81c5cd
commit b3e1f3750b
1 changed files with 11 additions and 1 deletions

View File

@ -1164,7 +1164,17 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
if prepare == True: if prepare == True:
url = self.prepare_url(url) url = self.prepare_url(url)
dbg('open_url: URL: %s (prepared: %s)' % (url, prepare)) dbg('open_url: URL: %s (prepared: %s)' % (url, prepare))
gtk.show_uri(None, url, gtk.gdk.CURRENT_TIME) if gtk.gtk_version < (2, 14, 0):
dbg('Old gtk (%s,%s,%s), calling xdg-open' % gtk.gtk_version)
try:
subprocess.Popen(["xdg-open", url])
except:
dbg('xdg-open did not work, falling back to webbrowser.open')
import webbrowser
webbrowser.open(url)
else:
# Shiny new Gtk+, so we hope they have a sane setup
gtk.show_uri(None, url, gtk.gdk.CURRENT_TIME)
def paste_clipboard(self, primary=False): def paste_clipboard(self, primary=False):
"""Paste one of the two clipboards""" """Paste one of the two clipboards"""