From 8dd28eb973a1c072448d961a6fb6a8a12cc3c950 Mon Sep 17 00:00:00 2001 From: Neal Norwitz Date: Thu, 10 Oct 2002 22:49:29 +0000 Subject: [PATCH] SF # 585913, Adds Galeon support to webbrowser.py --- Lib/webbrowser.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py index b562ab3d191..ac8ce58e97d 100644 --- a/Lib/webbrowser.py +++ b/Lib/webbrowser.py @@ -135,6 +135,33 @@ class Netscape: self.open(url, 1) +class Galeon: + """Launcher class for Galeon browsers.""" + def __init__(self, name): + self.name = name + self.basename = os.path.basename(name) + + def _remote(self, action, autoraise): + raise_opt = ("--noraise", "")[autoraise] + cmd = "%s %s %s >/dev/null 2>&1" % (self.name, raise_opt, action) + rc = os.system(cmd) + if rc: + import time + os.system("%s >/dev/null 2>&1 &" % self.name) + time.sleep(PROCESS_CREATION_DELAY) + rc = os.system(cmd) + return not rc + + def open(self, url, new=0, autoraise=1): + if new: + self._remote("-w '%s'" % url, autoraise) + else: + self._remote("-n '%s'" % url, autoraise) + + def open_new(self, url): + self.open(url, 1) + + class Konqueror: """Controller for the KDE File Manager (kfm, or Konqueror). @@ -234,7 +261,8 @@ class WindowsDefault: # the TERM and DISPLAY cases, because we might be running Python from inside # an xterm. if os.environ.get("TERM") or os.environ.get("DISPLAY"): - _tryorder = ["mozilla","netscape","kfm","grail","links","lynx","w3m"] + _tryorder = ["galeon", "mozilla", "netscape", "kfm", + "grail", "links", "lynx", "w3m",] # Easy cases first -- register console browsers if we have them. if os.environ.get("TERM"): @@ -261,6 +289,10 @@ if os.environ.get("TERM") or os.environ.get("DISPLAY"): register("mosaic", None, GenericBrowser( "mosaic '%s' >/dev/null &")) + # Gnome's Galeon + if _iscommand("galeon"): + register("galeon", None, Galeon("galeon")) + # Konqueror/kfm, the KDE browser. if _iscommand("kfm") or _iscommand("konqueror"): register("kfm", Konqueror, Konqueror())