1 $NetBSD: patch-ai,v 1.2 2009/12/15 12:07:57 asau Exp $
3 --- lib/gs/src/tool_utils.erl.orig 2009-03-12 14:23:23.000000000 +0200
4 +++ lib/gs/src/tool_utils.erl 2010-02-24 14:39:44.000000000 +0200
9 +%% Browser executable list (openURL command line protocol required)
10 +-define(BROWSERS, ["netscape", "mozilla", "MozillaFirebird", "opera"]).
12 %%----------------------------------------------------------------------
13 %% open_help(Parent, File)
14 %% Parent = gsobj() (GS root object or parent window)
18 darwin -> "open " ++ File;
19 - _Else -> "netscape -remote \"openURL(file:" ++ File ++ ")\""
20 + _Else -> unix_url_command("file:" ++ File)
23 "start " ++ filename:nativename(File);
27 darwin -> "open " ++ File;
28 - _Else -> "netscape -remote \"openURL(file:" ++ File ++ ")\""
29 + _Else -> unix_url_command("file:" ++ File)
32 "netscape.exe -h " ++ regexp:gsub(File,"\\\\","/");
35 insert_newlines(Other) ->
38 +%% find_browser(BrowserList) => string() | false
39 +%% BrowserList - [string()]
40 +%% Given a list of basenames, find the first available executable.
45 +find_browser([H | T]) ->
46 + case os:find_executable(H) of
53 +%% unix_url_command(URL) => string()
55 +%% Open an URL, using a browser which supports the openURL command
56 +%% line protocol. If no browser is found, the empty string will be
59 +unix_url_command(URL) ->
60 + Template = "BROWSER -remote \"openURL(" ++ URL ++ ")\" || BROWSER " ++ URL ++ "&",
62 + case os:getenv("BROWSER") of
64 + %% look for a compatible browser
65 + case find_browser(?BROWSERS) of
69 + case regexp:gsub(Template, "BROWSER", Browser) of
71 + %% Template does not contain "BROWSER" placeholder
79 + case regexp:gsub(Template, "BROWSER", Value) of
80 + {ok, Command2, 0} ->
83 + {ok, Command2, _} ->