From 668d1894364d6d333eea69ea354a492a6e048459 Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Thu, 7 Aug 2025 20:55:37 +0200 Subject: [PATCH] add arg parser + args for playback control --- application/main.c | 71 ++++++++++++++++++++++++++++++++++++++---- application/playlist.c | 38 ++++++++++++++++++++++ application/playlist.h | 10 ++++++ 3 files changed, 113 insertions(+), 6 deletions(-) diff --git a/application/main.c b/application/main.c index d49dc72..458fed0 100644 --- a/application/main.c +++ b/application/main.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include "window.h" #include "main.h" +#include "playlist.h" #include "settings.h" #include @@ -104,17 +106,70 @@ int main(int argc, char** argv) { display = XtOpenDisplay(app, NULL, APP_NAME, APP_CLASS, NULL, 0, &argc, argv); + PlaybackMode playback = PLAYBACK_STOP; + bool fullscreen = FALSE; + bool adjust_window_size = FALSE; + bool single_instance = FALSE; + + bool file_args = 0; if(argc > 1) { open_file_arg = cxArrayListCreateSimple(CX_STORE_POINTERS, argc-1); for(int i=1;iplaylist.tracks); } + +void PlayListSetMode(MainWindow *win, PlaybackMode mode) { + switch(mode) { + default: break; + case PLAYBACK_REPEAT: { + win->playlist.repeatTrack = TRUE; + win->playlist.repeatList = FALSE; + win->playlist.random = FALSE; + win->playlist.autoplayFolder = FALSE; + break; + } + case PLAYBACK_REPEAT_LIST: { + win->playlist.repeatTrack = TRUE; + win->playlist.repeatList = TRUE; + win->playlist.random = FALSE; + win->playlist.autoplayFolder = FALSE; + break; + } + case PLAYBACK_RANDOM: { + win->playlist.repeatTrack = TRUE; + win->playlist.repeatList = FALSE; + win->playlist.random = TRUE; + win->playlist.autoplayFolder = FALSE; + break; + } + case PLAYBACK_AUTOPLAY: { + win->playlist.repeatTrack = FALSE; + win->playlist.repeatList = FALSE; + win->playlist.random = FALSE; + win->playlist.autoplayFolder = TRUE; + break; + } + } + XtVaSetValues(win->playRepeatTrackButton, XmNset, win->playlist.repeatTrack, NULL); + XtVaSetValues(win->playRepeatListButton, XmNset, win->playlist.repeatList, NULL); + XtVaSetValues(win->playAutoPlayButton, XmNset, win->playlist.random, NULL); + XtVaSetValues(win->playRandom, XmNset, win->playlist.autoplayFolder, NULL); +} diff --git a/application/playlist.h b/application/playlist.h index 26df47b..553c2f8 100644 --- a/application/playlist.h +++ b/application/playlist.h @@ -29,6 +29,14 @@ extern "C" { #endif +typedef enum PlaybackMode { + PLAYBACK_STOP = 0, + PLAYBACK_REPEAT, + PLAYBACK_REPEAT_LIST, + PLAYBACK_RANDOM, + PLAYBACK_AUTOPLAY +} PlaybackMode; + void PlayListInit(MainWindow *win); void PlayListAddFile(MainWindow *win, const char *file); @@ -39,6 +47,8 @@ void PlayListPlayTrack(MainWindow *win, int i); void PlayListClear(MainWindow *win); +void PlayListSetMode(MainWindow *win, PlaybackMode mode); + #ifdef __cplusplus } #endif -- 2.47.3