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
@@ -181,6 +181,27 @@ void desktop_scan_apps(DesktopState* ds) {
|
||||
snprintf(item->binary_path, sizeof(item->binary_path),
|
||||
"0:/apps/%s/%s", dirname, binary);
|
||||
|
||||
// File types the app opens, used by Files for default apps and
|
||||
// "Open With". Stored lowercased as " ext1 ext2 " for whole-word
|
||||
// matching; entries that would overflow the buffer are dropped.
|
||||
if (auto* types = doc.get_array("files.types")) {
|
||||
int len = 0;
|
||||
item->file_types[len++] = ' ';
|
||||
for (int t = 0; t < types->array.count; t++) {
|
||||
auto* v = types->array.items[t];
|
||||
if (v->type != montauk::toml::Type::String || !v->str[0]) continue;
|
||||
const char* ext = v->str[0] == '.' ? v->str + 1 : v->str;
|
||||
int elen = montauk::slen(ext);
|
||||
if (elen == 0 || len + elen + 2 > (int)sizeof(item->file_types)) continue;
|
||||
for (int k = 0; k < elen; k++) {
|
||||
char ch = ext[k];
|
||||
item->file_types[len++] = (ch >= 'A' && ch <= 'Z') ? ch + 32 : ch;
|
||||
}
|
||||
item->file_types[len++] = ' ';
|
||||
}
|
||||
item->file_types[len < 2 ? 0 : len] = '\0';
|
||||
}
|
||||
|
||||
// Load icon from app directory
|
||||
item->icon = {};
|
||||
item->icon_path[0] = '\0';
|
||||
|
||||
Reference in new issue
Block a user