Do not show graphics editor options from snap
Gracefully handle the graphics editor options when running from within a snap. When running in snap confinement, the graphics editor option in the preferences panel is removed and edits to an existing decal will use xdg-open, allowing the user to select the appropriate application for editing using the system options. Signed-off-by: Billy Olsen <billy.olsen@gmail.com>
This commit is contained in:
parent
3b16a68fb3
commit
9666c4137b
@ -8,12 +8,9 @@ import java.awt.Desktop;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
|
||||
|
@ -23,6 +23,8 @@ import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import net.sf.openrocket.arch.SystemInfo;
|
||||
import net.sf.openrocket.arch.SystemInfo.Platform;
|
||||
import net.sf.openrocket.gui.adaptors.BooleanModel;
|
||||
import net.sf.openrocket.gui.components.StyledLabel;
|
||||
import net.sf.openrocket.gui.components.StyledLabel.Style;
|
||||
@ -37,7 +39,7 @@ public class GraphicsPreferencesPanel extends PreferencesPanel {
|
||||
public GraphicsPreferencesPanel(JDialog parent) {
|
||||
super(parent, new MigLayout("fillx"));
|
||||
|
||||
this.add(new JPanel(new MigLayout("fill, ins n n n")) {
|
||||
JPanel editorPrefPanel = new JPanel(new MigLayout("fill, ins n n n")) {
|
||||
{ //Editor Options
|
||||
TitledBorder border = BorderFactory.createTitledBorder(trans.get("pref.dlg.lbl.DecalEditor"));
|
||||
GUIUtil.changeFontStyle(border, Font.BOLD);
|
||||
@ -135,7 +137,16 @@ public class GraphicsPreferencesPanel extends PreferencesPanel {
|
||||
|
||||
});
|
||||
}
|
||||
}, "growx, span");
|
||||
};
|
||||
|
||||
/* Don't show the editor preferences panel when confined in a snap on Linux.
|
||||
* The snap confinement doesn't allow to run any edit commands, and instead
|
||||
* we will rely on using the xdg-open command which allows the user to pick
|
||||
* their preferred application.
|
||||
*/
|
||||
if (SystemInfo.getPlatform() != Platform.UNIX && !SystemInfo.isConfined()) {
|
||||
this.add(editorPrefPanel, "growx, span");
|
||||
}
|
||||
|
||||
this.add(new JPanel(new MigLayout("fill, ins n n n")) {
|
||||
{/////GL Options
|
||||
|
@ -74,15 +74,17 @@ public class EditDecalHelper {
|
||||
|
||||
boolean sysPrefSet = prefs.isDecalEditorPreferenceSet();
|
||||
int usageCount = doc.countDecalUsage(decal);
|
||||
boolean isSnapConfined = (SystemInfo.getPlatform() == Platform.UNIX && SystemInfo.isConfined());
|
||||
|
||||
//First Check preferences
|
||||
if (sysPrefSet && usageCount == 1) {
|
||||
|
||||
launchEditor(prefs.isDecalEditorPreferenceSystem(), prefs.getDecalEditorCommandLine(), decal);
|
||||
if (usageCount == 1 && (sysPrefSet || isSnapConfined)) {
|
||||
String commandLine = isSnapConfined ? "xdg-open %%" : prefs.getDecalEditorCommandLine();
|
||||
launchEditor(prefs.isDecalEditorPreferenceSystem(), commandLine, decal);
|
||||
return decal;
|
||||
}
|
||||
|
||||
EditDecalDialog dialog = new EditDecalDialog(parent, !sysPrefSet, usageCount);
|
||||
boolean promptForEditor = (!sysPrefSet && !isSnapConfined);
|
||||
EditDecalDialog dialog = new EditDecalDialog(parent, promptForEditor, usageCount);
|
||||
dialog.setVisible(true);
|
||||
|
||||
if (dialog.isCancel()) {
|
||||
@ -93,7 +95,10 @@ public class EditDecalHelper {
|
||||
boolean useSystemEditor = false;
|
||||
String commandLine = "";
|
||||
|
||||
if (sysPrefSet) {
|
||||
if (isSnapConfined) {
|
||||
useSystemEditor = false;
|
||||
commandLine = "xdg-open %%";
|
||||
} else if (sysPrefSet) {
|
||||
useSystemEditor = prefs.isDecalEditorPreferenceSystem();
|
||||
commandLine = prefs.getDecalEditorCommandLine();
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user