[four-in-a-row/arnaudb/new-ui: 8/12] Move New Game button in headerbar.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [four-in-a-row/arnaudb/new-ui: 8/12] Move New Game button in headerbar.
- Date: Thu, 19 Dec 2019 19:50:35 +0000 (UTC)
commit de53264f106f42aa8f827d8fc8324fe4ec83173e
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Thu Dec 19 00:42:43 2019 +0100
Move New Game button in headerbar.
data/four-in-a-row.css | 2 +
data/ui/four-in-a-row.ui | 130 +++++++++++++++++++++--------------------------
src/four-in-a-row.vala | 2 +-
src/game-window.vala | 69 +++++--------------------
4 files changed, 75 insertions(+), 128 deletions(-)
---
diff --git a/data/four-in-a-row.css b/data/four-in-a-row.css
index 7072288..c57ab45 100644
--- a/data/four-in-a-row.css
+++ b/data/four-in-a-row.css
@@ -24,3 +24,5 @@ button.unfullscreen-button {
GtkButtonBox {
-GtkButtonBox-child-internal-pad-x:0;
}
+
+.game-box { padding:1.5rem; }
diff --git a/data/ui/four-in-a-row.ui b/data/ui/four-in-a-row.ui
index 124144a..b4a7360 100644
--- a/data/ui/four-in-a-row.ui
+++ b/data/ui/four-in-a-row.ui
@@ -17,6 +17,20 @@
-->
<interface>
<requires lib="gtk+" version="3.12"/>
+ <menu id="game-menu">
+ <section>
+ <item>
+ <!-- Translators: during a game, entry in the game menu, for undoing the last move -->
+ <attribute name="label" translatable="yes">_Undo last move</attribute>
+ <attribute name="action">ui.undo</attribute>
+ </item>
+ <item>
+ <!-- Translators: during a game, entry in the game menu, for suggesting where to play -->
+ <attribute name="label" translatable="yes">_Hint</attribute>
+ <attribute name="action">ui.hint</attribute>
+ </item>
+ </section>
+ </menu>
<template class="GameWindow" parent="GtkApplicationWindow">
<!-- <initial-focus name="view"/> -->
<child type="titlebar">
@@ -24,10 +38,21 @@
<property name="visible">True</property>
<property name="show-close-button">True</property>
<child>
- <object class="GtkBox" id="controls_box">
- <property name="visible">False</property>
- <property name="orientation">horizontal</property>
+ <object class="GtkButton" id="new_game_button">
+ <property name="visible">True</property>
+ <property name="use-underline">True</property>
+ <!-- Translators: during a game, label of the New Game button (with a mnemonic that appears
pressing Alt) -->
+ <property name="label" translatable="yes">_New Game</property>
+ <property name="halign">fill</property>
+ <property name="valign">center</property>
+ <property name="action-name">ui.new-game</property>
+ <!-- Translators: during a game, tooltip text of the New Game button -->
+ <property name="tooltip-text" translatable="yes">Start a new game</property>
</object>
+ <packing>
+ <property name="pack-type">start</property>
+ <property name="position">0</property>
+ </packing>
</child>
<child>
<object class="GtkButton" id="back_button">
@@ -50,6 +75,30 @@
</object>
</child>
</object>
+ <packing>
+ <property name="pack-type">start</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="game_button">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="can-focus">True</property>
+ <property name="focus-on-click">False</property>
+ <property name="menu-model">game-menu</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">pan-down-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ <property name="position">1</property>
+ </packing>
</child>
<child>
<object class="GtkMenuButton" id="info_button">
@@ -95,77 +144,16 @@
</packing>
</child>
<child>
- <object class="GtkAspectFrame">
+ <object class="GtkBox" id="game_box">
<property name="visible">True</property>
- <property name="shadow-type">GTK_SHADOW_NONE</property>
- <property name="obey-child">false</property>
- <property name="ratio">1.4</property>
- <property name="margin">25</property>
- <child>
- <object class="GtkBox" id="game_box">
- <property name="visible">True</property>
- <property name="orientation">horizontal</property>
- <property name="spacing">25</property>
- <child>
- <object class="GtkBox" id="side_box">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkButton" id="new_game_button">
- <property name="visible">True</property>
- <property name="use-underline">True</property>
- <!-- 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="halign">fill</property>
- <property name="valign">center</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>
- <property name="width-request">120</property>
- <property name="height-request">60</property>
- </object>
- <packing>
- <property name="pack-type">end</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="hint_button">
- <property name="visible">True</property>
- <property name="use-underline">True</property>
- <!-- Translators: during a game, label of the Hint button (with a mnemonic that
appears pressing Alt) -->
- <property name="label" translatable="yes">_Hint</property>
- <property name="halign">fill</property>
- <property name="valign">center</property>
- <property name="action-name">ui.hint</property>
- <!-- Translators: during a game, tooltip text of the Hint button -->
- <property name="tooltip-text" translatable="yes">Suggest a play</property>
- <property name="width-request">120</property>
- <property name="height-request">60</property>
- </object>
- <packing>
- <property name="pack-type">end</property>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="pack-type">end</property>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">0</property>
- </packing>
- </child>
- </object>
- </child>
+ <property name="orientation">horizontal</property>
+ <property name="spacing">25</property>
+ <style>
+ <class name="game-box"/>
+ </style>
</object>
<packing>
- <property name="name">frame</property>
+ <property name="name">game-box</property>
</packing>
</child>
</object>
diff --git a/src/four-in-a-row.vala b/src/four-in-a-row.vala
index 386dc92..d5f2a02 100644
--- a/src/four-in-a-row.vala
+++ b/src/four-in-a-row.vala
@@ -781,7 +781,7 @@ private class FourInARow : Gtk.Application
Prefs.instance.settings.get_int ("window-height"),
Prefs.instance.settings.get_boolean ("window-is-maximized"),
/* start_now */ true,
- GameWindowFlags.SHOW_UNDO | GameWindowFlags.SHOW_START_BUTTON,
+ GameWindowFlags.SHOW_START_BUTTON,
(Box) builder.get_object ("new-game-screen"),
game_board_view,
app_menu);
diff --git a/src/game-window.vala b/src/game-window.vala
index 5478652..bf9b5fd 100644
--- a/src/game-window.vala
+++ b/src/game-window.vala
@@ -49,12 +49,11 @@ private class GameWindow : ApplicationWindow
private Button? start_game_button = null;
[GtkChild] private Button new_game_button;
[GtkChild] private Button back_button;
+ [GtkChild] private Button game_button;
[GtkChild] private Button unfullscreen_button;
- [GtkChild] private Box controls_box;
[GtkChild] private Box game_box;
[GtkChild] private Box new_game_box;
- [GtkChild] private Box side_box;
private Widget view;
@@ -118,45 +117,6 @@ private class GameWindow : ApplicationWindow
view.can_focus = true;
view.show ();
- /* add controls */
- if (GameWindowFlags.SHOW_UNDO in flags)
- {
- Box history_box = new Box (Orientation.HORIZONTAL, 0);
- 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 = "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;
- undo_button.show ();
- history_box.pack_start (undo_button, true, true, 0);
-
- /* if (GameWindowFlags.SHOW_REDO in flags)
- {
- Button redo_button = new Button.from_icon_name ("edit-redo-symbolic", Gtk.IconSize.BUTTON);
- redo_button.action_name = "app.redo";
- / Translators: during a game, tooltip text of the Redo button /
- redo_button.set_tooltip_text (_("Redo your most recent undone move"));
- redo_button.valign = Align.CENTER;
- redo_button.show ();
- history_box.pack_start (redo_button, true, true, 0);
- } */
-
- history_box.show ();
- controls_box.pack_start (history_box, true, true, 0);
- }
- /* if (GameWindowFlags.SHOW_HINT in flags)
- {
- Button hint_button = new Button.from_icon_name ("dialog-question-symbolic", Gtk.IconSize.BUTTON);
- hint_button.action_name = "app.hint";
- / Translators: during a game, tooltip text of the Hint button /
- hint_button.set_tooltip_text (_("Receive a hint for your next move"));
- hint_button.valign = Align.CENTER;
- hint_button.show ();
- controls_box.pack_start (hint_button, true, true, 0);
- } */
-
/* start or not */
if (start_now)
show_view ();
@@ -255,11 +215,6 @@ private class GameWindow : ApplicationWindow
* * Some internal calls
\*/
- internal void add_to_sidebox (Widget widget)
- {
- side_box.pack_start (widget, false, false, 0);
- }
-
internal void cannot_undo_more ()
{
undo_action.set_enabled (false);
@@ -292,7 +247,7 @@ private class GameWindow : ApplicationWindow
internal void allow_hint (bool allow)
{
string? stack_child = stack.get_visible_child_name ();
- if (stack_child == null || (!) stack_child != "frame")
+ if (stack_child == null || (!) stack_child != "game-box")
return;
hint_action.set_enabled (allow);
}
@@ -300,7 +255,7 @@ private class GameWindow : ApplicationWindow
internal void allow_undo (bool allow)
{
string? stack_child = stack.get_visible_child_name ();
- if (stack_child == null || (!) stack_child != "frame")
+ if (stack_child == null || (!) stack_child != "game-box")
return;
undo_action.set_enabled (allow);
}
@@ -315,7 +270,8 @@ private class GameWindow : ApplicationWindow
headerbar.set_title (program_name);
stack.set_visible_child_name ("start-box");
- controls_box.hide ();
+ game_button.hide ();
+ new_game_button.hide ();
if (!game_finished && back_button.visible)
back_button.grab_focus ();
@@ -327,9 +283,10 @@ private class GameWindow : ApplicationWindow
{
headerbar.set_title (last_subtitle);
- stack.set_visible_child_name ("frame");
+ stack.set_visible_child_name ("game-box");
back_button.hide (); // TODO transition?
- controls_box.show ();
+ game_button.show ();
+ new_game_button.show ();
if (game_finished)
new_game_button.grab_focus ();
@@ -344,7 +301,7 @@ private class GameWindow : ApplicationWindow
private void new_game_cb ()
{
string? stack_child = stack.get_visible_child_name ();
- if (stack_child == null || (!) stack_child != "frame")
+ if (stack_child == null || (!) stack_child != "game-box")
return;
wait ();
@@ -392,7 +349,7 @@ private class GameWindow : ApplicationWindow
}
/*\
- * * Controls_box actions
+ * * Game menu actions
\*/
private void undo_cb ()
@@ -400,7 +357,7 @@ private class GameWindow : ApplicationWindow
string? stack_child = stack.get_visible_child_name ();
if (stack_child == null)
return;
- if ((!) stack_child != "frame")
+ if ((!) stack_child != "game-box")
{
if (back_action.get_enabled ())
back_cb ();
@@ -418,7 +375,7 @@ private class GameWindow : ApplicationWindow
/* private void redo_cb ()
{
string? stack_child = stack.get_visible_child_name ();
- if (stack_child == null || (!) stack_child != "frame")
+ if (stack_child == null || (!) stack_child != "game-box")
return;
if (!back_button.is_focus)
@@ -430,7 +387,7 @@ private class GameWindow : ApplicationWindow
private void hint_cb ()
{
string? stack_child = stack.get_visible_child_name ();
- if (stack_child == null || (!) stack_child != "frame")
+ if (stack_child == null || (!) stack_child != "game-box")
return;
hint ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]