Add Mute all Sounds menu XB
authorH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 9 May 2016 05:08:18 +0000 (07:08 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Mon, 9 May 2016 05:16:03 +0000 (07:16 +0200)
XBoard now also has a menu item to mute all sounds (except the Play
button in the Sounds dialog) at the topof the Options menu, like WinBoard.

dialogs.c
frontend.h
menus.c
usounds.c
xboard.texi

index 9b48704..64001c2 100644 (file)
--- a/dialogs.c
+++ b/dialogs.c
@@ -866,7 +866,9 @@ static void
 Test (int n)
 {
     GenericReadout(soundOptions, 1);
+    mute <<= 1; // temporarily enable
     if(soundFiles[values[2]]) PlaySoundFile(soundFiles[values[2]]);
+    mute >>= 1;
 }
 
 void
index 16d1f5b..8bdf558 100644 (file)
@@ -216,6 +216,7 @@ extern char *programName;
 extern int commentUp;
 extern char *firstChessProgramNames;
 extern char *icsTextMenuString;
+extern int mute;
 
 void GreyRevert P((Boolean grey));
 void EnableNamedMenuItem P((char *menuRef, int state));
diff --git a/menus.c b/menus.c
index 50968c1..fbc7893 100644 (file)
--- a/menus.c
+++ b/menus.c
@@ -403,6 +403,13 @@ EditMenuProc ()
 }
 
 void
+MuteProc ()
+{
+    mute = !mute;
+    MarkMenuItem("Options.Mute", mute);
+}
+
+void
 NothingProc ()
 {
     return;
@@ -726,6 +733,8 @@ MenuItem engineMenu[100] = {
 };
 
 MenuItem optionsMenu[] = {
+  {N_("Mute all Sounds"),         NULL,             "Mute",                MuteProc,         CHECK},
+  {"----",                        NULL,              NULL,                 NothingProc},
 #ifdef OPTIONSDIALOG
   {N_("General..."),              NULL,             "General",             OptionsProc},
 #endif
index 6432335..dce58e0 100644 (file)
--- a/usounds.c
+++ b/usounds.c
@@ -76,10 +76,10 @@ extern char *getenv();
 #include "common.h"
 #include "frontend.h"
 
-
 int
 PlaySoundFile (char *name)
 {
+  if(mute == 1) return 1;
   if (*name == NULLCHAR) {
     return 0;
   } else if (strcmp(name, "$") == 0) {
index 6187303..3b77b70 100644 (file)
@@ -1415,6 +1415,10 @@ The maximum number of displayed engine names is set by the
 @section Options Menu
 @cindex Menu, Options
 @cindex Options Menu
+@section Mute all Sounds
+@cindex Mute sounds, Menu Item
+Ticking this menu item toggles all sounds XBoard can make on or off,
+without losing their definitions.
 @section General Options
 @cindex General Options, Menu Item
 The following items to set option values appear in the dialog