Commit 350236c3 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

Add a HdySqueezer to move the view switcher to the bottom of the window

parent 3e6d9c41
......@@ -5,6 +5,7 @@
<template class="UsageHeaderBar" parent="HdyHeaderBar">
<property name="visible">False</property>
<property name="show-close-button">True</property>
<property name="centering-policy">strict</property>
<child>
<object class="GtkButton" id="storage_back_button">
......@@ -25,8 +26,24 @@
</child>
<child type="title">
<object class="HdyViewSwitcher" id="view_switcher">
<object class="HdySqueezer" id="squeezer">
<property name="visible">True</property>
<property name="transition-type">crossfade</property>
<signal name="notify::visible-child" handler="on_squeezer_visible_child_changed"/>
<child>
<object class="HdyViewSwitcher" id="view_switcher">
<property name="visible">True</property>
</object>
</child>
<child>
<object class="GtkLabel" id="title_label">
<property name="visible">True</property>
<property name="label" translatable="yes">Usage</property>
<style>
<class name="title"/>
</style>
</object>
</child>
</object>
</child>
......
......@@ -31,9 +31,15 @@ namespace Usage
[GtkTemplate (ui = "/org/gnome/Usage/ui/header-bar.ui")]
public class HeaderBar : Hdy.HeaderBar
{
[GtkChild]
private Hdy.Squeezer squeezer;
[GtkChild]
private Hdy.ViewSwitcher view_switcher;
[GtkChild]
private Gtk.Label title_label;
[GtkChild]
private Gtk.ToggleButton performance_search_button;
......@@ -57,6 +63,8 @@ namespace Usage
private HeaderBarMode mode;
private Usage.PrimaryMenu menu;
public bool view_switcher_visible { get; private set; }
const GLib.ActionEntry[] select_action_entries = {
{ "select-all", select_all },
{ "select-none", select_none },
......@@ -72,6 +80,10 @@ namespace Usage
set_mode(HeaderBarMode.PERFORMANCE);
}
construct {
update_view_switcher_visible ();
}
public void set_mode(HeaderBarMode mode)
{
switch(this.mode)
......@@ -108,6 +120,15 @@ namespace Usage
this.mode = mode;
}
private void update_view_switcher_visible () {
view_switcher_visible = squeezer.visible_child == view_switcher;
}
[GtkCallback]
private void on_squeezer_visible_child_changed () {
update_view_switcher_visible ();
}
[GtkCallback]
private void on_performance_search_button_toggled () {
/* TODO: Implement a saner way of toggling this mode. */
......@@ -159,18 +180,19 @@ namespace Usage
public void show_title()
{
set_custom_title(null);
squeezer.set_child_enabled(view_switcher, false);
set_title(title_text);
}
public void set_title_text(string title)
{
this.title_text = title;
title_label.label = title;
}
public void show_view_switcher()
{
set_custom_title(view_switcher);
squeezer.set_child_enabled(view_switcher, true);
}
public void show_storage_back_button(bool show)
......
......@@ -52,6 +52,7 @@ namespace Usage
set_titlebar(header_bar);
viewswitcher_bar = new Hdy.ViewSwitcherBar();
viewswitcher_bar.stack = stack;
header_bar.bind_property ("view-switcher-visible", viewswitcher_bar, "reveal", BindingFlags.SYNC_CREATE | BindingFlags.INVERT_BOOLEAN);
views = new View[]
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment