[gnome-taquin/arnaudb/wip/gtk4: 39/56] GtkHeaderBar is not subclassable anymore.
- From: Arnaud B. <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-taquin/arnaudb/wip/gtk4: 39/56] GtkHeaderBar is not subclassable anymore.
- Date: Wed, 30 Sep 2020 13:55:33 +0000 (UTC)
commit 5c6ffa1b4e32410888e0731fee49679ab63c04b6
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sun Apr 19 13:09:03 2020 +0200
GtkHeaderBar is not subclassable anymore.
data/ui/base-headerbar.ui | 144 +++++++++++++++++++++++----------------------
data/ui/game-headerbar.ui | 74 ++++++++++++-----------
src/adaptative-window.vala | 2 +-
src/base-headerbar.vala | 8 ++-
src/game-headerbar.vala | 2 +-
5 files changed, 121 insertions(+), 109 deletions(-)
---
diff --git a/data/ui/base-headerbar.ui b/data/ui/base-headerbar.ui
index a0fcb69..f59e4b7 100644
--- a/data/ui/base-headerbar.ui
+++ b/data/ui/base-headerbar.ui
@@ -18,82 +18,86 @@
<interface>
<requires lib="gtk+" version="3.99"/>
<template class="BaseHeaderBar" parent="NightTimeAwareHeaderBar">
- <property name="show-title-buttons">True</property>
- <property name="has-subtitle">False</property>
- <child type="start">
- <object class="GtkButton" id="go_back_button">
- <property name="visible">False</property>
- <property name="valign">center</property>
- <property name="action-name">base.show-default-view</property>
- <property name="icon-name">go-previous-symbolic</property> <!-- TODO 3/3 dialog-information-symbolic
-->
- <style>
- <class name="image-button"/>
- </style>
- </object>
- </child>
- <child type="start">
- <object class="GtkSeparator" id="ltr_left_separator">
- <property name="visible">False</property>
- </object>
- </child>
- <child type="title">
- <object class="GtkBox" id="center_box">
- <property name="spacing">6</property>
- <property name="hexpand">False</property> <!-- or "hexpand-set">true... that's horrible -->
- <style>
- <class name="centerwidget"/>
- </style>
- <child>
- <object class="GtkLabel" id="title_label">
+ <child>
+ <object class="GtkHeaderBar" id="headerbar">
+ <property name="show-title-buttons">True</property>
+ <property name="has-subtitle">False</property>
+ <child type="start">
+ <object class="GtkButton" id="go_back_button">
<property name="visible">False</property>
+ <property name="valign">center</property>
+ <property name="action-name">base.show-default-view</property>
+ <property name="icon-name">go-previous-symbolic</property> <!-- TODO 3/3
dialog-information-symbolic -->
+ <style>
+ <class name="image-button"/>
+ </style>
</object>
</child>
- </object>
- </child>
- <child type="end">
- <object class="GtkStack" id="quit_button_stack">
- <property name="visible">False</property>
- <child>
- <object class="GtkStackPage">
- <property name="name">quit-button</property>
- <property name="child">
- <object class="GtkButton">
- <property name="valign">center</property>
- <property name="action-name">app.quit</property>
- <property name="icon-name">window-close-symbolic</property>
- <style>
- <class name="titlebutton"/>
- <class name="close"/>
- </style>
+ <child type="start">
+ <object class="GtkSeparator" id="ltr_left_separator">
+ <property name="visible">False</property>
+ </object>
+ </child>
+ <child type="title">
+ <object class="GtkBox" id="center_box">
+ <property name="spacing">6</property>
+ <property name="hexpand">False</property> <!-- or "hexpand-set">true... that's horrible -->
+ <style>
+ <class name="centerwidget"/>
+ </style>
+ <child>
+ <object class="GtkLabel" id="title_label">
+ <property name="visible">False</property>
</object>
- </property>
+ </child>
</object>
</child>
- </object>
- </child>
- <child type="end">
- <object class="GtkSeparator" id="ltr_right_separator">
- <property name="visible">False</property>
- <property name="orientation">vertical</property>
- <style>
- <class name="titlebutton"/>
- </style>
- </object>
- </child>
- <child type="end">
- <object class="GtkMenuButton" id="info_button">
- <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>
- <child internal-child="accessible">
- <object class="AtkObject">
- <!-- Translators: accessible name of the hamburger menu -->
- <property name="AtkObject::accessible-name" translatable="yes">Actions</property>
- <!-- Translators: accessible description of the hamburger menu -->
- <property name="AtkObject::accessible-description" translatable="yes">Current view
actions</property>
+ <child type="end">
+ <object class="GtkStack" id="quit_button_stack">
+ <property name="visible">False</property>
+ <child>
+ <object class="GtkStackPage">
+ <property name="name">quit-button</property>
+ <property name="child">
+ <object class="GtkButton">
+ <property name="valign">center</property>
+ <property name="action-name">app.quit</property>
+ <property name="icon-name">window-close-symbolic</property>
+ <style>
+ <class name="titlebutton"/>
+ <class name="close"/>
+ </style>
+ </object>
+ </property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkSeparator" id="ltr_right_separator">
+ <property name="visible">False</property>
+ <property name="orientation">vertical</property>
+ <style>
+ <class name="titlebutton"/>
+ </style>
+ </object>
+ </child>
+ <child type="end">
+ <object class="GtkMenuButton" id="info_button">
+ <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>
+ <child internal-child="accessible">
+ <object class="AtkObject">
+ <!-- Translators: accessible name of the hamburger menu -->
+ <property name="AtkObject::accessible-name" translatable="yes">Actions</property>
+ <!-- Translators: accessible description of the hamburger menu -->
+ <property name="AtkObject::accessible-description" translatable="yes">Current view
actions</property>
+ </object>
+ </child>
</object>
</child>
</object>
diff --git a/data/ui/game-headerbar.ui b/data/ui/game-headerbar.ui
index 066cfa0..c4c5035 100644
--- a/data/ui/game-headerbar.ui
+++ b/data/ui/game-headerbar.ui
@@ -18,46 +18,50 @@
<interface>
<requires lib="gtk+" version="3.99"/>
<template class="GameHeaderBar" parent="BaseHeaderBar">
- <property name="show-title-buttons">True</property>
- <child>
- <object class="GtkButton" id="new_game_button">
- <property name="visible">False</property>
- <property name="halign">center</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>
- <style>
- <class name="text-button"/>
- <class name="new-game-button"/>
- </style>
+ <child internal-child="headerbar">
+ <object class="GtkHeaderBar">
+ <property name="show-title-buttons">True</property>
<child>
- <!-- for ellipsizing, if the text shows a moves count that can grow -->
- <object class="GtkLabel">
- <!-- 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="ellipsize">end</property>
- <property name="mnemonic-widget">new_game_button</property>
+ <object class="GtkButton" id="new_game_button">
+ <property name="visible">False</property>
+ <property name="halign">center</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>
+ <style>
+ <class name="text-button"/>
+ <class name="new-game-button"/>
+ </style>
+ <child>
+ <!-- for ellipsizing, if the text shows a moves count that can grow -->
+ <object class="GtkLabel">
+ <!-- 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="ellipsize">end</property>
+ <property name="mnemonic-widget">new_game_button</property>
+ <property name="use-underline">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="back_button">
+ <property name="visible">False</property>
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <!-- Translators: when configuring a new game, if the user has a started game, tooltip text of
the Go back button -->
+ <property name="tooltip-text" translatable="yes">Go back to the current game</property>
<property name="use-underline">True</property>
+ <property name="action-name">base.escape</property>
+ <property name="focus-on-click">False</property>
+ <property name="icon-name">go-previous-symbolic</property>
+ <style>
+ <class name="image-button"/>
+ </style>
</object>
</child>
</object>
</child>
- <child>
- <object class="GtkButton" id="back_button">
- <property name="visible">False</property>
- <property name="halign">center</property>
- <property name="valign">center</property>
- <!-- Translators: when configuring a new game, if the user has a started game, tooltip text of the
Go back button -->
- <property name="tooltip-text" translatable="yes">Go back to the current game</property>
- <property name="use-underline">True</property>
- <property name="action-name">base.escape</property>
- <property name="focus-on-click">False</property>
- <property name="icon-name">go-previous-symbolic</property>
- <style>
- <class name="image-button"/>
- </style>
- </object>
- </child>
</template>
</interface>
diff --git a/src/adaptative-window.vala b/src/adaptative-window.vala
index d99cd98..bb60aa0 100644
--- a/src/adaptative-window.vala
+++ b/src/adaptative-window.vala
@@ -68,7 +68,7 @@ private interface AdaptativeWidget : Object
internal abstract void set_window_size (WindowSize new_size);
}
-private abstract class NightTimeAwareHeaderBar : HeaderBar
+private abstract class NightTimeAwareHeaderBar : Widget
{
private bool night_time = false; // no need to use NightTime here (that allows an "Unknown"
value)
private bool dark_theme = false;
diff --git a/src/base-headerbar.vala b/src/base-headerbar.vala
index 4d6bc5a..cdd1ce0 100644
--- a/src/base-headerbar.vala
+++ b/src/base-headerbar.vala
@@ -20,10 +20,14 @@ using Gtk;
[GtkTemplate (ui = "/org/gnome/Taquin/ui/base-headerbar.ui")]
private class BaseHeaderBar : NightTimeAwareHeaderBar, AdaptativeWidget
{
+ [GtkChild (internal = true)] protected HeaderBar headerbar;
[GtkChild] protected Box center_box;
construct
{
+ BinLayout layout = new BinLayout ();
+ set_layout_manager (layout);
+
center_box.valign = Align.FILL;
register_modes ();
@@ -49,7 +53,7 @@ private class BaseHeaderBar : NightTimeAwareHeaderBar, AdaptativeWidget
disable_action_bar = _disable_action_bar;
if (disable_action_bar)
{
- set_show_title_buttons (false);
+ headerbar.set_show_title_buttons (false);
quit_button_stack.show ();
ltr_right_separator.visible = current_mode_id == default_mode_id;
}
@@ -57,7 +61,7 @@ private class BaseHeaderBar : NightTimeAwareHeaderBar, AdaptativeWidget
{
ltr_right_separator.hide ();
quit_button_stack.hide ();
- set_show_title_buttons (true);
+ headerbar.set_show_title_buttons (true);
}
}
diff --git a/src/game-headerbar.vala b/src/game-headerbar.vala
index 94fb7de..e6e9d8e 100644
--- a/src/game-headerbar.vala
+++ b/src/game-headerbar.vala
@@ -41,7 +41,7 @@ private class GameHeaderBar : BaseHeaderBar, AdaptativeWidget
window_has_name = true;
if (game_widget != null)
- pack_end ((!) game_widget);
+ headerbar.pack_end ((!) game_widget);
}
internal GameHeaderBar (string _window_name,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]