fix: remove hardcoded text editor menu entry, add pass_home_dir flag for manifest.toml files
This commit is contained in:
@@ -26,6 +26,7 @@ struct ExternalApp {
|
||||
char category[24];
|
||||
SvgIcon icon;
|
||||
bool menu_visible;
|
||||
bool launch_with_home;
|
||||
};
|
||||
|
||||
struct DesktopSettings {
|
||||
@@ -81,7 +82,6 @@ struct DesktopState {
|
||||
SvgIcon icon_computer;
|
||||
SvgIcon icon_network;
|
||||
SvgIcon icon_calculator;
|
||||
SvgIcon icon_texteditor;
|
||||
SvgIcon icon_go_up;
|
||||
SvgIcon icon_go_back;
|
||||
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) {
|
||||
DesktopState* ds = fm->desktop;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ struct MenuRow {
|
||||
int app_id; // embedded dispatch ID, or -1 for categories/dividers
|
||||
bool external; // true = spawn binary_path
|
||||
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)
|
||||
};
|
||||
|
||||
@@ -76,6 +77,7 @@ inline int menu_add_category(const char* label) {
|
||||
r.app_id = -1;
|
||||
r.external = false;
|
||||
r.binary_path[0] = '\0';
|
||||
r.launch_with_home = false;
|
||||
r.icon = nullptr;
|
||||
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.external = false;
|
||||
r.binary_path[0] = '\0';
|
||||
r.launch_with_home = false;
|
||||
r.icon = icon;
|
||||
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;
|
||||
MenuRow& r = menu_rows[menu_row_count++];
|
||||
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.external = true;
|
||||
montauk::strncpy(r.binary_path, binary, sizeof(r.binary_path));
|
||||
r.launch_with_home = launch_with_home;
|
||||
r.icon = icon;
|
||||
return menu_row_count - 1;
|
||||
}
|
||||
|
||||
@@ -339,8 +339,11 @@ void gui::desktop_handle_mouse(DesktopState* ds) {
|
||||
menu_cat_expanded[cur_cat] = !menu_cat_expanded[cur_cat];
|
||||
} else if (!row.is_category) {
|
||||
if (row.external) {
|
||||
// Launch external app with user's home dir
|
||||
montauk::spawn(row.binary_path, ds->home_dir);
|
||||
if (row.launch_with_home) {
|
||||
montauk::spawn(row.binary_path, ds->home_dir);
|
||||
} else {
|
||||
montauk::spawn(row.binary_path);
|
||||
}
|
||||
} else {
|
||||
// Dispatch embedded app
|
||||
switch (row.app_id) {
|
||||
|
||||
@@ -74,10 +74,12 @@ void desktop_scan_apps(DesktopState* ds) {
|
||||
const char* icon_file = doc.get_string("app.icon", "");
|
||||
const char* category = doc.get_string("menu.category", "Applications");
|
||||
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->category, category, sizeof(app->category));
|
||||
app->menu_visible = visible;
|
||||
app->launch_with_home = launch_with_home;
|
||||
|
||||
// Build full binary path: 0:/apps/<dir>/<binary>
|
||||
snprintf(app->binary_path, sizeof(app->binary_path),
|
||||
@@ -116,7 +118,6 @@ struct EmbeddedAppDef {
|
||||
static const EmbeddedAppDef embedded_apps[] = {
|
||||
{ "Terminal", 0, 0 },
|
||||
{ "Files", 1, 0 },
|
||||
{ "Text Editor", 4, 0 },
|
||||
{ "Calculator", 3, 0 },
|
||||
{ "System Info", 2, 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 2: return &ds->icon_sysinfo;
|
||||
case 3: return &ds->icon_calculator;
|
||||
case 4: return &ds->icon_texteditor;
|
||||
case 5: return &ds->icon_terminal; // Kernel Log uses terminal icon
|
||||
case 6: return &ds->icon_procmgr;
|
||||
case 7: return &ds->icon_mandelbrot;
|
||||
@@ -161,7 +161,7 @@ void desktop_build_menu(DesktopState* ds) {
|
||||
ExternalApp* app = &ds->external_apps[x];
|
||||
if (!app->menu_visible) continue;
|
||||
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_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_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_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);
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
[app]
|
||||
name = "Text Editor"
|
||||
binary = "texteditor.elf"
|
||||
icon = "texteditor.svg"
|
||||
|
||||
[menu]
|
||||
category = "Applications"
|
||||
visible = true
|
||||
|
||||
[launch]
|
||||
pass_home_dir = false
|
||||
Reference in New Issue
Block a user