diff --git a/include/Mcde/Sound.h b/include/Mcde/Sound.h
index 77cc7f43..41aa286b 100644
--- a/include/Mcde/Sound.h
+++ b/include/Mcde/Sound.h
@@ -21,6 +21,12 @@ const char * McdeSoundFile(const char *event);
/* the theme directory (for the daemon's relative file names) */
const char * McdeSoundThemeDir(void);
+/* load another theme directory (the server's side of a theme change) */
+int McdeSoundLoadTheme(const char *dir);
+
+/* ask the running server to load DIR; returns 0 when it took it */
+int McdeSoundSetTheme(Display *dpy, const char *dir);
+
/* how many events the theme names, and their names (for a settings list) */
int McdeSoundCount(void);
const char * McdeSoundEventName(int i);
diff --git a/lib/McdeSound/Sound.c b/lib/McdeSound/Sound.c
index 6f759ede..906843e7 100644
--- a/lib/McdeSound/Sound.c
+++ b/lib/McdeSound/Sound.c
@@ -83,6 +83,42 @@ ReadTheme(const char *path)
return nev > 0 ? 0 : -1;
}
+int
+McdeSoundLoadTheme(const char *dir)
+{
+ char path[768];
+
+ if (dir == NULL || dir[0] == '\0')
+ return -1;
+ snprintf(themeDir, sizeof themeDir, "%s", dir);
+ snprintf(path, sizeof path, "%s/theme.ss", themeDir);
+ nev = 0;
+ return ReadTheme(path);
+}
+
+int
+McdeSoundSetTheme(Display *dpy, const char *dir)
+{
+ Atom sel = XInternAtom(dpy, "_MCDE_SOUND_SERVER", False);
+ Atom prop = XInternAtom(dpy, "_MCDE_SOUND_THEME", False);
+ Atom msg = XInternAtom(dpy, "_MCDE_SOUND_RELOAD", False);
+ Window owner = XGetSelectionOwner(dpy, sel);
+ XEvent ev;
+
+ if (owner == None)
+ return 1;
+ XChangeProperty(dpy, owner, prop, XA_STRING, 8, PropModeReplace,
+ (const unsigned char *) dir, (int) strlen(dir));
+ memset(&ev, 0, sizeof ev);
+ ev.xclient.type = ClientMessage;
+ ev.xclient.window = owner;
+ ev.xclient.message_type = msg;
+ ev.xclient.format = 8;
+ XSendEvent(dpy, owner, False, NoEventMask, &ev);
+ XFlush(dpy);
+ return 0;
+}
+
int
McdeSoundInit(void)
{
diff --git a/programs/dtsystemsettings/main.c b/programs/dtsystemsettings/main.c
index e9e7fcb8..f7e1f2a3 100644
--- a/programs/dtsystemsettings/main.c
+++ b/programs/dtsystemsettings/main.c
@@ -40,6 +40,9 @@
#include
#include
+#include
+#include
+
#include
#include "panes.h"
@@ -257,6 +260,52 @@ SoundPreview(Widget w, XtPointer data, XtPointer call)
(void) McdeSoundEvent(XtDisplay(w), (const char *) data);
}
+static void
+SoundTheme(Widget w, XtPointer data, XtPointer call)
+{
+ (void) call;
+ (void) McdeSoundSetTheme(XtDisplay(w), (const char *) data);
+}
+
+/* the themes are directories next to the current one */
+static void
+MakeThemes(Widget box)
+{
+ char root[512], path[768], *slash;
+ DIR *d;
+ struct dirent *e;
+ Widget row;
+
+ (void) McdeSoundInit();
+ snprintf(root, sizeof root, "%s", McdeSoundThemeDir());
+ if ((slash = strrchr(root, '/')) == NULL)
+ return;
+ *slash = '\0';
+ if ((d = opendir(root)) == NULL)
+ return;
+ XtVaCreateManagedWidget("themeLabel", xmLabelWidgetClass, box,
+ XmNlabelString, XmStringCreateLocalized("Sound theme:"), NULL);
+ row = XtVaCreateManagedWidget("themes", xmRowColumnWidgetClass, box,
+ XmNorientation, XmHORIZONTAL, XmNspacing, 4, NULL);
+ while ((e = readdir(d)) != NULL) {
+ struct stat st;
+ Widget b;
+ char *dir;
+
+ if (e->d_name[0] == '.')
+ continue;
+ snprintf(path, sizeof path, "%s/%s", root, e->d_name);
+ if (stat(path, &st) != 0 || !S_ISDIR(st.st_mode))
+ continue;
+ b = XtVaCreateManagedWidget(e->d_name, xmPushButtonWidgetClass,
+ row, NULL);
+ dir = strdup(path);
+ XtAddCallback(b, XmNactivateCallback, SoundTheme,
+ (XtPointer) dir);
+ }
+ closedir(d);
+}
+
static Widget
MakeSound(Widget parent)
{
@@ -294,6 +343,7 @@ MakeSound(Widget parent)
(XtPointer) ev[i]);
}
}
+ MakeThemes(box);
SoundRead();
return box;
}
diff --git a/programs/mcdesoundd/Makefile.am b/programs/mcdesoundd/Makefile.am
index 1ef0cd94..78ec5f70 100644
--- a/programs/mcdesoundd/Makefile.am
+++ b/programs/mcdesoundd/Makefile.am
@@ -24,3 +24,27 @@ sounds_DATA = theme.ss \
sounds/iconify.wav sounds/deiconify.wav sounds/new_mail.wav \
sounds/print_files.wav sounds/search_hit.wav sounds/search_miss.wav \
sounds/clock_chime_hour.wav
+
+# the second theme, for the theme choice in the settings
+basedir = $(CDE_INSTALLATION_TOP)/share/sounds/themes/Base
+base_DATA = themes/Base/theme.ss \
+ themes/Base/launch.wav \
+ themes/Base/start.wav \
+ themes/Base/end.wav \
+ themes/Base/error.wav \
+ themes/Base/warning.wav \
+ themes/Base/beep.wav \
+ themes/Base/open_folder.wav \
+ themes/Base/drop_move.wav \
+ themes/Base/drop_copy.wav \
+ themes/Base/remove.wav \
+ themes/Base/remove_to_dumpster.wav \
+ themes/Base/desk_switch.wav \
+ themes/Base/iconify.wav \
+ themes/Base/deiconify.wav \
+ themes/Base/new_mail.wav \
+ themes/Base/print_files.wav \
+ themes/Base/search_hit.wav \
+ themes/Base/search_miss.wav \
+ themes/Base/clock_chime_hour.wav \
+ themes/Base/terminal_bell.wav
diff --git a/programs/mcdesoundd/mcdesoundd.c b/programs/mcdesoundd/mcdesoundd.c
index 4e0bfc33..1571ce58 100644
--- a/programs/mcdesoundd/mcdesoundd.c
+++ b/programs/mcdesoundd/mcdesoundd.c
@@ -76,15 +76,40 @@ PlayEvent(const char *event)
McdeSoundPlay(dpy, path) == 0 ? "player" : "bell");
}
+static void
+ReloadTheme(void)
+{
+ Atom prop = XInternAtom(dpy, "_MCDE_SOUND_THEME", False);
+ Atom type;
+ int format;
+ unsigned long n, after;
+ unsigned char *data = NULL;
+
+ if (XGetWindowProperty(dpy, service, prop, 0, 1024, False,
+ AnyPropertyType, &type, &format, &n, &after, &data) == Success &&
+ data != NULL && n > 0) {
+ if (McdeSoundLoadTheme((char *) data) == 0)
+ fprintf(stderr, "mcdesoundd: theme now %s\n",
+ McdeSoundThemeDir());
+ else
+ fprintf(stderr, "mcdesoundd: cannot read theme %s\n",
+ (char *) data);
+ XFree(data);
+ }
+}
+
static void
Message(Widget w, XtPointer data, XEvent *ev, Boolean *keep)
{
(void) w; (void) data; (void) keep;
- if (ev->type == ClientMessage &&
- ev->xclient.message_type ==
- XInternAtom(dpy, "_MCDE_SOUND_EVENT", False) &&
- ev->xclient.format == 8)
+ if (ev->type != ClientMessage || ev->xclient.format != 8)
+ return;
+ if (ev->xclient.message_type ==
+ XInternAtom(dpy, "_MCDE_SOUND_EVENT", False))
PlayEvent(ev->xclient.data.b);
+ else if (ev->xclient.message_type ==
+ XInternAtom(dpy, "_MCDE_SOUND_RELOAD", False))
+ ReloadTheme();
}
int
@@ -130,6 +155,18 @@ main(int argc, char **argv)
ok ? "PASS" : "FAIL", McdeSoundThemeDir());
return ok ? 0 : 1;
}
+ if (strcmp(argv[i], "-set-theme") == 0 && i + 1 < argc) {
+ if ((dpy = XOpenDisplay(NULL)) == NULL)
+ return 2;
+ if (McdeSoundSetTheme(dpy, argv[i + 1]) != 0) {
+ fprintf(stderr,
+ "mcdesoundd: no server for the theme\n");
+ return 1;
+ }
+ fprintf(stderr, "mcdesoundd: theme %s sent\n",
+ argv[i + 1]);
+ return 0;
+ }
if (strcmp(argv[i], "-event") == 0 && i + 1 < argc) {
if ((dpy = XOpenDisplay(NULL)) == NULL)
return 2;
diff --git a/programs/mcdesoundd/themes/Base/beep.wav b/programs/mcdesoundd/themes/Base/beep.wav
new file mode 100644
index 00000000..e7115e0a
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/beep.wav differ
diff --git a/programs/mcdesoundd/themes/Base/clock_chime_hour.wav b/programs/mcdesoundd/themes/Base/clock_chime_hour.wav
new file mode 100644
index 00000000..29143da9
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/clock_chime_hour.wav differ
diff --git a/programs/mcdesoundd/themes/Base/deiconify.wav b/programs/mcdesoundd/themes/Base/deiconify.wav
new file mode 100644
index 00000000..40b19407
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/deiconify.wav differ
diff --git a/programs/mcdesoundd/themes/Base/desk_switch.wav b/programs/mcdesoundd/themes/Base/desk_switch.wav
new file mode 100644
index 00000000..bad3ad3e
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/desk_switch.wav differ
diff --git a/programs/mcdesoundd/themes/Base/drop_copy.wav b/programs/mcdesoundd/themes/Base/drop_copy.wav
new file mode 100644
index 00000000..3e4b029b
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/drop_copy.wav differ
diff --git a/programs/mcdesoundd/themes/Base/drop_move.wav b/programs/mcdesoundd/themes/Base/drop_move.wav
new file mode 100644
index 00000000..51225d39
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/drop_move.wav differ
diff --git a/programs/mcdesoundd/themes/Base/end.wav b/programs/mcdesoundd/themes/Base/end.wav
new file mode 100644
index 00000000..6ad08bf1
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/end.wav differ
diff --git a/programs/mcdesoundd/themes/Base/error.wav b/programs/mcdesoundd/themes/Base/error.wav
new file mode 100644
index 00000000..d7f0cae4
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/error.wav differ
diff --git a/programs/mcdesoundd/themes/Base/iconify.wav b/programs/mcdesoundd/themes/Base/iconify.wav
new file mode 100644
index 00000000..8e203d1f
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/iconify.wav differ
diff --git a/programs/mcdesoundd/themes/Base/launch.wav b/programs/mcdesoundd/themes/Base/launch.wav
new file mode 100644
index 00000000..6b8a36c1
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/launch.wav differ
diff --git a/programs/mcdesoundd/themes/Base/new_mail.wav b/programs/mcdesoundd/themes/Base/new_mail.wav
new file mode 100644
index 00000000..67d9e24b
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/new_mail.wav differ
diff --git a/programs/mcdesoundd/themes/Base/open_folder.wav b/programs/mcdesoundd/themes/Base/open_folder.wav
new file mode 100644
index 00000000..30a5be77
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/open_folder.wav differ
diff --git a/programs/mcdesoundd/themes/Base/print_files.wav b/programs/mcdesoundd/themes/Base/print_files.wav
new file mode 100644
index 00000000..07e6ca84
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/print_files.wav differ
diff --git a/programs/mcdesoundd/themes/Base/remove.wav b/programs/mcdesoundd/themes/Base/remove.wav
new file mode 100644
index 00000000..89bb0954
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/remove.wav differ
diff --git a/programs/mcdesoundd/themes/Base/remove_to_dumpster.wav b/programs/mcdesoundd/themes/Base/remove_to_dumpster.wav
new file mode 100644
index 00000000..97a88bf4
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/remove_to_dumpster.wav differ
diff --git a/programs/mcdesoundd/themes/Base/search_hit.wav b/programs/mcdesoundd/themes/Base/search_hit.wav
new file mode 100644
index 00000000..ca5532e2
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/search_hit.wav differ
diff --git a/programs/mcdesoundd/themes/Base/search_miss.wav b/programs/mcdesoundd/themes/Base/search_miss.wav
new file mode 100644
index 00000000..5523869f
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/search_miss.wav differ
diff --git a/programs/mcdesoundd/themes/Base/start.wav b/programs/mcdesoundd/themes/Base/start.wav
new file mode 100644
index 00000000..870108ea
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/start.wav differ
diff --git a/programs/mcdesoundd/themes/Base/terminal_bell.wav b/programs/mcdesoundd/themes/Base/terminal_bell.wav
new file mode 100644
index 00000000..634f0e14
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/terminal_bell.wav differ
diff --git a/programs/mcdesoundd/themes/Base/theme.ss b/programs/mcdesoundd/themes/Base/theme.ss
new file mode 100644
index 00000000..086d1284
--- /dev/null
+++ b/programs/mcdesoundd/themes/Base/theme.ss
@@ -0,0 +1,42 @@
+! MCDE sound theme Base -- the lower voice of Camouflage
+
+*Launch.soundfile: launch.wav
+*Launch.label: Launch
+*Start.soundfile: start.wav
+*Start.label: Start
+*End.soundfile: end.wav
+*End.label: End
+*Error.soundfile: error.wav
+*Error.label: Error
+*Warning.soundfile: warning.wav
+*Warning.label: Warning
+*Beep.soundfile: beep.wav
+*Beep.label: Beep
+*OpenFolder.soundfile: open_folder.wav
+*OpenFolder.label: OpenFolder
+*DropMove.soundfile: drop_move.wav
+*DropMove.label: DropMove
+*DropCopy.soundfile: drop_copy.wav
+*DropCopy.label: DropCopy
+*Remove.soundfile: remove.wav
+*Remove.label: Remove
+*RemoveToDumpster.soundfile: remove_to_dumpster.wav
+*RemoveToDumpster.label: RemoveToDumpster
+*DeskSwitch.soundfile: desk_switch.wav
+*DeskSwitch.label: DeskSwitch
+*Iconify.soundfile: iconify.wav
+*Iconify.label: Iconify
+*Deiconify.soundfile: deiconify.wav
+*Deiconify.label: Deiconify
+*NewMail.soundfile: new_mail.wav
+*NewMail.label: NewMail
+*PrintFiles.soundfile: print_files.wav
+*PrintFiles.label: PrintFiles
+*SearchHit.soundfile: search_hit.wav
+*SearchHit.label: SearchHit
+*SearchMiss.soundfile: search_miss.wav
+*SearchMiss.label: SearchMiss
+*ClockChimeHour.soundfile: clock_chime_hour.wav
+*ClockChimeHour.label: ClockChimeHour
+*TerminalBell.soundfile: terminal_bell.wav
+*TerminalBell.label: TerminalBell
diff --git a/programs/mcdesoundd/themes/Base/warning.wav b/programs/mcdesoundd/themes/Base/warning.wav
new file mode 100644
index 00000000..1e49d7f1
Binary files /dev/null and b/programs/mcdesoundd/themes/Base/warning.wav differ