mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
default to using Desktop methods for URLs and files when available on Linux
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
package processing.app.platform;
|
||||
|
||||
import java.io.File;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import processing.app.Base;
|
||||
@@ -97,26 +98,34 @@ public class LinuxPlatform extends DefaultPlatform {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File getSettingsFolder() throws Exception {
|
||||
return new File(getHomeDir(), ".processing");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public File getDefaultSketchbookFolder() throws Exception {
|
||||
return new File(getHomeDir(), "sketchbook");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void openURL(String url) throws Exception {
|
||||
if (openFolderAvailable()) {
|
||||
String launcher = Preferences.get("launcher");
|
||||
if (launcher != null) {
|
||||
Runtime.getRuntime().exec(new String[] { launcher, url });
|
||||
}
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
super.openURL(url);
|
||||
|
||||
} else if (openFolderAvailable()) {
|
||||
String launcher = Preferences.get("launcher"); // guaranteed non-null
|
||||
Runtime.getRuntime().exec(new String[] { launcher, url });
|
||||
|
||||
} else {
|
||||
System.err.println("No launcher set, cannot open " + url);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean openFolderAvailable() {
|
||||
if (Preferences.get("launcher") != null) {
|
||||
return true;
|
||||
@@ -151,19 +160,18 @@ public class LinuxPlatform extends DefaultPlatform {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void openFolder(File file) throws Exception {
|
||||
if (openFolderAvailable()) {
|
||||
String lunch = Preferences.get("launcher");
|
||||
try {
|
||||
String[] params = new String[] { lunch, file.getAbsolutePath() };
|
||||
//processing.core.PApplet.println(params);
|
||||
/*Process p =*/ Runtime.getRuntime().exec(params);
|
||||
/*int result =*/ //p.waitFor();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (Desktop.isDesktopSupported()) {
|
||||
super.openFolder(file);
|
||||
|
||||
} else if (openFolderAvailable()) {
|
||||
String launcher = Preferences.get("launcher");
|
||||
String[] params = new String[] { launcher, file.getAbsolutePath() };
|
||||
Runtime.getRuntime().exec(params);
|
||||
|
||||
} else {
|
||||
System.out.println("No launcher set, cannot open " +
|
||||
System.err.println("No launcher set, cannot open " +
|
||||
file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ X redo key command for Windows screwed up
|
||||
X https://github.com/processing/processing/issues/5773
|
||||
X fix an editor problem with plain text (css, etc) files
|
||||
X https://github.com/processing/processing/issues/5628
|
||||
X default to using Desktop methods for URLs and files when available on Linux
|
||||
X also cover a few weird cases that were failing silently
|
||||
|
||||
|
||||
contrib
|
||||
|
||||
Reference in New Issue
Block a user