[gnome-nibbles] Set default widgets for the pre-game screens.
- From: Iulian Radu <iulianradu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-nibbles] Set default widgets for the pre-game screens.
- Date: Mon, 15 Aug 2016 10:42:28 +0000 (UTC)
commit b9d2cf58d396a6de4b106e3cac94bc54d56fff7a
Author: Iulian Radu <iulian radu67 gmail com>
Date: Mon Aug 15 13:38:31 2016 +0300
Set default widgets for the pre-game screens.
This allows the user to just press enter until the game starts after
opening Nibbles.
https://bugzilla.gnome.org/show_bug.cgi?id=769838
data/nibbles.ui | 6 ++++--
src/gnome-nibbles.vala | 14 +++++++++++---
2 files changed, 15 insertions(+), 5 deletions(-)
---
diff --git a/data/nibbles.ui b/data/nibbles.ui
index ad2a050..646e326 100644
--- a/data/nibbles.ui
+++ b/data/nibbles.ui
@@ -326,8 +326,9 @@
</packing>
</child>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="next_button">
<property name="visible">True</property>
+ <property name="can-default">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Next</property>
<property
name="action-name">app.show-controls-screen</property>
@@ -377,8 +378,9 @@
</object>
</child>
<child>
- <object class="GtkButton">
+ <object class="GtkButton" id="start_button">
<property name="visible">True</property>
+ <property name="can-default">True</property>
<property name="use-underline">True</property>
<property name="label" translatable="yes">_Start</property>
<property name="action-name">app.start-game</property>
diff --git a/src/gnome-nibbles.vala b/src/gnome-nibbles.vala
index c57a027..84bc636 100644
--- a/src/gnome-nibbles.vala
+++ b/src/gnome-nibbles.vala
@@ -40,6 +40,8 @@ public class Nibbles : Gtk.Application
/* Pre-game screen widgets */
private Gee.LinkedList<Gtk.ToggleButton> number_of_players_buttons;
private Gee.LinkedList<Gtk.ToggleButton> number_of_ai_buttons;
+ private Gtk.Button next_button;
+ private Gtk.Button start_button;
private Gtk.Box grids_box;
private Gdk.Pixbuf arrow_pixbuf;
@@ -194,6 +196,8 @@ public class Nibbles : Gtk.Application
button.toggled.connect (change_number_of_ai_cb);
number_of_ai_buttons.add (button);
}
+ next_button = (Gtk.Button) builder.get_object ("next_button");
+ start_button = (Gtk.Button) builder.get_object ("start_button");
grids_box = (Gtk.Box) builder.get_object ("grids_box");
window.set_titlebar (headerbar);
@@ -544,12 +548,14 @@ public class Nibbles : Gtk.Application
new_game_button.hide ();
pause_button.hide ();
+ number_of_players_buttons[game.numhumans - 1].set_active (true);
+ number_of_ai_buttons[game.numai].set_active (true);
+
+ window.set_default (next_button);
+
main_stack.set_transition_type (Gtk.StackTransitionType.NONE);
main_stack.set_visible_child_name ("number_of_players");
main_stack.set_transition_type (Gtk.StackTransitionType.SLIDE_UP);
-
- number_of_players_buttons[game.numhumans - 1].set_active (true);
- number_of_ai_buttons[game.numai].set_active (true);
}
private void show_controls_screen_cb ()
@@ -600,6 +606,8 @@ public class Nibbles : Gtk.Application
}
}
+ window.set_default (start_button);
+
main_stack.set_visible_child_name ("controls");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]