[five-or-more/arnaudb/kill-preferences-dialog: 5/10] Remove Preferences dialog.



commit 070eb60f679ba2785725eabc1b769f1a238108eb
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Thu May 7 23:32:39 2020 +0200

    Remove Preferences dialog.

 data/five-or-more-preferences.ui          | 134 ------------------------------
 data/five-or-more.ui                      |  43 ++++++++--
 data/meson.build                          |   7 --
 data/org.gnome.five-or-more.gresource.xml |   1 -
 po/POTFILES.in                            |   2 -
 po/POTFILES.skip                          |   1 -
 src/main.vala                             |  21 -----
 src/meson.build                           |   1 -
 src/preferences-dialog.vala               |  81 ------------------
 src/window.vala                           |  41 ++++++++-
 10 files changed, 76 insertions(+), 256 deletions(-)
---
diff --git a/data/five-or-more.ui b/data/five-or-more.ui
index 8482e36..ba74da7 100644
--- a/data/five-or-more.ui
+++ b/data/five-or-more.ui
@@ -46,13 +46,46 @@
         <attribute name="label" translatable="yes">S_cores</attribute>
         <attribute name="action">win.scores</attribute>
       </item>
+      <submenu>
+        <!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt); 
displays allows to change the theme -->
+        <attribute name="label" translatable="yes">A_ppearance</attribute>
+        <section>
+          <item>
+            <!-- Translators: entry of the Appearance submenu of the hamburger menu; set theme to "balls"; 
other possible themes are "shapes" and "tango" -->
+            <attribute name="label" translatable="yes">balls</attribute>
+            <attribute name="action">win.change-theme</attribute>
+            <attribute name="target">balls.svg</attribute>
+          </item>
+          <item>
+            <!-- Translators: entry of the Appearance submenu of the hamburger menu; set theme to "shapes"; 
other possible themes are "balls" and "tango" -->
+            <attribute name="label" translatable="yes">shapes</attribute>
+            <attribute name="action">win.change-theme</attribute>
+            <attribute name="target">shapes.svg</attribute>
+          </item>
+          <item>
+            <!-- Translators: entry of the Appearance submenu of the hamburger menu; set theme to "tango"; 
other possible themes are "balls" and "shapes" -->
+            <attribute name="label" translatable="yes">tango</attribute>
+            <attribute name="action">win.change-theme</attribute>
+            <attribute name="target">tango.svg</attribute>
+          </item>
+        </section>
+        <section>
+          <!-- Translators: title of a section in the Appearance submenu of the hamburger menu; containes 
"Select color" and "Reset color" -->
+          <attribute name="label" translatable="yes">Background</attribute>
+          <item>
+            <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that 
appears when pressing Alt); opens a dialog for choosing background color -->
+            <attribute name="label" translatable="yes">_Select color</attribute>
+            <attribute name="action">win.background</attribute>
+          </item>
+          <item>
+            <!-- Translators: entry of the Appearance submenu of the hamburger menu (with a mnemonic that 
appears when pressing Alt); resets background color -->
+            <attribute name="label" translatable="yes">_Default color</attribute>
+            <attribute name="action">win.reset-bg</attribute>
+          </item>
+        </section>
+      </submenu>
     </section>
     <section>
-      <item>
-        <!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt); 
opens the Preferences dialog -->
-        <attribute name="label" translatable="yes">_Preferences</attribute>
-        <attribute name="action">app.preferences</attribute>
-      </item>
       <item>
         <!-- Translators: entry of the hamburger menu (with a mnemonic that appears when pressing Alt); 
opens the help of the application -->
         <attribute name="label" translatable="yes">_Help</attribute>
diff --git a/data/meson.build b/data/meson.build
index 34bdd2b..96a4189 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -26,13 +26,6 @@ foreach file: ['balls.svg', 'shapes.svg', 'tango.svg']
   )
 endforeach
 
