feat: expand Files features; add file associations
This commit is contained in:
1 parent
23cc56b933
commit
61d3b368f3
20 files changed
+779
-238
No files matched your search
@@ -281,28 +281,28 @@ void filemanager_open_entry(FileManagerState* fm, int idx) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Open file with appropriate app
|
||||
// Open the file with its default app (see associations.cpp).
|
||||
DesktopState* ds = fm->desktop;
|
||||
const char* name = fm->entry_names[idx];
|
||||
char fullpath[512];
|
||||
filemanager_build_fullpath(fullpath, 512, fm->current_path, fm->entry_names[idx]);
|
||||
if (is_image_file(fm->entry_names[idx])) {
|
||||
montauk::spawn("0:/apps/imageviewer/imageviewer.elf", fullpath);
|
||||
} else if (is_font_file(fm->entry_names[idx])) {
|
||||
montauk::spawn("0:/apps/fontpreview/fontpreview.elf", fullpath);
|
||||
} else if (is_pdf_file(fm->entry_names[idx])) {
|
||||
montauk::spawn("0:/apps/pdfviewer/pdfviewer.elf", fullpath);
|
||||
} else if (is_spreadsheet_file(fm->entry_names[idx])) {
|
||||
montauk::spawn("0:/apps/spreadsheet/spreadsheet.elf", fullpath);
|
||||
} else if (is_wordprocessor_file(fm->entry_names[idx])) {
|
||||
montauk::spawn("0:/apps/wordprocessor/wordprocessor.elf", fullpath);
|
||||
} else if (is_audio_file(fm->entry_names[idx])) {
|
||||
montauk::spawn("0:/apps/music/music.elf", fullpath);
|
||||
} else if (is_video_file(fm->entry_names[idx])) {
|
||||
montauk::spawn("0:/apps/video/video.elf", fullpath);
|
||||
} else if (str_ends_with(fm->entry_names[idx], ".elf")) {
|
||||
montauk::spawn(fullpath);
|
||||
} else {
|
||||
montauk::spawn("0:/apps/texteditor/texteditor.elf", fullpath);
|
||||
filemanager_build_fullpath(fullpath, 512, fm->current_path, name);
|
||||
if (str_ends_with(name, ".elf")) {
|
||||
desktop_spawn_app(ds, fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
char ext[16];
|
||||
file_extension(name, ext, sizeof(ext));
|
||||
int app = filemanager_assoc_default(ds, ext);
|
||||
if (app >= 0 && filemanager_launch_with(ds, app, fullpath)) return;
|
||||
|
||||
// Nothing claims this type: text still goes straight to the Text Editor
|
||||
// (READMEs, Makefiles, odd extensions); anything else asks.
|
||||
if (filemanager_file_looks_textual(fullpath)) {
|
||||
desktop_spawn_app(ds, "0:/apps/texteditor/texteditor.elf", fullpath);
|
||||
return;
|
||||
}
|
||||
filemanager_show_open_with(fm, idx);
|
||||
}
|
||||
|
||||
} // namespace filemanager
|
||||
Reference in new issue
Block a user