[iagno] Manage the Start Button with a flag.



commit 843b5454d37624f82937b2ac2e7578e9e485d2c6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Wed Mar 25 02:33:44 2015 +0100

    Manage the Start Button with a flag.

 data/iagno.ui        |   18 ------------------
 src/game-window.vala |   20 ++++++++++++++++----
 src/iagno.vala       |    2 +-
 3 files changed, 17 insertions(+), 23 deletions(-)
---
diff --git a/data/iagno.ui b/data/iagno.ui
index eaa50b6..2d01a24 100644
--- a/data/iagno.ui
+++ b/data/iagno.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 e9c3bef..f093dca 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/iagno/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/iagno.vala b/src/iagno.vala
index a28bca9..f256258 100644
--- a/src/iagno.vala
+++ b/src/iagno.vala
@@ -184,7 +184,7 @@ public class Iagno : Gtk.Application
                                  settings.get_int ("window-height"),
                                  settings.get_boolean ("window-is-maximized"),
                                  start_now,
-                                 GameWindowFlags.SHOW_UNDO,
+                                 GameWindowFlags.SHOW_UNDO | GameWindowFlags.SHOW_START_BUTTON,
                                  (Box) builder.get_object ("new-game-screen"),
                                  view);
 


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