[gnome-clocks/bilelmoussaoui/adaptive-headerbar] Switch between the HdySqueezer and HdyViewSwitcherBar on small size
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks/bilelmoussaoui/adaptive-headerbar] Switch between the HdySqueezer and HdyViewSwitcherBar on small size
- Date: Thu, 26 Sep 2019 13:13:16 +0000 (UTC)
commit 9de7739e20c423c0e8ef1d0e5e6bb38ce335544d
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Thu Sep 26 15:04:52 2019 +0200
Switch between the HdySqueezer and HdyViewSwitcherBar on small size
data/ui/window.ui | 35 ++++++++++++++++++++++++++++++++---
src/window.vala | 16 ++++++++++++++++
2 files changed, 48 insertions(+), 3 deletions(-)
---
diff --git a/data/ui/window.ui b/data/ui/window.ui
index 676beb0..f545ca1 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -95,12 +95,41 @@
</object>
</child>
<child>
- <object class="GtkStack" id="stack">
+ <object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="vexpand">True</property>
- <property name="hexpand">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkStack" id="stack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="HdyViewSwitcherBar" id="switcher_bar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stack">stack</property>
+ <property name="reveal">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
+
</child>
</template>
</interface>
diff --git a/src/window.vala b/src/window.vala
index bae6a67..bfadde6 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -37,7 +37,16 @@ public class Window : Gtk.ApplicationWindow {
[GtkChild]
private Gtk.Stack stack;
[GtkChild]
+ private Hdy.ViewSwitcherBar switcher_bar;
+ [GtkChild]
private Hdy.Squeezer squeezer;
+ [GtkChild]
+ private Hdy.ViewSwitcher title_wide_switcher;
+ [GtkChild]
+ private Hdy.ViewSwitcher title_narrow_switcher;
+ [GtkChild]
+ private Gtk.Box title_text;
+
[GtkChild]
private Gtk.MenuButton menu_button;
private GLib.Settings settings;
@@ -89,6 +98,13 @@ public class Window : Gtk.ApplicationWindow {
update_header_bar ();
});
+ this.size_allocate.connect((widget, allocation) => {
+ switcher_bar.set_reveal(allocation.width < 500);
+ squeezer.set_child_enabled(title_wide_switcher, allocation.width > 800);
+ squeezer.set_child_enabled(title_narrow_switcher, allocation.width > 500);
+ squeezer.set_child_enabled(title_text, allocation.width <= 500);
+ });
+
var header_bar_id = header_bar.notify["mode"].connect (() => {
update_header_bar ();
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]