[gnome-taquin] Use custom action group.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin] Use custom action group.
- Date: Mon, 21 Jan 2019 06:11:34 +0000 (UTC)
commit 843d688209f33ad0d44946905d4a3ac71a4f2b5d
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Mon Jan 14 08:41:56 2019 +0100
Use custom action group.
Keep exposing actions over D-Bus, the API
has not been thought or designed for now.
data/game-headerbar.ui | 4 ++--
src/game-headerbar.vala | 2 +-
src/game-view.vala | 2 +-
src/game-window.vala | 27 +++++++++++++++------------
src/taquin-main.vala | 12 ++++++------
5 files changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/data/game-headerbar.ui b/data/game-headerbar.ui
index 47c0cab..a8d53d7 100644
--- a/data/game-headerbar.ui
+++ b/data/game-headerbar.ui
@@ -38,7 +38,7 @@
<!-- Translators: when configuring a new game, if the user has a started game, tooltip text of the
Go back button -->
<property name="tooltip-text" translatable="yes">Go back to the current game</property>
<property name="use-underline">True</property>
- <property name="action-name">win.back</property>
+ <property name="action-name">ui.back</property>
<style><class name="image-button"/></style>
<child>
<object class="GtkImage">
@@ -61,7 +61,7 @@
<!-- Translators: during a game, label of the Start Over button (with a mnemonic that appears
pressing Alt) -->
<property name="label" translatable="yes">_Start Over</property>
<property name="use-underline">True</property>
- <property name="action-name">win.new-game</property>
+ <property name="action-name">ui.new-game</property>
<!-- Translators: during a game, tooltip text of the Start Over button -->
<property name="tooltip-text" translatable="yes">Start a new game</property>
</object>
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index 0c7eae5..a30ee91 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -36,7 +36,7 @@ private class GameHeaderBar : HeaderBar
history_box.get_style_context ().add_class ("linked");
Button undo_button = new Button.from_icon_name ("edit-undo-symbolic", Gtk.IconSize.BUTTON);
- undo_button.action_name = "win.undo";
+ undo_button.action_name = "ui.undo";
/* Translators: during a game, tooltip text of the Undo button */
undo_button.set_tooltip_text (_("Undo your most recent move"));
undo_button.valign = Align.CENTER;
diff --git a/src/game-view.vala b/src/game-view.vala
index 04bd5bd..c71c664 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -49,7 +49,7 @@ private class GameView : Stack
start_game_button.width_request = 222;
start_game_button.height_request = 60;
start_game_button.halign = Align.CENTER;
- start_game_button.set_action_name ("win.start-game");
+ start_game_button.set_action_name ("ui.start-game");
/* Translators: when configuring a new game, tooltip text of the blue Start button */
// start_game_button.set_tooltip_text (_("Start a new game as configured"));
((StyleContext) start_game_button.get_style_context ()).add_class ("suggested-action");
diff --git a/src/game-window.vala b/src/game-window.vala
index 3d722c3..ebf120f 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -60,7 +60,7 @@ private class GameWindow : ApplicationWindow
}
/* window actions */
- install_win_action_entries ();
+ install_ui_action_entries ();
/* window config */
set_title (name);
@@ -163,24 +163,25 @@ private class GameWindow : ApplicationWindow
public signal void redo ();
public signal void hint ();
- private SimpleAction back_action;
- public SimpleAction undo_action;
- public SimpleAction redo_action;
+ public SimpleAction undo_action;
+ public SimpleAction redo_action;
- private void install_win_action_entries ()
+ private bool back_action_disabled = true;
+
+ private void install_ui_action_entries ()
{
- add_action_entries (win_actions, this);
+ SimpleActionGroup action_group = new SimpleActionGroup ();
+ action_group.add_action_entries (ui_action_entries, this);
+ insert_action_group ("ui", action_group);
- back_action = (SimpleAction) lookup_action ("back");
- undo_action = (SimpleAction) lookup_action ("undo");
- redo_action = (SimpleAction) lookup_action ("redo");
+ undo_action = (SimpleAction) action_group.lookup_action ("undo");
+ redo_action = (SimpleAction) action_group.lookup_action ("redo");
- back_action.set_enabled (false);
undo_action.set_enabled (false);
redo_action.set_enabled (false);
}
- private const GLib.ActionEntry win_actions[] =
+ private const GLib.ActionEntry [] ui_action_entries =
{
{ "new-game", new_game_cb },
{ "start-game", start_game_cb },
@@ -204,7 +205,7 @@ private class GameWindow : ApplicationWindow
game_view.set_transition_duration (800);
headerbar.new_game ();
- back_action.set_enabled (true);
+ back_action_disabled = false;
show_new_game_screen ();
}
@@ -227,6 +228,8 @@ private class GameWindow : ApplicationWindow
private void back_cb (/* SimpleAction action, Variant? variant */)
{
+ if (back_action_disabled)
+ return;
if (game_view.game_content_visible_if_true ())
return;
diff --git a/src/taquin-main.vala b/src/taquin-main.vala
index a68d2eb..5adf371 100644
--- a/src/taquin-main.vala
+++ b/src/taquin-main.vala
@@ -157,13 +157,13 @@ public class Taquin : Gtk.Application
window.play.connect (start_game);
window.undo.connect (undo_cb);
- set_accels_for_action ("win.new-game", { "<Primary>n" });
- set_accels_for_action ("win.start-game", { "<Shift><Primary>n" });
+ set_accels_for_action ("ui.new-game", { "<Primary>n" });
+ set_accels_for_action ("ui.start-game", { "<Shift><Primary>n" });
set_accels_for_action ("app.quit", { "<Primary>q" });
- set_accels_for_action ("win.undo", { "<Primary>z" });
- set_accels_for_action ("win.redo", { "<Shift><Primary>z" });
- set_accels_for_action ("win.back", { "Escape" });
- set_accels_for_action ("win.toggle-hamburger", { "F10" });
+ set_accels_for_action ("ui.undo", { "<Primary>z" });
+ set_accels_for_action ("ui.redo", { "<Shift><Primary>z" });
+ set_accels_for_action ("ui.back", { "Escape" });
+ set_accels_for_action ("ui.toggle-hamburger", { "F10" });
set_accels_for_action ("app.help", { "F1" });
set_accels_for_action ("app.about", { "<Shift>F1" });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]