[gnome-games] collection-header-bar: Use HdyViewSwitcherTitle
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] collection-header-bar: Use HdyViewSwitcherTitle
- Date: Thu, 12 Mar 2020 18:38:04 +0000 (UTC)
commit ae1d4df5f87f3b56c8713049b0f0defb767f0ab2
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Thu Mar 5 20:31:43 2020 +0500
collection-header-bar: Use HdyViewSwitcherTitle
Replace manual squeezer+view switcher with the new widget, this should
simplify the layout a bit.
data/ui/collection-header-bar.ui | 22 ++++------------------
src/ui/collection-header-bar.vala | 17 ++++-------------
2 files changed, 8 insertions(+), 31 deletions(-)
---
diff --git a/data/ui/collection-header-bar.ui b/data/ui/collection-header-bar.ui
index 4ef36d4f..73faac3a 100644
--- a/data/ui/collection-header-bar.ui
+++ b/data/ui/collection-header-bar.ui
@@ -61,25 +61,11 @@
</packing>
</child>
<child type="title">
- <object class="HdySqueezer" id="title_squeezer">
+ <object class="HdyViewSwitcherTitle" id="view_switcher_title">
<property name="visible">True</property>
- <property name="transition-type">crossfade</property>
- <signal name="notify::visible-child" handler="update_adaptive_state"/>
- <child>
- <object class="HdyViewSwitcher" id="view_switcher">
- <property name="visible">True</property>
- <property name="policy">wide</property>
- </object>
- </child>
- <child>
- <object class="GtkLabel">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Games</property>
- <style>
- <class name="title"/>
- </style>
- </object>
- </child>
+ <property name="title" translatable="yes">Games</property>
+ <property name="view-switcher-enabled" bind-source="GamesCollectionHeaderBar"
bind-property="is-collection-empty" bind-flags="bidirectional|sync-create|invert-boolean"/>
+ <signal name="notify::title-visible" handler="update_adaptive_state"/>
</object>
</child>
<child>
diff --git a/src/ui/collection-header-bar.vala b/src/ui/collection-header-bar.vala
index 0351b10e..685239a4 100644
--- a/src/ui/collection-header-bar.vala
+++ b/src/ui/collection-header-bar.vala
@@ -13,18 +13,11 @@ private class Games.CollectionHeaderBar : Gtk.Bin {
}
_viewstack = value;
- view_switcher.stack = _viewstack;
+ view_switcher_title.stack = _viewstack;
}
}
- private bool _is_collection_empty;
- public bool is_collection_empty {
- get { return _is_collection_empty; }
- set {
- _is_collection_empty = value;
- title_squeezer.set_child_enabled (view_switcher, !value);
- }
- }
+ public bool is_collection_empty { get; set; }
public bool is_folded { get; set; }
public bool is_showing_bottom_bar { get; set; }
@@ -39,9 +32,7 @@ private class Games.CollectionHeaderBar : Gtk.Bin {
[GtkChild]
private Hdy.HeaderBar subview_header_bar;
[GtkChild]
- private Hdy.Squeezer title_squeezer;
- [GtkChild]
- private Hdy.ViewSwitcher view_switcher;
+ private Hdy.ViewSwitcherTitle view_switcher_title;
private ulong viewstack_child_changed_id;
@@ -51,7 +42,7 @@ private class Games.CollectionHeaderBar : Gtk.Bin {
[GtkCallback]
private void update_adaptive_state () {
- bool showing_title = title_squeezer.visible_child != view_switcher;
+ bool showing_title = view_switcher_title.title_visible;
is_showing_bottom_bar = showing_title && !is_collection_empty;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]