Changeset 6682 in josm


Ignore:
Timestamp:
2014-01-13T19:29:33+01:00 (8 years ago)
Author:
simon04
Message:

fix #5629 #5108 #9568 - Make Unix web browsers configurable via browser.unix property

Default is ["xdg-open", "#DESKTOP#", "$BROWSER", "gnome-open", "kfmclient openURL", "firefox"].

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/OpenBrowser.java

    r6380 r6682  
    5959                    // Desktop API works fine under Windows, so we don't try any fallback in case of I/O exceptions because it's not API's fault
    6060                    Desktop.getDesktop().browse(uri);
     61                } else if (Main.platform instanceof PlatformHookUnixoid) {
     62                    // see #5629 #5108 #9568
     63                    Main.platform.openUrl(uri.toString());
    6164                } else {
    6265                    // This is not the case with some Linux environments (see below), and not sure about Mac OS X, so we need to handle API failure
  • trunk/src/org/openstreetmap/josm/tools/PlatformHookUnixoid.java

    r6443 r6682  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
     6import java.awt.Desktop;
    67import java.awt.Dimension;
    78import java.awt.GraphicsEnvironment;
     
    1213import java.io.IOException;
    1314import java.io.InputStreamReader;
     15import java.net.URI;
     16import java.net.URISyntaxException;
    1417import java.util.Arrays;
    1518
     
    4144    @Override
    4245    public void openUrl(String url) throws IOException {
    43         String[] programs = {"gnome-open", "kfmclient openURL", "firefox"};
    44         for (String program : programs) {
     46        for (String program : Main.pref.getCollection("browser.unix",
     47                Arrays.asList("xdg-open", "#DESKTOP#", "$BROWSER", "gnome-open", "kfmclient openURL", "firefox"))) {
    4548            try {
    46                 Runtime.getRuntime().exec(program+" "+url);
     49                if ("#DESKTOP#".equals(program)) {
     50                    Desktop.getDesktop().browse(new URI(url));
     51                } else if (program.startsWith("$")) {
     52                    program = System.getenv().get(program.substring(1));
     53                    Runtime.getRuntime().exec(new String[]{program, url});
     54                } else {
     55                    Runtime.getRuntime().exec(new String[]{program, url});
     56                }
    4757                return;
    4858            } catch (IOException e) {
     59                Main.warn(e);
     60            } catch (URISyntaxException e) {
    4961                Main.warn(e);
    5062            }
Note: See TracChangeset for help on using the changeset viewer.