[four-in-a-row] Add --mute and --unmute command-line support.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [four-in-a-row] Add --mute and --unmute command-line support.
- Date: Fri, 27 Dec 2019 16:10:42 +0000 (UTC)
commit 97018cac92a02c91b4208e85144626919dc1aee9
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Dec 26 22:37:42 2019 +0100
Add --mute and --unmute command-line support.
src/four-in-a-row.vala | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/src/four-in-a-row.vala b/src/four-in-a-row.vala
index c16ad2d..f90e0d6 100644
--- a/src/four-in-a-row.vala
+++ b/src/four-in-a-row.vala
@@ -89,10 +89,18 @@ private class FourInARow : Gtk.Application
[CCode (notify = false)] internal bool sound_on { private get; internal set; }
private uint8 theme_id;
+ private static bool? sound = null;
+
private const OptionEntry [] option_entries =
{
/* Translators: command-line option description, see 'four-in-a-row --help' */
- { "version", 'v', OptionFlags.NONE, OptionArg.NONE, null, N_("Print release version and exit"), null
},
+ { "mute", 0, OptionFlags.NONE, OptionArg.NONE, null, N_("Turn off the sound"),
null },
+
+ /* Translators: command-line option description, see 'four-in-a-row --help' */
+ { "unmute", 0, OptionFlags.NONE, OptionArg.NONE, null, N_("Turn on the sound"),
null },
+
+ /* Translators: command-line option description, see 'four-in-a-row --help' */
+ { "version", 'v', OptionFlags.NONE, OptionArg.NONE, null, N_("Print release version
and exit"), null },
{}
};
@@ -141,6 +149,11 @@ private class FourInARow : Gtk.Application
return Posix.EXIT_SUCCESS;
}
+ if (options.contains ("mute"))
+ sound = false;
+ else if (options.contains ("unmute"))
+ sound = true;
+
/* Activate */
return -1;
}
@@ -149,6 +162,12 @@ private class FourInARow : Gtk.Application
{
base.startup ();
+ if (sound != null)
+ settings.set_boolean ("sound", (!) sound);
+
+ if (settings.get_boolean ("sound"))
+ init_sound ();
+
settings.bind ("key-drop", this, "keypress-drop", SettingsBindFlags.GET |
SettingsBindFlags.NO_SENSITIVITY);
settings.bind ("key-right", this, "keypress-right", SettingsBindFlags.GET |
SettingsBindFlags.NO_SENSITIVITY);
settings.bind ("key-left", this, "keypress-left", SettingsBindFlags.GET |
SettingsBindFlags.NO_SENSITIVITY);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]