From 8cb209058c20df8af6fe0dfb8e5e5996053af45d Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Thu, 27 Nov 2025 02:30:24 +0900 Subject: [PATCH] make add directory work on mauplay --- mauplay/ui.c | 16 ++++++++++++++++ mbiff/main.c | 29 +++++++++++++++++++++++------ mbiff/mbiff.h | 2 ++ 3 files changed, 41 insertions(+), 6 deletions(-) diff --git a/mauplay/ui.c b/mauplay/ui.c index d00cead..7dadbce 100644 --- a/mauplay/ui.c +++ b/mauplay/ui.c @@ -449,6 +449,19 @@ static void file_fc_chosen(MwWidget handle, void* user, void* client) { db_scan(); } +static void file_dc_scan(const char* path, int dir, int symlink, void* uesr) { + if(dir) { + MDEDirectoryScan(path, file_dc_scan, NULL); + } else { + db_add(path); + } +} + +static void file_dc_chosen(MwWidget handle, void* user, void* client) { + MDEDirectoryScan(client, file_dc_scan, NULL); + db_scan(); +} + static void playlist_fc_chosen(MwWidget handle, void* user, void* client) { playlist_add(client); } @@ -457,6 +470,9 @@ static void menu_menu(MwWidget handle, void* user, void* client) { if(client == file_add_file) { MwWidget fc = MwFileChooser(window, "Choose a file to add"); MwAddUserHandler(fc, MwNfileChosenHandler, file_fc_chosen, NULL); + } else if(client == file_add_directory) { + MwWidget dc = MwDirectoryChooser(window, "Choose a directory to add"); + MwAddUserHandler(dc, MwNdirectoryChosenHandler, file_dc_chosen, NULL); } else if(client == file_add_playlist) { MwWidget fc = MwFileChooser(window, "Choose a playlist to add"); MwAddUserHandler(fc, MwNfileChosenHandler, playlist_fc_chosen, NULL); diff --git a/mbiff/main.c b/mbiff/main.c index eb6241d..ded1368 100644 --- a/mbiff/main.c +++ b/mbiff/main.c @@ -3,13 +3,14 @@ #include "mailempty.xpm" #include "mailfull.xpm" -MwWidget window, image, mail; -MwLLPixmap empty, full; -static int waiting = 0; +MwWidget window, menu, image, mail; +MwLLPixmap empty, full; +static int waiting = 0; +static void* help_about; static void resize(MwWidget handle, void* user, void* client) { int w = MwGetInteger(handle, MwNwidth); - int h = MwGetInteger(handle, MwNheight); + int h = MwGetInteger(handle, MwNheight) - MwGetInteger(menu, MwNheight); int iw = w < h ? w : h; (void)user; @@ -17,7 +18,7 @@ static void resize(MwWidget handle, void* user, void* client) { MwVaApply(image, MwNx, (w - iw) / 2, - MwNy, (h - iw) / 2, + MwNy, MwGetInteger(menu, MwNheight) + (h - iw) / 2, MwNwidth, iw, MwNheight, iw, NULL); @@ -46,7 +47,15 @@ static void mouseUp(MwWidget handle, void* user, void* client) { NULL); } +static void menu_menu(MwWidget handle, void* user, void* client) { + if(client == help_about) { + MDEAboutDialog(window, "mbiff", VERSION, mail); + } +} + int main() { + void* m; + init_mail(); MwLibraryInit(); @@ -55,6 +64,11 @@ int main() { MwNtitle, "mbiff", NULL); + menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0); + + m = MwMenuAdd(menu, NULL, "?Help"); + help_about = MwMenuAdd(menu, m, "About"); + empty = MwLoadImage(window, ICON128DIR "/mailempty.png"); full = MwLoadImage(window, ICON128DIR "/mailfull.png"); mail = MwLoadImage(window, ICON128DIR "/mail.png"); @@ -64,10 +78,13 @@ int main() { MwVaApply(window, MwNiconPixmap, mail, NULL); - image = MwVaCreateWidget(MwImageClass, "image", window, 0, 0, 128, 128, + image = MwVaCreateWidget(MwImageClass, "image", window, 0, 0, 0, 0, MwNpixmap, empty, NULL); + resize(window, NULL, NULL); + + MwAddUserHandler(menu, MwNmenuHandler, menu_menu, NULL); MwAddUserHandler(image, MwNmouseUpHandler, mouseUp, NULL); MwAddUserHandler(window, MwNtickHandler, tick, NULL); MwAddUserHandler(window, MwNresizeHandler, resize, NULL); diff --git a/mbiff/mbiff.h b/mbiff/mbiff.h index 5059349..8d78087 100644 --- a/mbiff/mbiff.h +++ b/mbiff/mbiff.h @@ -1,6 +1,8 @@ #ifndef __MBIFF_H__ #define __MBIFF_H__ +#define VERSION "0.0.0" + #include "config.h" /* Milsko */