Skip to content

Commit

Permalink
Add an option to disable the sandboxing check
Browse files Browse the repository at this point in the history
  • Loading branch information
Sollace committed Jul 25, 2023
1 parent 5257a16 commit cbaf353
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/minelittlepony/hdskins/client/HDConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import com.minelittlepony.hdskins.client.gui.filesystem.FileSystemUtil;

public class HDConfig extends Config {

public final Setting<Path> lastChosenFile = value("lastChosenFile", FileSystemUtil.getUserContentDirectory(FileSystemUtil.CONTENT_TYPE_DOWNLOAD));
public final Setting<Boolean> useNativeFileChooser = value("useNativeFileChooser", false);
public final Setting<Boolean> useNativeFileChooser = value("filesystem", "useNativeFileChooser", false)
.addComment("When enable, will always use the native dialogue for opening and saving files");
public final Setting<Boolean> enableSandboxingCheck = value("filesystem", "enableSandboxingCheck", true)
.addComment("When enabled, will use the native dialogue for opening and saving files only when running inside a sandboxed environment (flatpaks)");

public HDConfig(Path path) {
super(FLATTENED_JSON_ADAPTER, path);
super(HEIRARCHICAL_JSON_ADAPTER, path);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.minelittlepony.hdskins.client.HDSkins;
import com.minelittlepony.hdskins.client.gui.filesystem.FileDialogs;
import com.minelittlepony.hdskins.client.gui.filesystem.FileSystemUtil;
import com.minelittlepony.hdskins.client.gui.filesystem.WatchedFile;
import com.minelittlepony.hdskins.profile.SkinType;

Expand Down Expand Up @@ -72,10 +73,12 @@ public void addSkinChangedEventListener(Consumer<SkinType> listener) {
}

private FileDialogs getFileDialogs() {
if (HDSkins.getInstance().getConfig().useNativeFileChooser.get()) {
if ((FileSystemUtil.IS_SANDBOXED && !HDSkins.getInstance().getConfig().enableSandboxingCheck.get())
|| HDSkins.getInstance().getConfig().useNativeFileChooser.get()) {
return FileDialogs.NATIVE;
}
return FileDialogs.DEFAULT;

return FileDialogs.INTEGRATED;
}

public void addImageValidation(Function<NativeImage, Text> validator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ public interface FileDialogs {
FileDialogs INTEGRATED = new IntegratedFileDialogs();
FileDialogs NATIVE = new NativeFileDialogs();

FileDialogs DEFAULT = FileSystemUtil.IS_SANDBOXED ? NATIVE : INTEGRATED;

FileDialog open(String title);

FileDialog save(String title, String filename);
Expand Down

0 comments on commit cbaf353

Please sign in to comment.