Commit 4a491191 authored by Adrien Plazas's avatar Adrien Plazas
Browse files

Merge branch 'librem5-3-32-0' into pureos/sloppy

parents 00b8378e 711404e7
Pipeline #32949 canceled with stages
<svg xmlns="http://www.w3.org/2000/svg" width="16.011" height="16">
<g fill="#2e3436">
<path d="M8.017 1.001c-2.049 0-4.098.78-5.656 2.338-3.116 3.116-3.116 8.197 0 11.313a1 1 0 101.414-1.414 5.984 5.984 0 010-8.485 5.984 5.984 0 018.485 0 5.984 5.984 0 010 8.485 1 1 0 101.414 1.414c3.116-3.116 3.116-8.197 0-11.313a7.975 7.975 0 00-5.657-2.338z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;white-space:normal;shape-padding:0;isolation:auto;mix-blend-mode:normal;solid-color:#000;solid-opacity:1;marker:none" color="#000" font-weight="400" font-family="sans-serif" overflow="visible"/>
<path d="M10.017 8.995a2 2 0 01-2 2 2 2 0 01-2-2 2 2 0 012-2 2 2 0 012 2z"/>
<path d="M4.01 4.238a.75.75 0 00-.524 1.289l3 3A.751.751 0 107.55 7.464l-3-3a.75.75 0 00-.54-.226zM7.517 1.995v2h1v-2z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;white-space:normal;shape-padding:0;isolation:auto;mix-blend-mode:normal;solid-color:#000;solid-opacity:1" color="#000" font-weight="400" font-family="sans-serif" overflow="visible" fill-rule="evenodd"/>
<path d="M3.422 3.693l-.707.707 1.414 1.414.707-.707zM1.017 8.495v1h2v-1zM13.017 8.495v1h2v-1zM12.613 3.693L11.2 5.107l.707.707L13.32 4.4zM4.129 12.177l-1.414 1.414.707.707 1.414-1.414zM11.906 12.177l-.707.707 1.414 1.414.707-.707z" style="line-height:normal;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000;text-transform:none;text-orientation:mixed;white-space:normal;shape-padding:0;isolation:auto;mix-blend-mode:normal;solid-color:#000;solid-opacity:1" color="#000" font-weight="400" font-family="sans-serif" overflow="visible" fill-rule="evenodd"/>
</g>
</svg>
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/gnome/Usage">
<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>
......
......@@ -2,9 +2,10 @@
<interface>
<!-- interface-requires gtk+ 3.12 -->
<template class="UsageHeaderBar" parent="GtkHeaderBar">
<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="GtkStackSwitcher" id="stack_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>
......@@ -46,9 +63,13 @@
</child>
<child>
<object class="GtkButton" id="storage_rescan_button">
<object class="GtkRevealer" id="storage_rescan_revealer">
<property name="visible">False</property>
<property name="no-show-all">True</property>
<property name="reveal-child">True</property>
<child>
<object class="GtkButton" id="storage_rescan_button">
<property name="visible">true</property>
<signal name="clicked" handler="on_storage_rescan_button_clicked"/>
<child>
......@@ -58,6 +79,8 @@
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="pack-type">end</property>
</packing>
......
......@@ -7,13 +7,16 @@
<child>
<object class="GtkPaned" id="paned">
<object class="HdyLeaflet" id="leaflet">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="mode-transition-type">slide</property>
<property name="visible-child">content_box</property>
<child>
<object class="GtkBox" id="switcher_box">
<property name="visible">True</property>
<property name="hexpand">False</property>
<property name="hexpand-set">True</property>
<property name="width-request">200</property>
<style>
<class name="sidebar"/>
......@@ -22,19 +25,28 @@
</child>
<child>
<object class="GtkBox">
<object class="GtkBox" id="content_box">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="width-request">360</property>
<child>
<object class="GtkSearchBar" id="search_bar">
<property name="visible">True</property>
<object class="HdySearchBar" id="search_bar">
<property name="visible">True</property>
<child>
<object class="GtkSearchEntry" id="search_entry">
<object class="HdyColumn">
<property name="visible">True</property>
<property name="width-request">350</property>
<signal name="search-changed" handler="on_search_entry_changed"/>
<property name="hexpand">True</property>
<property name="maximum-width">400</property>
<property name="linear-growth-width">300</property>
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="visible">True</property>
<property name="hexpand">True</property>
<signal name="search-changed" handler="on_search_entry_changed"/>
</object>
</child>
</object>
</child>
</object>
......@@ -45,10 +57,20 @@
<property name="visible">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkBox" id="performance_content">
<object class="HdyColumn">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">30</property>
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="expand">True</property>
<property name="maximum-width">600</property>
<property name="linear-growth-width">400</property>
<child>
<object class="GtkBox" id="performance_content">
<property name="visible">True</property>
<property name="orientation">vertical</property>
<property name="spacing">30</property>
</object>
</child>
</object>
</child>
</object>
......
......@@ -3,7 +3,6 @@
<!-- interface-requires gtk+ 3.10 -->
<template class="UsageProcessRow" parent="GtkListBoxRow">
<property name="visible">True</property>
<property name="width-request">600</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
......
......@@ -18,23 +18,28 @@
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="no-show-all">True</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkPaned" id="paned">
<object class="HdyLeaflet" id="leaflet">
<property name="visible">True</property>
<property name="orientation">horizontal</property>
<property name="position">300</property>
<property name="mode-transition-type">slide</property>
<property name="visible-child">scrolled_window</property>
<child>
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="visible">True</property>
<property name="hexpand">False</property>
<property name="hexpand-set">True</property>
<property name="vexpand">True</property>
<property name="width-request">300</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkRevealer" id="revealer">
<property name="visible">True</property>
<property name="visible">False</property>
<property name="transition-type">slide-up</property>
<property name="transition-duration">400</property>
</object>
......
......@@ -13,10 +13,16 @@ gobject_dep = dependency('gobject-2.0')
gio_dep = dependency('gio-2.0')
gtk_dep = dependency('gtk+-3.0', version : '>=3.20.10')
libdazzle_dep = dependency('libdazzle-1.0', version : '>=3.30')
libhandy_dep = dependency('libhandy-0.0', version : '>=0.0.10')
gnome = import('gnome')
i18n = import('i18n')
add_project_arguments (
'-DHANDY_USE_UNSTABLE_API',
language: 'c'
)
po_dir = join_paths(meson.source_root(), 'po')
vapi_dir = join_paths (meson.source_root (), 'vapi')
......
......@@ -61,6 +61,9 @@ namespace Usage
base.startup();
add_action_entries(app_entries, this);
set_accels_for_action ("app.search", {"<Primary>f"});
var icon_theme = Gtk.IconTheme.get_default ();
icon_theme.add_resource_path ("/org/gnome/Usage/icons/hicolor");
}
private void on_about(GLib.SimpleAction action, GLib.Variant? parameter)
......
......@@ -38,7 +38,6 @@ namespace Usage
cpu_graph.hexpand = true;
var cpu_graph_box = new GraphBox(cpu_graph);
cpu_graph_box.height_request = 225;
cpu_graph_box.width_request = 600;
cpu_graph_box.valign = Gtk.Align.START;
process_list_box = new ProcessListBox(ProcessListBoxType.PROCESSOR);
......@@ -53,7 +52,6 @@ namespace Usage
no_process_view = new NoResultsFoundView();
var cpu_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
cpu_box.halign = Gtk.Align.CENTER;
cpu_box.pack_start(label, false, false, 0);
cpu_box.pack_start(cpu_graph_box, false, false, 0);
cpu_box.pack_start(spinner, true, true, 0);
......
......@@ -25,6 +25,8 @@ public static int main (string[] args)
Intl.textdomain(Config.GETTEXT_PACKAGE);
Intl.bind_textdomain_codeset(Config.GETTEXT_PACKAGE, "utf-8");
Hdy.init(ref args);
var application = new Usage.Application();
return application.run(args);
}
......@@ -29,10 +29,16 @@ namespace Usage
}
[GtkTemplate (ui = "/org/gnome/Usage/ui/header-bar.ui")]
public class HeaderBar : Gtk.HeaderBar
public class HeaderBar : Hdy.HeaderBar
{
[GtkChild]
private Gtk.StackSwitcher stack_switcher;
private Hdy.Squeezer squeezer;
[GtkChild]
private Hdy.ViewSwitcher view_switcher;
[GtkChild]
private Gtk.Label title_label;
[GtkChild]
private Gtk.ToggleButton performance_search_button;
......@@ -41,7 +47,7 @@ namespace Usage
private Gtk.Button storage_back_button;
[GtkChild]
private Gtk.Button storage_rescan_button;
private Gtk.Revealer storage_rescan_revealer;
[GtkChild]
private Gtk.Button storage_select_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 },
......@@ -66,12 +74,16 @@ namespace Usage
{
mode = HeaderBarMode.PERFORMANCE;
menu = new Usage.PrimaryMenu();
stack_switcher.set_stack(stack);
view_switcher.set_stack(stack);
this.primary_menu_button.set_popover(menu);
set_mode(HeaderBarMode.PERFORMANCE);
}
construct {
update_view_switcher_visible ();
}
public void set_mode(HeaderBarMode mode)
{
switch(this.mode)
......@@ -81,7 +93,7 @@ namespace Usage
break;
case HeaderBarMode.STORAGE:
storage_back_button.hide ();
storage_rescan_button.hide ();
storage_rescan_revealer.hide ();
storage_select_button.hide ();
storage_cancel_button.hide ();
break;
......@@ -90,17 +102,17 @@ namespace Usage
switch(mode)
{
case HeaderBarMode.PERFORMANCE:
show_stack_switcher();
show_view_switcher();
performance_search_button.show();
break;
case HeaderBarMode.STORAGE:
if(title_text == "")
show_stack_switcher();
show_view_switcher();
else
show_title();
storage_rescan_button.show ();
storage_select_button.show ();
storage_rescan_revealer.show ();
storage_select_button.hide ();
break;
}
......@@ -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. */
......@@ -121,10 +142,10 @@ namespace Usage
[GtkCallback]
private void on_storage_rescan_button_clicked () {
stack_switcher.show ();
view_switcher.show ();
storage_select_button.hide ();
storage_rescan_button.hide ();
storage_rescan_revealer.reveal_child = false;
storage_back_button.hide ();
StorageAnalyzer.get_default().create_cache.begin(true);
......@@ -159,33 +180,36 @@ 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_stack_switcher()
public void show_view_switcher()
{
set_custom_title(stack_switcher);
squeezer.set_child_enabled(view_switcher, true);
}
public void show_storage_back_button(bool show)
{
show &= mode == HeaderBarMode.STORAGE;
storage_back_button.visible = show;
}
public void show_storage_rescan_button(bool show)
{
storage_rescan_button.visible = show;
storage_rescan_revealer.reveal_child = show;
}
public void show_storage_select_button(bool show)
{
storage_select_button.visible = show;
show &= mode == HeaderBarMode.STORAGE;
storage_select_button.visible = false;
}
public void action_on_search()
......@@ -204,7 +228,7 @@ namespace Usage
{
if(show)
{
storage_rescan_button.hide ();
storage_rescan_revealer.hide ();
storage_select_button.hide ();
storage_back_button.hide();
storage_cancel_button.show();
......@@ -238,12 +262,12 @@ namespace Usage
{
storage_back_button.show ();
storage_rescan_button.show ();
storage_select_button.show ();
storage_rescan_revealer.show ();
storage_select_button.hide ();
storage_cancel_button.hide();
storage_selection_menu = null;
if(title_text == "")
show_stack_switcher();
show_view_switcher();
else
show_title();
((StorageView) (GLib.Application.get_default() as Application).get_window().get_views()[Views.STORAGE]).show_action_bar(false);
......
......@@ -50,7 +50,6 @@ namespace Usage
speedometers.margin_top = 30;
var memory_box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
memory_box.halign = Gtk.Align.CENTER;
memory_box.pack_start(speedometers, false, false, 0);
memory_box.pack_start(spinner, true, true, 0);
memory_box.add(no_process_view);
......
......@@ -51,6 +51,7 @@ deps = [
gtk_dep,
dependency('libgtop-2.0', version : '>= 2.34.0'),
libdazzle_dep,
libhandy_dep,
cc.find_library('m'),
valac.find_library('config', dirs: vapi_dir),
valac.find_library('posix')
......
......@@ -32,7 +32,7 @@ namespace Usage
private Gtk.Box performance_content;
[GtkChild]
private Gtk.SearchBar search_bar;
private Hdy.SearchBar search_bar;
[GtkChild]
private Gtk.SearchEntry search_entry;
......@@ -46,6 +46,7 @@ namespace Usage
{
name = "PERFORMANCE";
title = _("Performance");
icon_name = "speedometer-symbolic";
sub_views = new View[]
{
......
......@@ -90,7 +90,7 @@ namespace Usage
{
(GLib.Application.get_default() as Application).get_window().get_header_bar().show_storage_back_button(false);
(GLib.Application.get_default() as Application).get_window().get_header_bar().set_title_text("");
(GLib.Application.get_default() as Application).get_window().get_header_bar().show_stack_switcher();
(GLib.Application.get_default() as Application).get_window().get_header_bar().show_view_switcher();
}
else
{
......
......@@ -37,19 +37,24 @@ namespace Usage
private Gtk.ScrolledWindow scrolled_window;
[GtkChild]
private Gtk.Paned paned;
private Hdy.Leaflet leaflet;
public StorageView ()
{
name = "STORAGE";
title = _("Storage");
icon_name = "drive-harddisk-symbolic";
/* It would be nice being able to this in the template file. */
storage_list_box = new StorageListBox();
scrolled_window.add(storage_list_box);
var graph = new StorageGraph();
paned.add2(graph);
graph.hexpand = true;
graph.vexpand = true;
graph.width_request = 300;
graph.show();
leaflet.add(graph);
action_bar = new StorageActionBar();
revealer.add(action_bar);
......@@ -82,8 +87,6 @@ namespace Usage
public void show_action_bar(bool show)
{
revealer.set_reveal_child(show);
action_bar.hide_all();
}
}
}
......@@ -23,6 +23,7 @@ namespace Usage
public abstract class View : Gtk.Bin
{
public string title;
public string icon_name;
protected View ()
{
......
......@@ -29,6 +29,7 @@ namespace Usage
public class Window : Gtk.ApplicationWindow
{
private Usage.HeaderBar header_bar;
private Hdy.ViewSwitcherBar viewswitcher_bar;
private View[] views;
public Window(Gtk.Application application)
......@@ -36,7 +37,6 @@ namespace Usage
GLib.Object(application : application);
this.set_default_size(950, 600);
this.set_size_request(930, 300);
this.window_position = Gtk.WindowPosition.CENTER;
this.set_title(_("Usage"));
......@@ -47,8 +47,12 @@ namespace Usage
});
var stack = new Gtk.Stack();
stack.vexpand = true;
header_bar = new Usage.HeaderBar(stack);
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[]
{
......@@ -56,8 +60,10 @@ namespace Usage
new StorageView(),
};
foreach(var view in views)
foreach(var view in views) {
stack.add_titled(view, view.name, view.title);
stack.child_set (view, "icon-name", view.icon_name, null);
}
stack.notify.connect(() => {
if(stack.visible_child_name == views[Views.PERFORMANCE].name)
......@@ -71,7 +77,10 @@ namespace Usage
}
});
this.add(stack);
var box = new Gtk.Box(Gtk.Orientation.VERTICAL, 0);
box.add(stack);
box.add(viewswitcher_bar);
this.add(box);
}
public Usage.HeaderBar get_header_bar()
......
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