-# UI files
-foreach file: ['five-or-more.ui', 'five-or-more-preferences.ui']
-  install_data (file,
-    install_dir: join_paths (pkgdata_dir)
-  )
-endforeach
-
 # Icons
 foreach size: [ '16x16', '22x22', '24x24', '32x32', '48x48', '256x256', '512x512' ]
     install_data(join_paths('icons', 'hicolor', size, 'org.gnome.five-or-more.png'),
diff --git a/data/org.gnome.five-or-more.gresource.xml b/data/org.gnome.five-or-more.gresource.xml
index 4893213..3136fa7 100644
--- a/data/org.gnome.five-or-more.gresource.xml
+++ b/data/org.gnome.five-or-more.gresource.xml
@@ -2,6 +2,5 @@
 <gresources>
   <gresource prefix="/org/gnome/five-or-more/ui">
     <file preprocess="xml-stripblanks">five-or-more.ui</file>
-    <file preprocess="xml-stripblanks" alias="preferences-dialog.ui">five-or-more-preferences.ui</file>
   </gresource>
 </gresources>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c19c907..5d33a9c 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,11 +1,9 @@
 # List of source files containing translatable strings.
 # Please keep this file in alphabetical order.
-data/five-or-more-preferences.ui
 data/five-or-more.ui
 data/org.gnome.five-or-more.appdata.xml.in
 data/org.gnome.five-or-more.desktop.in
 data/org.gnome.five-or-more.gschema.xml
 src/game.vala
 src/main.vala
-src/preferences-dialog.vala
 src/window.vala
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 4c3a3bd..3a7a614 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,4 +1,3 @@
 src/game.c
 src/main.c
-src/preferences-dialog.c
 src/window.c
diff --git a/src/main.vala b/src/main.vala
index 7be3c3e..1e51331 100644
--- a/src/main.vala
+++ b/src/main.vala
@@ -30,11 +30,9 @@ private class FiveOrMoreApp: Gtk.Application
     private Settings settings;
 
     private GameWindow window;
-    private PreferencesDialog? preferences_dialog = null;
 
     private const GLib.ActionEntry action_entries[] =
     {
-        { "preferences",    preferences_cb  },
         { "help",           help_cb         },
         { "about",          about_cb        },
         { "quit",           quit            }
@@ -77,25 +75,6 @@ private class FiveOrMoreApp: Gtk.Application
         set_accels_for_action ("app.help",      {          "F1" });
     }
 
-    private void preferences_cb ()
-    {
-        if (preferences_dialog != null)
-        {
-            preferences_dialog.show ();
-            return;
-        }
-
-        preferences_dialog = new PreferencesDialog (settings);
-        preferences_dialog.set_transient_for (window);
-
-        preferences_dialog.response.connect (() => {
-            preferences_dialog.destroy ();
-            preferences_dialog = null;
-        });
-
-        preferences_dialog.show ();
-    }
-
     private void help_cb ()
     {
         try
diff --git a/src/meson.build b/src/meson.build
index 2e42ca0..b6d4900 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -8,7 +8,6 @@ five_or_more_sources = [
   'next-pieces-widget.vala',
   'piece.vala',
   'piece-generator.vala',
-  'preferences-dialog.vala',
   'theme-renderer.vala',
   'view.vala',
   'window.vala',
diff --git a/src/window.vala b/src/window.vala
index 1e51dab..9b93c34 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -54,9 +54,14 @@ private class GameWindow : ApplicationWindow
 
     private const GLib.ActionEntry win_actions [] =
     {
-        {"change-size", null,       "s", "'SMALL'", change_size },
-        {"new-game",    new_game    },
-        {"scores",      show_scores }
+        { "background",     change_background  },
+        { "reset-bg",       reset_background   },
+
+        { "change-size",    null,               "s", "'BOARD_SIZE_SMALL'",  change_size     },
+        { "change-theme",   null,               "s", "'balls.svg'",         change_theme    },
+
+        { "new-game",       new_game           },
+        { "scores",         show_scores        }
     };
 
     construct
@@ -166,6 +171,29 @@ private class GameWindow : ApplicationWindow
     * * actions
     \*/
 
+    private inline void change_background ()
+    {
+        string old_color_string = settings.get_string (FiveOrMoreApp.KEY_BACKGROUND_COLOR);
+        ColorChooserDialog dialog = new ColorChooserDialog (_("Background color"), this);
+        if (!dialog.rgba.parse (old_color_string))
+            return;
+        dialog.notify ["rgba"].connect ((dialog, param) => {
+                var color = ((ColorChooserDialog) dialog).get_rgba ();
+                if (!settings.set_string (FiveOrMoreApp.KEY_BACKGROUND_COLOR, color.to_string ()))
+                    warning ("Failed to set color: %s", color.to_string ());
+            });
+        var result = dialog.run ();
+        dialog.destroy ();
+        if (result == ResponseType.OK)
+            return;
+        settings.set_string (FiveOrMoreApp.KEY_BACKGROUND_COLOR, old_color_string);
+    }
+
+    private inline void reset_background ()
+    {
+        settings.reset (FiveOrMoreApp.KEY_BACKGROUND_COLOR);
+    }
+
     private inline void change_size (SimpleAction action, Variant? parameter)
     {
         int size;
@@ -179,6 +207,13 @@ private class GameWindow : ApplicationWindow
         settings.set_int (FiveOrMoreApp.KEY_SIZE, size);
     }
 
+    private inline void change_theme (SimpleAction action, Variant? parameter)
+        requires (parameter != null)
+    {
+        action.set_state (parameter);
+        settings.set_string (FiveOrMoreApp.KEY_THEME, ((!) parameter).get_string ());
+    }
+
     private inline void new_game (/* SimpleAction action, Variant? parameter */)
     {
         int size = settings.get_int (FiveOrMoreApp.KEY_SIZE);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]