Small file browser fixes

This commit is contained in:
crschnick 2023-05-19 15:29:19 +00:00
parent 55d54fad01
commit a4cd30311a
3 changed files with 14 additions and 6 deletions

View file

@ -6,6 +6,8 @@ import io.xpipe.app.browser.FileBrowserEntry;
import io.xpipe.app.browser.OpenFileSystemModel;
import io.xpipe.app.browser.action.LeafAction;
import io.xpipe.core.process.OsType;
import io.xpipe.core.process.ShellControl;
import io.xpipe.core.process.ShellDialect;
import javafx.scene.Node;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyCodeCombination;
@ -30,7 +32,9 @@ public class OpenFileWithAction implements LeafAction {
WinUser.SW_SHOWNORMAL);
}
case OsType.Linux linux -> {
throw new UnsupportedOperationException();
ShellControl sc = model.getFileSystem().getShell().get();
ShellDialect d = sc.getShellDialect();
sc.executeSimpleCommand("mimeopen -a " + d.fileArgument(entries.get(0).getRawFileEntry().getPath()));
}
case OsType.MacOs macOs -> {
throw new UnsupportedOperationException();
@ -52,7 +56,7 @@ public class OpenFileWithAction implements LeafAction {
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
var os = model.getFileSystem().getShell();
return os.isPresent()
&& os.get().getOsType().equals(OsType.WINDOWS)
&& !os.get().getOsType().equals(OsType.MACOS)
&& entries.size() == 1
&& entries.stream().noneMatch(entry -> entry.getRawFileEntry().isDirectory());
}

View file

@ -22,9 +22,10 @@ public class OpenInNativeManagerAction implements LeafAction {
sc.executeSimpleCommand("explorer " + d.fileArgument(e));
}
case OsType.Linux linux -> {
var action = entry.getRawFileEntry().isDirectory() ? "org.freedesktop.FileManager1.ShowFolders" : "org.freedesktop.FileManager1.ShowFiles";
var dbus = String.format("""
dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItems array:string:"file://%s" string:""
""", entry.getRawFileEntry().getPath());
dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 %s array:string:"file://%s" string:""
""", action, entry.getRawFileEntry().getPath());
sc.executeSimpleCommand(dbus);
}
case OsType.MacOs macOs -> {

View file

@ -29,7 +29,10 @@ public class OpenNativeFileDetailsAction implements LeafAction {
}
}
case OsType.Linux linux -> {
throw new UnsupportedOperationException();
var dbus = String.format("""
dbus-send --session --print-reply --dest=org.freedesktop.FileManager1 --type=method_call /org/freedesktop/FileManager1 org.freedesktop.FileManager1.ShowItemProperties array:string:"file://%s" string:""
""", entry.getRawFileEntry().getPath());
sc.executeSimpleCommand(dbus);
}
case OsType.MacOs macOs -> {
sc.osascriptCommand(String.format(
@ -56,7 +59,7 @@ public class OpenNativeFileDetailsAction implements LeafAction {
@Override
public boolean isApplicable(OpenFileSystemModel model, List<FileBrowserEntry> entries) {
var os = model.getFileSystem().getShell();
return os.isPresent() && !os.get().getOsType().equals(OsType.LINUX);
return os.isPresent();
}
@Override