[gnome-2048/arnaudb/wip/gtk4: 30/57] HeaderBar is not subclassable anymore.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-2048/arnaudb/wip/gtk4: 30/57] HeaderBar is not subclassable anymore.
- Date: Mon, 28 Sep 2020 14:35:55 +0000 (UTC)
commit f4517e460c7f1477d5e0e0eb9617216dc4db45b6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Tue Apr 28 09:37:33 2020 +0200
HeaderBar is not subclassable anymore.
data/game-headerbar.ui | 62 ++++++++++++++++++++++++++-----------------------
src/game-headerbar.vala | 14 +++++++----
2 files changed, 42 insertions(+), 34 deletions(-)
---
diff --git a/data/game-headerbar.ui b/data/game-headerbar.ui
index 471e45b..aeb2820 100644
--- a/data/game-headerbar.ui
+++ b/data/game-headerbar.ui
@@ -17,37 +17,41 @@
-->
<interface>
<requires lib="gtk+" version="3.99"/>
- <template class="GameHeaderBar" parent="GtkHeaderBar">
- <property name="can-focus">False</property>
- <!-- Translators: title of the window, displayed in the headerbar -->
- <property name="title" translatable="yes">GNOME 2048</property>
- <property name="show-title-buttons">True</property>
+ <template class="GameHeaderBar" parent="GtkWidget">
<child>
- <object class="GtkMenuButton" id="_new_game_button">
- <!-- Translators: button in the headerbar (with a mnemonic that appears pressing Alt) -->
- <property name="label" translatable="yes">_New Game</property>
- <property name="valign">center</property>
- <property name="can-focus">True</property>
- <property name="receives-default">True</property>
- <property name="use-underline">True</property>
- <property name="focus-on-click">False</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkLabel" id="_score">
+ <object class="GtkHeaderBar" id="_headerbar">
<property name="can-focus">False</property>
- <property name="label">0</property>
- </object>
- </child>
- <child type="end">
- <object class="GtkMenuButton" id="_hamburger_button">
- <property name="halign">end</property>
- <property name="valign">center</property>
- <property name="focus-on-click">False</property>
- <property name="icon-name">open-menu-symbolic</property>
- <style>
- <class name="image-button"/>
- </style>
+ <!-- Translators: title of the window, displayed in the headerbar -->
+ <property name="title" translatable="yes">GNOME 2048</property>
+ <property name="show-title-buttons">True</property>
+ <child>
+ <object class="GtkMenuButton" id="_new_game_button">
+ <!-- Translators: button in the headerbar (with a mnemonic that appears pressing Alt) -->
+ <property name="label" translatable="yes">_New Game</property>
+ <property name="valign">center</property>
+ <property name="can-focus">True</property>
+ <property name="receives-default">True</property>
+ <property name="use-underline">True</property>
+ <property name="focus-on-click">False</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkLabel" id="_score">
+ <property name="can-focus">False</property>
+ <property name="label">0</property>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="_hamburger_button">
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <property name="focus-on-click">False</property>
+ <property name="icon-name">open-menu-symbolic</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ </object>
+ </child>
</object>
</child>
</template>
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index b474e8a..50e1fe5 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -21,8 +21,9 @@
using Gtk;
[GtkTemplate (ui = "/org/gnome/TwentyFortyEight/ui/game-headerbar.ui")]
-private class GameHeaderBar : HeaderBar
+private class GameHeaderBar : Widget
{
+ [GtkChild] private HeaderBar _headerbar;
[GtkChild] private Label _score;
[GtkChild] private MenuButton _new_game_button;
[GtkChild] private MenuButton _hamburger_button;
@@ -35,6 +36,9 @@ private class GameHeaderBar : HeaderBar
construct
{
+ BinLayout layout = new BinLayout ();
+ set_layout_manager (layout);
+
_hamburger_button.notify ["active"].connect (test_popover_closed);
_new_game_button.notify ["active"].connect (test_popover_closed);
}
@@ -57,15 +61,15 @@ private class GameHeaderBar : HeaderBar
internal void clear_subtitle ()
{
- set_subtitle (null);
- set_has_subtitle (false);
+ _headerbar.set_subtitle (null);
+ _headerbar.set_has_subtitle (false);
}
internal void finished ()
{
- set_has_subtitle (true);
+ _headerbar.set_has_subtitle (true);
/* Translators: subtitle of the headerbar, when the user cannot move anymore */
- subtitle = _("Game Over");
+ _headerbar.subtitle = _("Game Over");
}
internal void set_score (Object game, ParamSpec unused)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]