From 4bb1a115951057f5da08ffec52f49c63e640dda2 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Sat, 6 Sep 2008 16:01:12 +0100 Subject: [PATCH 1/4] Assume http:// for URLs without it --- terminatorlib/terminatorterm.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index 70def21b..b69dac1c 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -832,7 +832,10 @@ text/plain if url: if url[1] != self.matches['email']: - address = url[0] + if url[1]: # Assume HTTP if we launch a URL with no protocol, otherwise xdg-open won't open it + address = "http://" + url[0] + else: + address = url[0] nameopen = _("_Open Link") namecopy = _("_Copy Link Address") iconopen = gtk.image_new_from_stock(gtk.STOCK_JUMP_TO, gtk.ICON_SIZE_MENU) From fd8ad1bbea7f637acc8ab9595b79db01bc9349c6 Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Mon, 8 Sep 2008 20:21:26 +0100 Subject: [PATCH 2/4] Launch ftp.x.y with an ftp protocol --- terminatorlib/terminatorterm.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index b69dac1c..0091ec76 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -832,8 +832,14 @@ text/plain if url: if url[1] != self.matches['email']: - if url[1]: # Assume HTTP if we launch a URL with no protocol, otherwise xdg-open won't open it - address = "http://" + url[0] + # Add protocol if we launch a URL without it, otherwise xdg-open won't open it + if url[1] == self.matches['addr_only']: + if url[0][0:3] == "ftp": + # "ftp.foo.bar" -> "ftp://ftp.foo.bar" + address = "ftp://" + url[0] + else: + # Assume http + address = "http://" + url[0] else: address = url[0] nameopen = _("_Open Link") From aead00463c87a2715b86de39dd4f1766edb3657f Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Mon, 8 Sep 2008 20:42:26 +0100 Subject: [PATCH 3/4] Need to start xdg-open in a new process as it does not do that itself - some browsers (Epiphany) can therefore cause Terminator to block until they are exited --- terminatorlib/terminatorterm.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index 0091ec76..f8de9f63 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -170,10 +170,12 @@ class TerminatorTerm (gtk.VBox): def openurl (self, url): dbg ('openurl: viewing %s'%url) try: - dbg ('openurl: calling xdg-open') - if subprocess.call(["xdg-open", url]) != 0: - dbg ('openurl: xdg-open failed') - raise + try: + dbg ('openurl: calling xdg-open') + subprocess.Popen(["xdg-open", url]) + except: + dbg ('openurl: xdg-open failed') + raise except: try: dbg ('openurl: calling url_show') From 1a975ab7c0c736fdd29ed86d1231b3b6e10e64dc Mon Sep 17 00:00:00 2001 From: Iain Lane Date: Mon, 8 Sep 2008 21:13:31 +0100 Subject: [PATCH 4/4] Remove unnecessary try-except block --- terminatorlib/terminatorterm.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/terminatorlib/terminatorterm.py b/terminatorlib/terminatorterm.py index f8de9f63..7786104c 100755 --- a/terminatorlib/terminatorterm.py +++ b/terminatorlib/terminatorterm.py @@ -170,13 +170,10 @@ class TerminatorTerm (gtk.VBox): def openurl (self, url): dbg ('openurl: viewing %s'%url) try: - try: - dbg ('openurl: calling xdg-open') - subprocess.Popen(["xdg-open", url]) - except: - dbg ('openurl: xdg-open failed') - raise + dbg ('openurl: calling xdg-open') + subprocess.Popen(["xdg-open", url]) except: + dbg ('openurl: xdg-open failed') try: dbg ('openurl: calling url_show') self.terminator.url_show (url)