[gnome-usage] window: Inline the header into the window
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-usage] window: Inline the header into the window
- Date: Thu, 25 Jun 2020 10:56:54 +0000 (UTC)
commit 387ac950149a31fdb963205bba65811e9eda2b65
Author: Adrien Plazas <kekun plazas laposte net>
Date: Wed Jun 24 17:47:19 2020 +0200
window: Inline the header into the window
This inlines Usage.HeaderBar into Usage.Window to make the code simpler.
This purposefully breaks the indentation in window.ui to limit the diff
in the next commit, making the changes easier to read.
data/meson.build | 1 -
data/org.gnome.Usage.gresource.xml | 1 -
data/ui/header-bar.ui | 59 ------------------
data/ui/window.ui | 52 ++++++++++++++++
po/POTFILES.in | 2 -
po/POTFILES.skip | 1 -
src/header-bar.vala | 121 -------------------------------------
src/meson.build | 1 -
src/window.vala | 68 ++++++++++++++++++---
9 files changed, 113 insertions(+), 193 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 9d95744..03b5f3c 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,7 +1,6 @@
resource_data = files(
'interface/adwaita.css',
'ui/primary-menu.ui',
- 'ui/header-bar.ui',
'ui/memory-speedometer.ui',
'ui/no-results-found-view.ui',
'ui/performance-view.ui',
diff --git a/data/org.gnome.Usage.gresource.xml b/data/org.gnome.Usage.gresource.xml
index b2b59a0..d980239 100644
--- a/data/org.gnome.Usage.gresource.xml
+++ b/data/org.gnome.Usage.gresource.xml
@@ -4,7 +4,6 @@
<file preprocess="xml-stripblanks">icons/hicolor/scalable/status/speedometer-symbolic.svg</file>
<file compressed="true">interface/adwaita.css</file>
<file preprocess="xml-stripblanks">ui/primary-menu.ui</file>
- <file preprocess="xml-stripblanks">ui/header-bar.ui</file>
<file preprocess="xml-stripblanks">ui/loading-notification.ui</file>
<file preprocess="xml-stripblanks">ui/memory-speedometer.ui</file>
<file preprocess="xml-stripblanks">ui/no-results-found-view.ui</file>
diff --git a/data/ui/window.ui b/data/ui/window.ui
index ca112a1..0653f78 100644
--- a/data/ui/window.ui
+++ b/data/ui/window.ui
@@ -8,6 +8,57 @@
<property name="title" translatable="yes">Usage</property>
<property name="visible">True</property>
<property name="window-position">center</property>
+ <child type="titlebar">
+ <object class="HdyHeaderBar" id="header_bar">
+ <property name="centering-policy">strict</property>
+ <property name="show-close-button">True</property>
+ <property name="visible">True</property>
+ <child type="title">
+ <object class="HdyViewSwitcherTitle" id="view_switcher_title">
+ <property name="stack">stack</property>
+ <property name="title" translatable="yes">Usage</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkMenuButton" id="primary_menu_button">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">open-menu-symbolic</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRevealer" id="performance_search_revealer">
+ <!-- This allows the button to take space even when it is concealed, keeping the header
bar's sizing homogeneous. -->
+ <property name="transition-duration">0</property>
+ <property name="transition-type">crossfade</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkToggleButton" id="performance_search_button">
+ <property name="visible">True</property>
+ <signal name="toggled" handler="on_performance_search_button_toggled"/>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">system-search-symbolic</property>
+ <property name="visible">True</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ </object>
+ </child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
@@ -23,6 +74,7 @@
</child>
<child>
<object class="HdyViewSwitcherBar" id="view_switcher_bar">
+ <property name="reveal" bind-source="view_switcher_title" bind-property="title-visible"
bind-flags="sync-create"/>
<property name="stack">stack</property>
<property name="visible">True</property>
</object>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index a45c400..c09292d 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -3,7 +3,6 @@
data/org.gnome.Usage.appdata.xml.in.in
data/org.gnome.Usage.desktop.in.in
data/org.gnome.Usage.gschema.xml.in
-data/ui/header-bar.ui
data/ui/memory-speedometer.ui
data/ui/no-results-found-view.ui
data/ui/performance-view.ui
@@ -18,7 +17,6 @@ src/app-item.vala
src/application.vala
src/cpu-sub-view.vala
src/graph-stack-switcher.vala
-src/header-bar.vala
src/memory-sub-view.vala
src/performance-view.vala
src/storage/storage-actionbar.vala
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 644c367..cc70df6 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -4,7 +4,6 @@ src/app-item.c
src/application.c
src/cpu-sub-view.c
src/graph-stack-switcher.c
-src/header-bar.c
src/memory-sub-view.c
src/performance-view.c
src/storage/storage-actionbar.c
diff --git a/src/meson.build b/src/meson.build
index b7f4c57..935e2d6 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -13,7 +13,6 @@ vala_sources = [
'graph-stacked-renderer.vala',
'graph-stack-switcher.vala',
'graph-switcher-button.vala',
- 'header-bar.vala',
'loading-notification.vala',
'memory-graph-model.vala',
'memory-graph.vala',
diff --git a/src/window.vala b/src/window.vala
index d6dfc3d..b31a1a3 100644
--- a/src/window.vala
+++ b/src/window.vala
@@ -27,13 +27,29 @@ namespace Usage
STORAGE,
}
+ public enum HeaderBarMode
+ {
+ PERFORMANCE,
+ STORAGE,
+ }
+
[GtkTemplate (ui = "/org/gnome/Usage/ui/window.ui")]
public class Window : Gtk.ApplicationWindow
{
[GtkChild]
private Gtk.Stack stack;
- private Usage.HeaderBar header_bar;
+ [GtkChild]
+ private Gtk.Revealer performance_search_revealer;
+
+ [GtkChild]
+ private Gtk.ToggleButton performance_search_button;
+
+ [GtkChild]
+ private Gtk.MenuButton primary_menu_button;
+
+ private HeaderBarMode mode;
+ private Usage.PrimaryMenu menu;
[GtkChild]
private Hdy.ViewSwitcherBar view_switcher_bar;
@@ -54,9 +70,11 @@ namespace Usage
load_css();
});
- header_bar = new Usage.HeaderBar(stack);
- set_titlebar(header_bar);
- header_bar.bind_property ("title-visible", view_switcher_bar, "reveal",
BindingFlags.SYNC_CREATE);
+ mode = HeaderBarMode.PERFORMANCE;
+ menu = new Usage.PrimaryMenu();
+ this.primary_menu_button.set_popover(menu);
+
+ set_mode(HeaderBarMode.PERFORMANCE);
views = new View[]
{
@@ -70,9 +88,39 @@ namespace Usage
}
}
+ public void set_mode(HeaderBarMode mode)
+ {
+ switch(this.mode)
+ {
+ case HeaderBarMode.PERFORMANCE:
+ performance_search_revealer.reveal_child = false;
+ break;
+ case HeaderBarMode.STORAGE:
+ break;
+ }
+
+ switch(mode)
+ {
+ case HeaderBarMode.PERFORMANCE:
+ performance_search_revealer.reveal_child = true;
+ break;
+ case HeaderBarMode.STORAGE:
+ break;
+ }
+ menu.mode = mode;
+ this.mode = mode;
+ }
+
public void action_on_search()
{
- header_bar.action_on_search();
+ switch(mode)
+ {
+ case HeaderBarMode.PERFORMANCE:
+ performance_search_button.set_active(!performance_search_button.get_active());
+ break;
+ case HeaderBarMode.STORAGE:
+ break;
+ }
}
public View[] get_views()
@@ -88,16 +136,22 @@ namespace Usage
Gtk.StyleContext.add_provider_for_screen(get_screen(), provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
+ [GtkCallback]
+ private void on_performance_search_button_toggled () {
+ /* TODO: Implement a saner way of toggling this mode. */
+ ((PerformanceView) (GLib.Application.get_default() as
Application).get_window().get_views()[Views.PERFORMANCE]).set_search_mode(performance_search_button.active);
+ }
+
[GtkCallback]
private void on_visible_child_changed()
{
if(stack.visible_child_name == views[Views.PERFORMANCE].name)
{
- header_bar.set_mode(HeaderBarMode.PERFORMANCE);
+ set_mode(HeaderBarMode.PERFORMANCE);
}
else if(stack.visible_child_name == views[Views.STORAGE].name)
{
- header_bar.set_mode(HeaderBarMode.STORAGE);
+ set_mode(HeaderBarMode.STORAGE);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]