[gnome-taquin] Focus hacks.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin] Focus hacks.
- Date: Fri, 26 Dec 2014 17:48:55 +0000 (UTC)
commit 5b1d449c948ee7c0a8e8b01dfceec584d3bea54c
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Fri Dec 26 18:48:10 2014 +0100
Focus hacks.
data/taquin.ui | 4 ++--
src/taquin-main.vala | 23 +++++++++++++++++++++--
src/taquin-view.vala | 2 +-
3 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/data/taquin.ui b/data/taquin.ui
index 1be393e..c461267 100644
--- a/data/taquin.ui
+++ b/data/taquin.ui
@@ -185,7 +185,7 @@
</packing>
</child>
<child>
- <object class="GtkButton">
+ <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>
@@ -225,7 +225,7 @@
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="start-over-button">
<property name="visible">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Start Over</property>
diff --git a/src/taquin-main.vala b/src/taquin-main.vala
index a4ac3fc..2f1e659 100644
--- a/src/taquin-main.vala
+++ b/src/taquin-main.vala
@@ -40,6 +40,8 @@ public class Taquin : Gtk.Application
private HeaderBar headerbar;
private Button back_button;
private Button undo_button;
+ private Button start_game_button;
+ private Button start_over_button;
private Stack stack;
private MenuButton size_button;
private MenuButton theme_button;
@@ -49,6 +51,7 @@ public class Taquin : Gtk.Application
private Game? game = null;
private SimpleAction undo_action;
List<string> theme_dirlist;
+ private bool game_finished = false;
private static const OptionEntry[] option_entries =
{
@@ -169,7 +172,9 @@ public class Taquin : Gtk.Application
headerbar = builder.get_object ("headerbar") as HeaderBar;
back_button = builder.get_object ("back-button") as Button;
- undo_button = builder.get_object ("undo-button") as Button;
+ undo_button = builder.get_object ("undo-button") as Button;
+ start_game_button = builder.get_object ("start-game-button") as Button;
+ start_over_button = builder.get_object ("start-over-button") as Button;
stack = builder.get_object ("main-stack") as Stack;
size_button = builder.get_object ("size-button") as MenuButton;
@@ -265,6 +270,10 @@ public class Taquin : Gtk.Application
undo_button.hide ();
stack.set_visible_child_name ("start-box");
back_button.show ();
+ if (undo_action.enabled)
+ back_button.grab_focus ();
+ else
+ start_game_button.grab_focus ();
}
private void back_cb ()
@@ -274,6 +283,10 @@ public class Taquin : Gtk.Application
back_button.hide ();
stack.set_visible_child_name ("frame");
undo_button.show ();
+ if (game_finished)
+ start_over_button.grab_focus (); // TODO change headerbar subtitle?
+ else
+ view.grab_focus ();
}
private void start_game_cb ()
@@ -283,6 +296,7 @@ public class Taquin : Gtk.Application
back_button.hide ();
start_game ();
undo_button.show ();
+ view.grab_focus ();
}
/*\
@@ -295,11 +309,13 @@ public class Taquin : Gtk.Application
SignalHandler.disconnect_by_func (game, null, this);
undo_action.set_enabled (false);
+ game_finished = false;
var type = (GameType) settings.get_enum ("type");
var size = settings.get_int ("size");
game = new Game (type, size);
view.game = game;
+ view.grab_focus ();
var filename = "";
var dirlist = theme_dirlist.copy ();
@@ -338,7 +354,7 @@ public class Taquin : Gtk.Application
"documenters", documenters,
"translator-credits", _("translator-credits"),
"logo-icon-name", "gnome-taquin",
- "website", "https://wiki.gnome.org/Apps/Taquin", // TODO
+ "website", "https://wiki.gnome.org/Apps/Taquin",
null);
}
@@ -367,6 +383,7 @@ public class Taquin : Gtk.Application
private void cannot_undo_more_cb ()
{
undo_action.set_enabled (false);
+ view.grab_focus ();
}
private void move_cb ()
{
@@ -380,6 +397,8 @@ public class Taquin : Gtk.Application
}
private void game_complete_cb ()
{
+ game_finished = true;
+ start_over_button.grab_focus ();
headerbar.set_subtitle (_("Bravo! You finished the game!"));
undo_action.set_enabled (false);
play_sound ("gameover");
diff --git a/src/taquin-view.vala b/src/taquin-view.vala
index 91ea125..ed1dd86 100644
--- a/src/taquin-view.vala
+++ b/src/taquin-view.vala
@@ -428,7 +428,7 @@ public class TaquinView : Gtk.DrawingArea
default: return false;
}
}
- if (k_name == "space" || k_name == "KP_Enter" || k_name == "Return")
+ if (k_name == "space" || k_name == "KP_Enter" || k_name == "Return") // TODO even if
game.game_type == GameType.SIXTEEN ??
{
game.request_move (x_arrow, y_arrow);
return true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]