From b3e1f3750b45dd541efc37a93196f3c83d4df187 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Wed, 7 Apr 2010 12:27:39 +0100 Subject: [PATCH] Handle older gtk versions that lack gtk.show_uri(), making them use xdg-open with a fallback to webbrowser.open(). Closes LP#554571 --- terminatorlib/terminal.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 8f23df66..bfd7e9dd 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -1164,7 +1164,17 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) if prepare == True: url = self.prepare_url(url) 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): """Paste one of the two clipboards"""