[four-in-a-row] Move sound toggle in hamburger menu.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [four-in-a-row] Move sound toggle in hamburger menu.
- Date: Fri, 27 Sep 2019 22:18:16 +0000 (UTC)
commit 3451b20be61012bf30d574f1121814098ef2c6d2
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Aug 18 23:06:27 2019 +0200
Move sound toggle in hamburger menu.
src/four-in-a-row.vala | 42 +++++++++++++++++++++++++++---------------
src/prefs-box.vala | 7 -------
src/prefs.vala | 7 -------
3 files changed, 27 insertions(+), 29 deletions(-)
---
diff --git a/src/four-in-a-row.vala b/src/four-in-a-row.vala
index 87e4c57..5f8ee31 100644
--- a/src/four-in-a-row.vala
+++ b/src/four-in-a-row.vala
@@ -159,6 +159,8 @@ private class FourInARow : Gtk.Application {
}
private inline void add_actions() {
+ add_action (Prefs.instance.settings.create_action ("sound"));
+
new_game_action = new SimpleAction("new-game", null);
new_game_action.activate.connect(this.on_game_new);
add_action(new_game_action);
@@ -709,19 +711,27 @@ private class FourInARow : Gtk.Application {
add_actions();
- menu_button = builder.get_object("menu_button") as Gtk.MenuButton;
+ menu_button = builder.get_object ("menu_button") as Gtk.MenuButton;
+ app_menu = new GLib.Menu ();
+
+ section = new GLib.Menu ();
+ section.append (_("Sound"), "app.sound");
+ section.freeze ();
+ app_menu.append_section (null, section);
- app_menu = new GLib.Menu();
- section = new GLib.Menu();
- app_menu.append_section(null, section);
- section.append(_("_Scores"), "app.scores");
- section = new GLib.Menu();
- app_menu.append_section(null, section);
- section.append(_("_Preferences"), "app.preferences");
- section.append(_("_Help"), "app.help");
- section.append(_("_About Four-in-a-row"), "app.about");
+ section = new GLib.Menu ();
+ section.append (_("_Scores"), "app.scores");
+ section.freeze ();
+ app_menu.append_section (null, section);
- menu_button.menu_model = app_menu;
+ section = new GLib.Menu ();
+ section.append (_("_Preferences"), "app.preferences");
+ section.append (_("_Help"), "app.help");
+ section.append (_("_About Four-in-a-row"), "app.about");
+ section.freeze ();
+ app_menu.append_section (null, section);
+
+ menu_button.set_menu_model (app_menu);
frame = builder.get_object("frame") as Gtk.AspectFrame;
@@ -801,12 +811,14 @@ private class FourInARow : Gtk.Application {
}
}
- private void play_sound(SoundID id) {
- if (Prefs.instance.do_sound) {
+ private void play_sound (SoundID id)
+ {
+ if (Prefs.instance.settings.get_boolean ("sound"))
+ {
if (sound_context_state == SoundContextState.INITIAL)
- init_sound();
+ init_sound ();
if (sound_context_state == SoundContextState.WORKING)
- do_play_sound(id, sound_context);
+ do_play_sound (id, sound_context);
}
}
diff --git a/src/prefs-box.vala b/src/prefs-box.vala
index 914a5cb..e12b3a5 100644
--- a/src/prefs-box.vala
+++ b/src/prefs-box.vala
@@ -30,7 +30,6 @@ private class PrefsBox : Dialog {
Notebook notebook;
ComboBox combobox;
ComboBoxText combobox_theme;
- ToggleButton checkbutton_sound;
Grid grid;
GamesControlsList controls_list;
@@ -105,9 +104,6 @@ private class PrefsBox : Dialog {
label.set_mnemonic_widget(combobox_theme);
grid.attach(combobox_theme, 1, 1, 1, 1);
- checkbutton_sound = new CheckButton.with_mnemonic(_("E_nable sounds"));
- grid.attach(checkbutton_sound, 0, 2, 2, 1);
-
/* keyboard tab */
label = new Label.with_mnemonic(_("Keyboard Controls"));
@@ -120,13 +116,10 @@ private class PrefsBox : Dialog {
/* fill in initial values */
combobox_theme.set_active(Prefs.instance.theme_id);
- checkbutton_sound.set_active(Prefs.instance.do_sound);
/* connect signals */
combobox_theme.changed.connect(on_select_theme);
- checkbutton_sound.toggled.connect(Prefs.instance.on_toggle_sound);
Prefs.instance.theme_changed.connect((theme_id) => combobox_theme.set_active(theme_id));
- Prefs.instance.notify["do_sound"].connect(() =>
checkbutton_sound.set_active(Prefs.instance.do_sound));
}
protected override bool delete_event(Gdk.EventAny event) { // TODO use hide_on_delete (Gtk3) or
hide-on-close (Gtk4) 2/2
diff --git a/src/prefs.vala b/src/prefs.vala
index fb17e39..b0087a5 100644
--- a/src/prefs.vala
+++ b/src/prefs.vala
@@ -22,8 +22,6 @@
private class Prefs : Object {
private const int DEFAULT_THEME_ID = 0;
- [CCode (notify = false)] internal bool do_sound{ internal get; internal set;}
-
private int _theme_id;
[CCode (notify = true)] internal int theme_id {
get{
@@ -52,7 +50,6 @@ private class Prefs : Object {
theme_id = settings.get_int("theme-id");
settings.changed ["theme-id"].connect(theme_id_changed_cb);
- settings.bind("sound", this, "do_sound", SettingsBindFlags.DEFAULT);
settings.bind("theme-id", this, "theme-id", SettingsBindFlags.DEFAULT);
settings.bind("key-drop", this, "keypress_drop", SettingsBindFlags.DEFAULT);
settings.bind("key-right", this, "keypress_right", SettingsBindFlags.DEFAULT);
@@ -93,10 +90,6 @@ private class Prefs : Object {
return 2;
}
- internal inline void on_toggle_sound(Gtk.ToggleButton t) {
- do_sound = t.get_active();
- }
-
private static Level sane_player_level(Level val) {
if (val < Level.HUMAN)
return Level.HUMAN;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]