[iagno] Remove theme's dialog.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [iagno] Remove theme's dialog.
- Date: Sun, 28 Jul 2019 18:40:07 +0000 (UTC)
commit a809f2d72fe158b7f5316abe58df45df44ddfabd
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Jul 28 19:24:46 2019 +0200
Remove theme's dialog.
Replace it by a submenu
for the hamburger menu.
Allows the applications
to add GameView options
as they want, and makes
hamburger menu cleaner.
data/iagno.css | 15 +---
data/iagno.gresource.xml | 1 -
data/themes/adwaita.theme.desktop.in | 2 +-
data/themes/classic.theme.desktop.in | 2 +-
data/themes/high_contrast.theme.desktop.in | 2 +-
data/themes/sun_and_star.theme.desktop.in | 2 +-
data/ui/iagno-themes.ui | 100 -------------------------
data/ui/iagno.ui | 10 ---
po/POTFILES.in | 2 -
po/POTFILES.skip | 1 -
src/game-window.vala | 11 ++-
src/iagno.vala | 91 +++++++++++++++++-----
src/meson.build | 3 +-
src/themes-dialog.vala | 116 -----------------------------
14 files changed, 89 insertions(+), 269 deletions(-)
---
diff --git a/data/iagno.css b/data/iagno.css
index d725454..b3ffd17 100644
--- a/data/iagno.css
+++ b/data/iagno.css
@@ -32,18 +32,9 @@ grid#scoreboard label {
padding: 4px 7px 4px 0;
}
-/* Themes' dialog listbox */
-list#themes-listbox image {
- transition-duration: 200ms;
- opacity: 0;
-}
-
-list#themes-listbox row:selected * {
- opacity: 1;
- color:@theme_selected_fg_color;
-}
-list#themes-listbox row:selected image:backdrop {
- color:@theme_unfocused_selected_fg_color;
+/* "Default" theme is in italic */
+popover > stack > box:nth-child(2) > box > box > box:first-child > modelbutton:first-child > box > label {
+ font-style:italic;
}
/* make all widgets change font-size at same time */
diff --git a/data/iagno.gresource.xml b/data/iagno.gresource.xml
index eb96659..b45d70d 100644
--- a/data/iagno.gresource.xml
+++ b/data/iagno.gresource.xml
@@ -2,7 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/Reversi/ui">
<file preprocess="xml-stripblanks" compressed="true" alias="game-window.ui">ui/iagno.ui</file>
- <file preprocess="xml-stripblanks" compressed="true" alias="themes.ui">ui/iagno-themes.ui</file>
<file preprocess="xml-stripblanks" compressed="true" alias="iagno-screens.ui">ui/iagno-screens.ui</file>
<file compressed="true">iagno.css</file>
<file>noise.png</file>
diff --git a/data/themes/adwaita.theme.desktop.in b/data/themes/adwaita.theme.desktop.in
index 6745ea5..7ea97fe 100644
--- a/data/themes/adwaita.theme.desktop.in
+++ b/data/themes/adwaita.theme.desktop.in
@@ -17,7 +17,7 @@
[Theme]
Id=adwaita
-# Translators: name of a board graphical theme; similar to Gtk theme name, should probably be kept unchanged
+# Translators: name of a board graphical theme, as visible in the "Appearance" submenu of the hamburger
menu; similar to Gtk theme name, should probably be kept unchanged
Name=Adwaita
[Pieces]
diff --git a/data/themes/classic.theme.desktop.in b/data/themes/classic.theme.desktop.in
index 3f56ab1..2d01f14 100644
--- a/data/themes/classic.theme.desktop.in
+++ b/data/themes/classic.theme.desktop.in
@@ -17,7 +17,7 @@
[Theme]
Id=classic
-# Translators: name of a board graphical theme; copies the look of the most common physical board
+# Translators: name of a board graphical theme, as visible in the "Appearance" submenu of the hamburger
menu; copies the look of the most common physical board
Name=Classic
[Pieces]
diff --git a/data/themes/high_contrast.theme.desktop.in b/data/themes/high_contrast.theme.desktop.in
index f328c7d..032451f 100644
--- a/data/themes/high_contrast.theme.desktop.in
+++ b/data/themes/high_contrast.theme.desktop.in
@@ -18,7 +18,7 @@
[Theme]
Id=high_contrast
-# Translators: name of a board graphical theme; uses only two colors, one really dark and one really light
+# Translators: name of a board graphical theme, as visible in the "Appearance" submenu of the hamburger
menu; uses only two colors, one really dark and one really light
Name=Black and White
[Pieces]
diff --git a/data/themes/sun_and_star.theme.desktop.in b/data/themes/sun_and_star.theme.desktop.in
index fc40674..fdefbb8 100644
--- a/data/themes/sun_and_star.theme.desktop.in
+++ b/data/themes/sun_and_star.theme.desktop.in
@@ -17,7 +17,7 @@
[Theme]
Id=sun_and_star
-# Translators: name of a board graphical theme; Light player uses a symbolized Sun, Dark player a symbolized
five-arms star
+# Translators: name of a board graphical theme, as visible in the "Appearance" submenu of the hamburger
menu; Light player uses a symbolized Sun, Dark player a symbolized five-arms star
Name=Sun and Star
[Pieces]
diff --git a/data/ui/iagno.ui b/data/ui/iagno.ui
index 3477d74..b2119ee 100644
--- a/data/ui/iagno.ui
+++ b/data/ui/iagno.ui
@@ -23,16 +23,6 @@
<requires lib="gtk+" version="3.12"/>
<menu id="primary-menu">
<section>
- <item>
- <!-- Translators: hamburger menu entry; open theme dialog button (with a mnemonic that appears
pressing Alt) -->
- <attribute name="label" translatable="yes">A_ppearance</attribute>
- <attribute name="action">app.theme</attribute>
- </item>
- <item>
- <!-- Translators: hamburger menu entry; highlight-turnable-tiles togglebutton (with a mnemonic that
appears pressing Alt) -->
- <attribute name="label" translatable="yes">Highlight _turnable tiles</attribute>
- <attribute name="action">app.highlight-turnable-tiles</attribute>
- </item>
<item>
<!-- Translators: hamburger menu entry; sound togglebutton (with a mnemonic that appears pressing
Alt) -->
<attribute name="label" translatable="yes">_Sound</attribute>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 86f5dbe..250ad7b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,7 +3,6 @@
data/org.gnome.Reversi.appdata.xml.in
data/org.gnome.Reversi.desktop.in
data/ui/iagno-screens.ui
-data/ui/iagno-themes.ui
data/ui/iagno.ui
data/themes/adwaita.theme.desktop.in
data/themes/classic.theme.desktop.in
@@ -16,4 +15,3 @@ src/game-view.vala
src/game-window.vala
src/iagno.vala
src/player.vala
-src/themes-dialog.vala
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 3b32825..6adbb0a 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -4,4 +4,3 @@ src/game-view.c
src/game-window.c
src/iagno.c
src/player.c
-src/themes-dialog.c
diff --git a/src/game-window.vala b/src/game-window.vala
index 9ae536c..f6171ed 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -65,7 +65,7 @@ private class GameWindow : ApplicationWindow
// internal signal void redo ();
// internal signal void hint ();
- internal GameWindow (string? css_resource, string name, int width, int height, bool maximized, bool
start_now, GameWindowFlags flags, Box new_game_screen, Widget _view)
+ internal GameWindow (string? css_resource, string name, int width, int height, bool maximized, bool
start_now, GameWindowFlags flags, Box new_game_screen, Widget _view, GLib.Menu? appearance_menu)
{
if (css_resource != null)
{
@@ -83,6 +83,15 @@ private class GameWindow : ApplicationWindow
set_title (name);
headerbar.set_title (name);
+ GLib.MenuModel hamburger_menu = (!) info_button.get_menu_model ();
+ if (appearance_menu != null)
+ {
+ GLib.Menu first_section = (GLib.Menu) (!) hamburger_menu.get_item_link (0, "section");
+ /* Translators: hamburger menu entry; "Appearance" submenu (with a mnemonic that appears
pressing Alt) */
+ first_section.prepend_submenu (_("A_ppearance"), (!) appearance_menu);
+ }
+ ((GLib.Menu) hamburger_menu).freeze ();
+
set_default_size (width, height);
if (maximized)
maximize ();
diff --git a/src/iagno.vala b/src/iagno.vala
index 01ca287..0aa5f29 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -48,9 +48,6 @@ private class Iagno : Gtk.Application
private Label dark_score_label;
private Label light_score_label;
- private bool should_init_themes_dialog = true;
- private ThemesDialog themes_dialog;
-
/* Computer player (if there is one) */
internal ComputerPlayer? computer { internal get; private set; default = null; }
@@ -97,10 +94,9 @@ private class Iagno : Gtk.Application
private const GLib.ActionEntry app_actions [] =
{
- {"theme", theme_cb},
- {"help", help_cb},
- {"about", about_cb},
- {"quit", quit}
+ { "help", help_cb },
+ { "about", about_cb },
+ { "quit", quit }
};
private static int main (string [] args)
@@ -223,6 +219,69 @@ private class Iagno : Gtk.Application
if (settings.get_boolean ("sound"))
init_sound ();
+ GLib.Menu appearance_menu = new GLib.Menu ();
+ GLib.Menu section = new GLib.Menu ();
+ /* Translators: hamburger menu "Appearance" submenu entry; a name for the default theme */
+ section.append (_("Default"), "app.theme('default')");
+ Dir dir;
+ string wanted_theme_id = settings.get_string ("theme");
+ bool theme_name_found = false;
+ try
+ {
+ dir = Dir.open (Path.build_filename (DATA_DIRECTORY, "themes", "key"));
+ while (true)
+ {
+ string? filename = dir.read_name ();
+ if (filename == null)
+ break;
+ if (filename == "default")
+ {
+ warning ("There should not be a theme filename named \"default\", ignoring it.");
+ continue;
+ }
+
+ string path = Path.build_filename (DATA_DIRECTORY, "themes", "key", (!) filename);
+ GLib.KeyFile key = new GLib.KeyFile ();
+ string theme_name;
+ try
+ {
+ key.load_from_file (path, GLib.KeyFileFlags.NONE);
+ theme_name = key.get_locale_string ("Theme", "Name");
+ }
+ catch (GLib.KeyFileError e)
+ {
+ warning ("oops: %s", e.message);
+ continue;
+ }
+ section.append (theme_name, @"app.theme('$((!) filename)')");
+
+ if (wanted_theme_id == (!) filename)
+ {
+ theme_name_found = true;
+ view.theme = wanted_theme_id;
+ }
+ }
+ }
+ catch (FileError e)
+ {
+ warning ("Failed to load themes: %s", e.message);
+ }
+ if (!theme_name_found && wanted_theme_id != "default")
+ {
+ warning (@"Theme $wanted_theme_id not found, using default.");
+ settings.set_string ("theme", "default");
+ wanted_theme_id = "default";
+ }
+ section.freeze ();
+ appearance_menu.append_section (null, section);
+
+ section = new GLib.Menu ();
+ /* Translators: hamburger menu "Appearance" submenu entry; highlight-turnable-tiles togglebutton
(with a mnemonic that appears pressing Alt) */
+ section.append (_("Highlight _turnable tiles"), "app.highlight-turnable-tiles");
+ section.freeze ();
+ appearance_menu.append_section (null, section);
+ appearance_menu.freeze ();
+
/* Window */
window = new GameWindow ("/org/gnome/Reversi/ui/iagno.css",
PROGRAM_NAME,
@@ -232,7 +291,8 @@ private class Iagno : Gtk.Application
start_now,
GameWindowFlags.SHOW_UNDO | GameWindowFlags.SHOW_START_BUTTON,
(Box) builder.get_object ("new-game-screen"),
- view);
+ view,
+ appearance_menu);
Widget scoregrid = (Widget) builder.get_object ("scoregrid");
window.add_to_sidebox (scoregrid);
@@ -258,7 +318,10 @@ private class Iagno : Gtk.Application
add_action (settings.create_action ("num-players"));
add_action (settings.create_action ("computer-level"));
add_action (settings.create_action ("highlight-turnable-tiles"));
+ add_action (settings.create_action ("theme"));
+
settings.bind ("highlight-turnable-tiles", view, "show-turnable-tiles", SettingsBindFlags.GET);
+ settings.bind ("theme", view, "theme", SettingsBindFlags.GET);
Box level_box = (Box) builder.get_object ("difficulty-box");
Box color_box = (Box) builder.get_object ("color-box");
@@ -296,18 +359,6 @@ private class Iagno : Gtk.Application
* * App-menu callbacks
\*/
- private void theme_cb ()
- {
- /* Don’t permit to open more than one dialog */
- if (should_init_themes_dialog)
- {
- themes_dialog = new ThemesDialog (settings, view);
- themes_dialog.set_transient_for (window);
- should_init_themes_dialog = false;
- }
- themes_dialog.present ();
- }
-
private void help_cb ()
{
try
diff --git a/src/meson.build b/src/meson.build
index 8835d4b..d1a3946 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -25,8 +25,7 @@ executable(meson.project_name(),
'game-window.vala',
'game.vala',
'iagno.vala',
- 'player.vala',
- 'themes-dialog.vala'
+ 'player.vala'
] + resources,
install: true,
c_args: [
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]