Skip to content

Commit 5ab60c8

Browse files
committed
default to using Desktop methods for URLs and files when available on Linux
1 parent d3e0693 commit 5ab60c8

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

app/src/processing/app/platform/LinuxPlatform.java

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
package processing.app.platform;
2424

2525
import java.io.File;
26+
import java.awt.Desktop;
2627
import java.awt.Toolkit;
2728

2829
import processing.app.Base;
@@ -97,26 +98,34 @@ static public String getHomeDir(String user) throws Exception {
9798
}
9899

99100

101+
@Override
100102
public File getSettingsFolder() throws Exception {
101103
return new File(getHomeDir(), ".processing");
102104
}
103105

104106

107+
@Override
105108
public File getDefaultSketchbookFolder() throws Exception {
106109
return new File(getHomeDir(), "sketchbook");
107110
}
108111

109112

113+
@Override
110114
public void openURL(String url) throws Exception {
111-
if (openFolderAvailable()) {
112-
String launcher = Preferences.get("launcher");
113-
if (launcher != null) {
114-
Runtime.getRuntime().exec(new String[] { launcher, url });
115-
}
115+
if (Desktop.isDesktopSupported()) {
116+
super.openURL(url);
117+
118+
} else if (openFolderAvailable()) {
119+
String launcher = Preferences.get("launcher"); // guaranteed non-null
120+
Runtime.getRuntime().exec(new String[] { launcher, url });
121+
122+
} else {
123+
System.err.println("No launcher set, cannot open " + url);
116124
}
117125
}
118126

119127

128+
@Override
120129
public boolean openFolderAvailable() {
121130
if (Preferences.get("launcher") != null) {
122131
return true;
@@ -151,19 +160,18 @@ public boolean openFolderAvailable() {
151160
}
152161

153162

163+
@Override
154164
public void openFolder(File file) throws Exception {
155-
if (openFolderAvailable()) {
156-
String lunch = Preferences.get("launcher");
157-
try {
158-
String[] params = new String[] { lunch, file.getAbsolutePath() };
159-
//processing.core.PApplet.println(params);
160-
/*Process p =*/ Runtime.getRuntime().exec(params);
161-
/*int result =*/ //p.waitFor();
162-
} catch (Exception e) {
163-
e.printStackTrace();
164-
}
165+
if (Desktop.isDesktopSupported()) {
166+
super.openFolder(file);
167+
168+
} else if (openFolderAvailable()) {
169+
String launcher = Preferences.get("launcher");
170+
String[] params = new String[] { launcher, file.getAbsolutePath() };
171+
Runtime.getRuntime().exec(params);
172+
165173
} else {
166-
System.out.println("No launcher set, cannot open " +
174+
System.err.println("No launcher set, cannot open " +
167175
file.getAbsolutePath());
168176
}
169177
}

todo.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ X redo key command for Windows screwed up
55
X https://github.com/processing/processing/issues/5773
66
X fix an editor problem with plain text (css, etc) files
77
X https://github.com/processing/processing/issues/5628
8+
X default to using Desktop methods for URLs and files when available on Linux
9+
X also cover a few weird cases that were failing silently
810

911

1012
contrib

0 commit comments

Comments
 (0)