From 2130498be2368f187ed82e4a5484340204c6f89f Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Sat, 18 Oct 2025 16:31:59 +0000 Subject: [PATCH] home directory git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@412 b9cfdab3-6d41-4d17-bbe4-086880011989 --- include/Mw/MachDep.h | 1 + src/filechooser.c | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/Mw/MachDep.h b/include/Mw/MachDep.h index a74d398..0f14b84 100644 --- a/include/Mw/MachDep.h +++ b/include/Mw/MachDep.h @@ -20,6 +20,7 @@ #include #else #include +#include #include #include #include diff --git a/src/filechooser.c b/src/filechooser.c index be73b3d..21f67d9 100644 --- a/src/filechooser.c +++ b/src/filechooser.c @@ -69,7 +69,7 @@ static void okay(MwWidget handle, void* user, void* call) { destroy(handle->parent); } -static void msgbox_okay(MwWidget handle, void* user, void* call){ +static void msgbox_okay(MwWidget handle, void* user, void* call) { (void)user; (void)call; @@ -93,6 +93,22 @@ static void files_activate(MwWidget handle, void* user, void* call) { } } +static void nav_activate(MwWidget handle, void* user, void* call) { + int index = *(int*)call; + const char* e = MwListBoxGet(handle, index); + + (void)user; + + if(strcmp(e, "Home") == 0) { +#ifdef _WIN32 +#else + struct passwd* p = getpwuid(getuid()); + + scan(handle->parent, p->pw_dir); +#endif + } +} + static void addr_up_activate(MwWidget handle, void* user, void* call) { filechooser_t* fc = handle->parent->opaque; char* p = MwDirectoryJoin(fc->path, ".."); @@ -127,6 +143,7 @@ static void layout(MwWidget handle) { MwNleftPadding, 16, NULL); MwListBoxInsert(fc->nav, -1, fc->computer, "Home", NULL); + MwAddUserHandler(fc->nav, MwNactivateHandler, nav_activate, NULL); } else { MwVaApply(fc->nav, MwNx, wx,