ref: 9e14ceab625f7ee4f7153bd675d9ac92f0da5e9c
parent: ceb3e491892eb8facd2fac1ea7b09752fffc40f4
author: Simon Howard <fraggle@soulsphere.org>
date: Sun Oct 21 15:44:01 EDT 2018
setup: Add window action to open music pack dir. This replaces the widget that controls the music pack path with a window action button that just opens the configured music pack path. The path is now automatically created and populated with an explanatory README file that should explain the purpose to users. Another major step in implementing #1051.
--- a/src/setup/sound.c
+++ b/src/setup/sound.c
@@ -113,9 +113,25 @@
return result;
}
+static void OpenMusicPackDir(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused))
+{
+ char *cmd;
+
+#if defined(__MACOSX__)
+ cmd = M_StringJoin("open \"", music_pack_path, "\"", NULL);
+#elif defined(_WIN32)
+ cmd = M_StringJoin("start \"", music_pack_path, "\"", NULL);
+#else
+ cmd = M_StringJoin("xdg-open \"", music_pack_path, "\"", NULL);
+#endif
+ system(cmd);
+ free(cmd);
+}
+
void ConfigSound(TXT_UNCAST_ARG(widget), void *user_data)
{
txt_window_t *window;
+ txt_window_action_t *music_action;
// Build the window
@@ -126,6 +142,12 @@
TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_TOP,
TXT_SCREEN_W / 2, 3);
+ music_action = TXT_NewWindowAction('m', "Music Packs");
+ TXT_SetWindowAction(window, TXT_HORIZ_CENTER,
+ TXT_NewConditional(&snd_musicdevice, SNDDEVICE_GENMIDI,
+ music_action));
+ TXT_SignalConnect(music_action, "pressed", OpenMusicPackDir, NULL);
+
TXT_AddWidgets(window,
TXT_NewSeparator("Sound effects"),
TXT_NewRadioButton("Disabled", &snd_sfxdevice, SNDDEVICE_NONE),
@@ -181,13 +203,6 @@
TXT_NewFileSelector(&timidity_cfg_path, 34,
"Select Timidity config file",
cfg_extension),
- TXT_NewStrut(4, 0),
- TXT_NewLabel("Digital music pack directory: "),
- TXT_NewStrut(4, 0),
- TXT_NewFileSelector(&music_pack_path, 34,
- "Select directory containing music pack "
- "config files",
- TXT_DIRECTORY),
NULL)),
NULL);
}