[gnome-taquin] Move 'undo' action to a MenuButton.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin] Move 'undo' action to a MenuButton.
- Date: Mon, 21 Jan 2019 06:12:49 +0000 (UTC)
commit c8b386fb0dd8fde6cf713189274abfdda2500b90
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Jan 19 11:26:20 2019 +0100
Move 'undo' action to a MenuButton.
As planned, created a history menubutton.
data/game-headerbar.ui | 35 ++++++++++++++++++++++++++++++++---
src/game-headerbar.vala | 26 +++++++++++++-------------
2 files changed, 45 insertions(+), 16 deletions(-)
---
diff --git a/data/game-headerbar.ui b/data/game-headerbar.ui
index a0b1673..9ffcae2 100644
--- a/data/game-headerbar.ui
+++ b/data/game-headerbar.ui
@@ -17,12 +17,41 @@
-->
<interface>
<requires lib="gtk+" version="3.12"/>
+ <menu id="history-menu">
+ <section>
+ <item>
+ <!-- Translators: during a game, entry in the menu of the history menubutton (with a mnemonic that
appears pressing Alt) -->
+ <attribute name="label" translatable="yes">_Undo</attribute>
+ <attribute name="action">ui.undo</attribute>
+ </item>
+ </section>
+ </menu>
<template class="GameHeaderBar" parent="BaseHeaderBar">
<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="GtkMenuButton" id="history_button">
+ <property name="visible">True</property>
+ <property name="valign">center</property>
+ <property name="focus-on-click">False</property>
+ <property name="menu-model">history-menu</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <!-- Translators: accessible name of the history menubutton -->
+ <property name="AtkObject::accessible-name" translatable="yes">History</property>
+ <!-- Translators: accessible description of the history menubutton -->
+ <property name="AtkObject::accessible-description" translatable="yes">Game history
menu</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="icon-name">document-open-recent-symbolic</property>
+ <property name="icon-size">1</property>
+ </object>
+ </child>
</object>
<packing>
<property name="pack-type">end</property>
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index 8d2ef38..8eea029 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -23,9 +23,9 @@ using Gtk;
[GtkTemplate (ui = "/org/gnome/Taquin/ui/game-headerbar.ui")]
private class GameHeaderBar : BaseHeaderBar
{
- [GtkChild] private Box controls_box;
- [GtkChild] private Button new_game_button;
- [GtkChild] private Button back_button;
+ [GtkChild] private MenuButton history_button;
+ [GtkChild] private Button new_game_button;
+ [GtkChild] private Button back_button;
public bool window_has_name { private get; protected construct; default = false; }
public string window_name { private get; internal construct; default = ""; }
@@ -47,20 +47,20 @@ private class GameHeaderBar : BaseHeaderBar
has_keyboard_shortcuts: false,
window_name: _window_name);
- if (GameWindowFlags.SHOW_UNDO in flags)
+/* 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"));
+*/ /* 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)
+*/ /* 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";
@@ -71,10 +71,10 @@ private class GameHeaderBar : BaseHeaderBar
history_box.pack_start (redo_button, true, true, 0);
} */
- history_box.show ();
+/* history_box.show ();
controls_box.pack_start (history_box, true, true, 0);
}
- /* if (GameWindowFlags.SHOW_HINT in flags)
+*/ /* 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";
@@ -132,7 +132,7 @@ private class GameHeaderBar : BaseHeaderBar
set_subtitle (null); // TODO save / restore?
- controls_box.hide ();
+ history_button.hide ();
if (!game_finished && back_button.visible)
{
@@ -149,7 +149,7 @@ private class GameHeaderBar : BaseHeaderBar
back_button.hide (); // TODO transition?
new_game_button.show (); // TODO transition?
- controls_box.show ();
+ history_button.show ();
if (game_finished)
{
@@ -220,14 +220,14 @@ private class GameHeaderBar : BaseHeaderBar
real_this.back_button.show ();
else
{
- real_this.controls_box.show ();
+ real_this.history_button.show ();
real_this.new_game_button.show ();
}
}
else
{
real_this.back_button.hide ();
- real_this.controls_box.hide ();
+ real_this.history_button.hide ();
real_this.new_game_button.hide ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]