fix: remove hardcoded text editor menu entry, add pass_home_dir flag for manifest.toml files

This commit is contained in:
2026-03-28 09:19:17 +01:00
parent 6106396b52
commit 27b0fef416
9 changed files with 33 additions and 12 deletions
+1 -1
View File
@@ -26,6 +26,7 @@ struct ExternalApp {
char category[24]; char category[24];
SvgIcon icon; SvgIcon icon;
bool menu_visible; bool menu_visible;
bool launch_with_home;
}; };
struct DesktopSettings { struct DesktopSettings {
@@ -81,7 +82,6 @@ struct DesktopState {
SvgIcon icon_computer; SvgIcon icon_computer;
SvgIcon icon_network; SvgIcon icon_network;
SvgIcon icon_calculator; SvgIcon icon_calculator;
SvgIcon icon_texteditor;
SvgIcon icon_go_up; SvgIcon icon_go_up;
SvgIcon icon_go_back; SvgIcon icon_go_back;
SvgIcon icon_go_forward; SvgIcon icon_go_forward;
@@ -1028,7 +1028,12 @@ static void filemanager_open_entry(FileManagerState* fm, int idx) {
if (fm->at_apps_view && fm->entry_types[idx] == 6) { if (fm->at_apps_view && fm->entry_types[idx] == 6) {
DesktopState* ds = fm->desktop; DesktopState* ds = fm->desktop;
if (ds && fm->app_map[idx] >= 0 && fm->app_map[idx] < ds->external_app_count) { if (ds && fm->app_map[idx] >= 0 && fm->app_map[idx] < ds->external_app_count) {
montauk::spawn(ds->external_apps[fm->app_map[idx]].binary_path, ds->home_dir); const ExternalApp& app = ds->external_apps[fm->app_map[idx]];
if (app.launch_with_home) {
montauk::spawn(app.binary_path, ds->home_dir);
} else {
montauk::spawn(app.binary_path);
}
} }
return; return;
} }
+5 -1
View File
@@ -25,6 +25,7 @@ struct MenuRow {
int app_id; // embedded dispatch ID, or -1 for categories/dividers int app_id; // embedded dispatch ID, or -1 for categories/dividers
bool external; // true = spawn binary_path bool external; // true = spawn binary_path
char binary_path[128]; // full VFS path for external apps char binary_path[128]; // full VFS path for external apps
bool launch_with_home; // true = pass home_dir as first argument
SvgIcon* icon; // loaded menu icon (null for categories/dividers) SvgIcon* icon; // loaded menu icon (null for categories/dividers)
}; };
@@ -76,6 +77,7 @@ inline int menu_add_category(const char* label) {
r.app_id = -1; r.app_id = -1;
r.external = false; r.external = false;
r.binary_path[0] = '\0'; r.binary_path[0] = '\0';
r.launch_with_home = false;
r.icon = nullptr; r.icon = nullptr;
return menu_row_count - 1; return menu_row_count - 1;
} }
@@ -88,11 +90,12 @@ inline int menu_add_embedded(const char* label, int app_id, SvgIcon* icon) {
r.app_id = app_id; r.app_id = app_id;
r.external = false; r.external = false;
r.binary_path[0] = '\0'; r.binary_path[0] = '\0';
r.launch_with_home = false;
r.icon = icon; r.icon = icon;
return menu_row_count - 1; return menu_row_count - 1;
} }
inline int menu_add_external(const char* label, const char* binary, SvgIcon* icon) { inline int menu_add_external(const char* label, const char* binary, SvgIcon* icon, bool launch_with_home) {
if (menu_row_count >= MAX_MENU_ROWS) return -1; if (menu_row_count >= MAX_MENU_ROWS) return -1;
MenuRow& r = menu_rows[menu_row_count++]; MenuRow& r = menu_rows[menu_row_count++];
r.is_category = false; r.is_category = false;
@@ -100,6 +103,7 @@ inline int menu_add_external(const char* label, const char* binary, SvgIcon* ico
r.app_id = -1; r.app_id = -1;
r.external = true; r.external = true;
montauk::strncpy(r.binary_path, binary, sizeof(r.binary_path)); montauk::strncpy(r.binary_path, binary, sizeof(r.binary_path));
r.launch_with_home = launch_with_home;
r.icon = icon; r.icon = icon;
return menu_row_count - 1; return menu_row_count - 1;
} }
+4 -1
View File
@@ -339,8 +339,11 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
menu_cat_expanded[cur_cat] = !menu_cat_expanded[cur_cat]; menu_cat_expanded[cur_cat] = !menu_cat_expanded[cur_cat];
} else if (!row.is_category) { } else if (!row.is_category) {
if (row.external) { if (row.external) {
// Launch external app with user's home dir if (row.launch_with_home) {
montauk::spawn(row.binary_path, ds->home_dir); montauk::spawn(row.binary_path, ds->home_dir);
} else {
montauk::spawn(row.binary_path);
}
} else { } else {
// Dispatch embedded app // Dispatch embedded app
switch (row.app_id) { switch (row.app_id) {
+3 -4
View File
@@ -74,10 +74,12 @@ void desktop_scan_apps(DesktopState* ds) {
const char* icon_file = doc.get_string("app.icon", ""); const char* icon_file = doc.get_string("app.icon", "");
const char* category = doc.get_string("menu.category", "Applications"); const char* category = doc.get_string("menu.category", "Applications");
bool visible = doc.get_bool("menu.visible", true); bool visible = doc.get_bool("menu.visible", true);
bool launch_with_home = doc.get_bool("launch.pass_home_dir", true);
montauk::strncpy(app->name, name, sizeof(app->name)); montauk::strncpy(app->name, name, sizeof(app->name));
montauk::strncpy(app->category, category, sizeof(app->category)); montauk::strncpy(app->category, category, sizeof(app->category));
app->menu_visible = visible; app->menu_visible = visible;
app->launch_with_home = launch_with_home;
// Build full binary path: 0:/apps/<dir>/<binary> // Build full binary path: 0:/apps/<dir>/<binary>
snprintf(app->binary_path, sizeof(app->binary_path), snprintf(app->binary_path, sizeof(app->binary_path),
@@ -116,7 +118,6 @@ struct EmbeddedAppDef {
static const EmbeddedAppDef embedded_apps[] = { static const EmbeddedAppDef embedded_apps[] = {
{ "Terminal", 0, 0 }, { "Terminal", 0, 0 },
{ "Files", 1, 0 }, { "Files", 1, 0 },
{ "Text Editor", 4, 0 },
{ "Calculator", 3, 0 }, { "Calculator", 3, 0 },
{ "System Info", 2, 2 }, { "System Info", 2, 2 },
{ "Kernel Log", 5, 2 }, { "Kernel Log", 5, 2 },
@@ -133,7 +134,6 @@ static SvgIcon* icon_for_embedded(DesktopState* ds, int app_id) {
case 1: return &ds->icon_filemanager; case 1: return &ds->icon_filemanager;
case 2: return &ds->icon_sysinfo; case 2: return &ds->icon_sysinfo;
case 3: return &ds->icon_calculator; case 3: return &ds->icon_calculator;
case 4: return &ds->icon_texteditor;
case 5: return &ds->icon_terminal; // Kernel Log uses terminal icon case 5: return &ds->icon_terminal; // Kernel Log uses terminal icon
case 6: return &ds->icon_procmgr; case 6: return &ds->icon_procmgr;
case 7: return &ds->icon_mandelbrot; case 7: return &ds->icon_mandelbrot;
@@ -161,7 +161,7 @@ void desktop_build_menu(DesktopState* ds) {
ExternalApp* app = &ds->external_apps[x]; ExternalApp* app = &ds->external_apps[x];
if (!app->menu_visible) continue; if (!app->menu_visible) continue;
if (montauk::streq(app->category, CATEGORY_NAMES[cat])) { if (montauk::streq(app->category, CATEGORY_NAMES[cat])) {
menu_add_external(app->name, app->binary_path, &app->icon); menu_add_external(app->name, app->binary_path, &app->icon, app->launch_with_home);
} }
} }
} }
@@ -210,7 +210,6 @@ void gui::desktop_init(DesktopState* ds) {
ds->icon_computer = svg_load("0:/icons/computer.svg", 20, 20, defColor); ds->icon_computer = svg_load("0:/icons/computer.svg", 20, 20, defColor);
ds->icon_network = svg_load("0:/icons/network-wired-symbolic.svg", 16, 16, colors::PANEL_TEXT); ds->icon_network = svg_load("0:/icons/network-wired-symbolic.svg", 16, 16, colors::PANEL_TEXT);
ds->icon_calculator = svg_load("0:/icons/accessories-calculator.svg", 20, 20, defColor); ds->icon_calculator = svg_load("0:/icons/accessories-calculator.svg", 20, 20, defColor);
ds->icon_texteditor = svg_load("0:/icons/accessories-text-editor.svg", 20, 20, defColor);
ds->icon_go_up = svg_load("0:/icons/go-up-symbolic.svg", 16, 16, defColor); ds->icon_go_up = svg_load("0:/icons/go-up-symbolic.svg", 16, 16, defColor);
ds->icon_go_back = svg_load("0:/icons/go-previous-symbolic.svg", 16, 16, defColor); ds->icon_go_back = svg_load("0:/icons/go-previous-symbolic.svg", 16, 16, defColor);
ds->icon_go_forward = svg_load("0:/icons/go-next-symbolic.svg", 16, 16, defColor); ds->icon_go_forward = svg_load("0:/icons/go-next-symbolic.svg", 16, 16, defColor);
+11
View File
@@ -0,0 +1,11 @@
[app]
name = "Text Editor"
binary = "texteditor.elf"
icon = "texteditor.svg"
[menu]
category = "Applications"
visible = true
[launch]
pass_home_dir = false
-2
View File
@@ -37,7 +37,6 @@ ICONS=(
"apps/symbolic/system-file-manager-symbolic.svg" "apps/symbolic/system-file-manager-symbolic.svg"
"apps/symbolic/preferences-desktop-apps-symbolic.svg" "apps/symbolic/preferences-desktop-apps-symbolic.svg"
"apps/symbolic/accessories-calculator-symbolic.svg" "apps/symbolic/accessories-calculator-symbolic.svg"
"apps/symbolic/accessories-text-editor-symbolic.svg"
"places/symbolic/folder-symbolic.svg" "places/symbolic/folder-symbolic.svg"
"places/symbolic/folder-documents-symbolic.svg" "places/symbolic/folder-documents-symbolic.svg"
"places/symbolic/user-home-symbolic.svg" "places/symbolic/user-home-symbolic.svg"
@@ -51,7 +50,6 @@ ICONS=(
"apps/scalable/system-file-manager.svg" "apps/scalable/system-file-manager.svg"
"apps/scalable/preferences-desktop-apps.svg" "apps/scalable/preferences-desktop-apps.svg"
"apps/scalable/accessories-calculator.svg" "apps/scalable/accessories-calculator.svg"
"apps/scalable/accessories-text-editor.svg"
"apps/scalable/web-browser.svg" "apps/scalable/web-browser.svg"
"places/scalable/folder.svg" "places/scalable/folder.svg"
"places/scalable/user-home.svg" "places/scalable/user-home.svg"
+1
View File
@@ -33,6 +33,7 @@ APPS=(
"rpgdemo|apps/scalable/utilities-terminal.svg" "rpgdemo|apps/scalable/utilities-terminal.svg"
"paint|apps/scalable/kolourpaint.svg" "paint|apps/scalable/kolourpaint.svg"
"screenshot|apps/scalable/gnome-screenshot.svg" "screenshot|apps/scalable/gnome-screenshot.svg"
"texteditor|apps/scalable/accessories-text-editor.svg"
) )
installed=0 installed=0
+1 -1
View File
@@ -26,6 +26,7 @@ struct ExternalApp {
char category[24]; char category[24];
SvgIcon icon; SvgIcon icon;
bool menu_visible; bool menu_visible;
bool launch_with_home;
}; };
struct DesktopSettings { struct DesktopSettings {
@@ -81,7 +82,6 @@ struct DesktopState {
SvgIcon icon_computer; SvgIcon icon_computer;
SvgIcon icon_network; SvgIcon icon_network;
SvgIcon icon_calculator; SvgIcon icon_calculator;
SvgIcon icon_texteditor;
SvgIcon icon_go_up; SvgIcon icon_go_up;
SvgIcon icon_go_back; SvgIcon icon_go_back;
SvgIcon icon_go_forward; SvgIcon icon_go_forward;