[gnome-taquin] Manage the Start Button with a flag.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin] Manage the Start Button with a flag.
- Date: Wed, 25 Mar 2015 01:35:22 +0000 (UTC)
commit a631facbec99c975985a67195f60273997947450
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Wed Mar 25 02:35:12 2015 +0100
Manage the Start Button with a flag.
data/taquin.ui | 18 ------------------
src/game-window.vala | 20 ++++++++++++++++----
src/taquin-main.vala | 2 +-
3 files changed, 17 insertions(+), 23 deletions(-)
---
diff --git a/data/taquin.ui b/data/taquin.ui
index 0cc0842..3b8ba24 100644
--- a/data/taquin.ui
+++ b/data/taquin.ui
@@ -47,24 +47,6 @@
<property name="width-request">350</property>
<property name="height-request">350</property>
<property name="spacing">6</property>
- <child>
- <object class="GtkButton" id="start_game_button">
- <property name="visible">True</property>
- <property name="use-underline">True</property>
- <property name="label" translatable="yes">_Start Game</property>
- <!-- <property name="tooltip-text" translatable="yes">Start a new game as
configured</property> TODO -->
- <property name="action-name">win.start-game</property>
- <property name="width-request">222</property>
- <property name="height-request">60</property>
- <property name="halign">center</property>
- <style><class name="suggested-action"/></style>
- </object>
- <packing>
- <property name="pack-type">end</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- </packing>
- </child>
</object>
<packing>
<property name="name">start-box</property>
diff --git a/src/game-window.vala b/src/game-window.vala
index 16b675b..66ecd5c 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -24,7 +24,8 @@ using Gtk;
public enum GameWindowFlags {
SHOW_UNDO,
SHOW_REDO,
- SHOW_HINT;
+ SHOW_HINT,
+ SHOW_START_BUTTON;
}
[GtkTemplate (ui = "/org/gnome/taquin/ui/game-window.ui")]
@@ -44,11 +45,10 @@ public class GameWindow : ApplicationWindow
[GtkChild]
private Stack stack;
+ private Button? start_game_button = null;
[GtkChild]
private Button new_game_button;
[GtkChild]
- private Button start_game_button;
- [GtkChild]
private Button back_button;
[GtkChild]
@@ -123,6 +123,18 @@ public class GameWindow : ApplicationWindow
/* add widgets */
new_game_box.pack_start (new_game_screen, true, true, 0);
+ if (GameWindowFlags.SHOW_START_BUTTON in flags)
+ {
+ start_game_button = new Button.with_mnemonic (_("_Start Game"));
+ // start_game_button.set_tooltip_text (_("Start a new game as configured"));
+ 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");
+ ((StyleContext) start_game_button.get_style_context ()).add_class ("suggested-action");
+ start_game_button.show ();
+ new_game_box.pack_end (start_game_button, false, false, 0);
+ }
game_box.pack_start (view, true, true, 0);
game_box.set_focus_child (view); // TODO test if necessary; note: view could grab focus
from application
@@ -244,7 +256,7 @@ public class GameWindow : ApplicationWindow
if (!game_finished && back_button.visible)
back_button.grab_focus ();
- else
+ else if (start_game_button != null)
start_game_button.grab_focus ();
}
diff --git a/src/taquin-main.vala b/src/taquin-main.vala
index 76b3947..992f009 100644
--- a/src/taquin-main.vala
+++ b/src/taquin-main.vala
@@ -137,7 +137,7 @@ public class Taquin : Gtk.Application
settings.get_int ("window-height"),
settings.get_boolean ("window-is-maximized"),
true, // TODO add an option to go to new-game screen?
- GameWindowFlags.SHOW_UNDO,
+ GameWindowFlags.SHOW_UNDO | GameWindowFlags.SHOW_START_BUTTON,
(Box) builder.get_object ("new-game-screen"),
view);
window.play.connect (start_game);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]