libsysprof-ui: use adwaita rows for assistant

This isn't exactly ideal in our use, but it's transitionary so that we
can get rid of the EggThreeGrid which is very out of place in a libadwaita
world.
This commit is contained in:
Christian Hergert
2022-07-11 12:55:12 -07:00
parent dd7d080642
commit c6ae3221a1
2 changed files with 219 additions and 488 deletions

View File

@ -22,6 +22,7 @@
#include "config.h"
#include <adwaita.h>
#include <sysprof.h>
#include "egg-three-grid.h"
@ -54,16 +55,14 @@ struct _SysprofProfilerAssistant
/* Template Objects */
GtkSwitch *allow_throttling;
GtkButton *record_button;
GtkEntry *command_line;
AdwEntryRow *command_line;
GtkSearchEntry *search_entry;
GtkRevealer *process_revealer;
GtkListBox *process_list_box;
SysprofEnvironEditor *environ_editor;
GtkFlowBox *aid_flow_box;
GtkSwitch *whole_system_switch;
GtkSwitch *launch_switch;
GtkSwitch *inherit_switch;
GtkWidget *scroller;
};
enum {
@ -114,12 +113,15 @@ create_process_row_cb (gpointer item_,
}
static void
sysprof_profiler_assistant_notify_reveal_child_cb (SysprofProfilerAssistant *self,
GParamSpec *pspec,
GtkRevealer *revealer)
sysprof_profiler_assistant_notify_active_cb (SysprofProfilerAssistant *self,
GParamSpec *pspec,
GtkSwitch *switch_)
{
g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self));
g_assert (GTK_IS_REVEALER (revealer));
g_assert (GTK_IS_SWITCH (switch_));
if (gtk_switch_get_active (switch_))
return;
if (self->process_model == NULL)
{
@ -155,7 +157,7 @@ sysprof_profiler_assistant_command_line_changed_cb (SysprofProfilerAssistant *se
gint argc;
g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self));
g_assert (GTK_IS_ENTRY (entry));
g_assert (ADW_IS_ENTRY_ROW (entry));
style_context = gtk_widget_get_style_context (GTK_WIDGET (entry));
text = gtk_editable_get_text (GTK_EDITABLE (entry));
@ -314,13 +316,13 @@ filter_by_search_text (GObject *object,
static void
sysprof_profiler_assistant_search_changed_cb (SysprofProfilerAssistant *self,
GtkSearchEntry *search_entry)
GtkEditable *search_entry)
{
g_autoptr(SysprofModelFilter) filter = NULL;
const gchar *text;
const char *text;
g_assert (SYSPROF_IS_PROFILER_ASSISTANT (self));
g_assert (GTK_IS_SEARCH_ENTRY (search_entry));
g_assert (GTK_IS_EDITABLE (search_entry));
if (self->process_model == NULL)
return;
@ -353,9 +355,12 @@ static void
sysprof_profiler_assistant_dispose (GObject *object)
{
SysprofProfilerAssistant *self = (SysprofProfilerAssistant *)object;
GtkWidget *child;
g_clear_object (&self->process_model);
g_clear_pointer (&self->scroller, gtk_widget_unparent);
while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
gtk_widget_unparent (child);
G_OBJECT_CLASS (sysprof_profiler_assistant_parent_class)->dispose (object);
}
@ -390,13 +395,11 @@ sysprof_profiler_assistant_class_init (SysprofProfilerAssistantClass *klass)
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, command_line);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, environ_editor);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_list_box);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, process_revealer);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, record_button);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, whole_system_switch);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, launch_switch);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, inherit_switch);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, search_entry);
gtk_widget_class_bind_template_child (widget_class, SysprofProfilerAssistant, scroller);
g_type_ensure (EGG_TYPE_THREE_GRID);
@ -439,9 +442,9 @@ sysprof_profiler_assistant_init (SysprofProfilerAssistant *self)
self,
G_CONNECT_SWAPPED);
g_signal_connect_object (self->process_revealer,
"notify::reveal-child",
G_CALLBACK (sysprof_profiler_assistant_notify_reveal_child_cb),
g_signal_connect_object (self->whole_system_switch,
"notify::active",
G_CALLBACK (sysprof_profiler_assistant_notify_active_cb),
self,
G_CONNECT_SWAPPED);

View File

@ -63,468 +63,212 @@
</object>
<template class="SysprofProfilerAssistant" parent="GtkWidget">
<child>
<object class="GtkScrolledWindow" id="scroller">
<property name="propagate-natural-width">true</property>
<property name="propagate-natural-height">true</property>
<property name="hscrollbar-policy">never</property>
<property name="visible">true</property>
<object class="AdwPreferencesPage">
<child>
<object class="GtkBox">
<property name="margin-top">36</property>
<property name="margin-bottom">36</property>
<property name="margin-start">36</property>
<property name="margin-end">36</property>
<property name="spacing">12</property>
<property name="orientation">vertical</property>
<property name="visible">true</property>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Profiling Target</property>
<child>
<object class="EggThreeGrid" id="three_grid">
<property name="column-spacing">12</property>
<property name="row-spacing">6</property>
<property name="visible">true</property>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="visible">true</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Profilers</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="0.83333"/>
</attributes>
</object>
</child>
<child>
<object class="GtkFlowBox" id="aid_flow_box">
<property name="activate-on-single-click">true</property>
<property name="column-spacing">24</property>
<property name="row-spacing">12</property>
<property name="max-children-per-line">4</property>
<property name="min-children-per-line">4</property>
<property name="halign">fill</property>
<property name="homogeneous">true</property>
<property name="selection-mode">single</property>
<property name="margin-top">12</property>
<property name="margin-bottom">24</property>
<property name="visible">true</property>
<child>
<object class="SysprofAidIcon">
<property name="aid">callgraph_aid</property>
<property name="selected">true</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">cpu_aid</property>
<property name="selected">true</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">memory_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">mutter_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">gjs_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">app_aid</property>
<property name="selected">true</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">rapl_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">battery_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">network_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">diskstat_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="tooltip-text" translatable="yes">Track application memory allocations (Sysprof must launch target application)</property>
<property name="aid">memprof_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="tooltip-text" translatable="yes">Track slow operations on your applications main loop</property>
<property name="aid">speedtrack_aid</property>
<property name="selected">false</property>
<property name="visible">true</property>
</object>
</child>
</object>
</child>
<layout>
<property name="column">center</property>
<property name="row">5</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="label" translatable="yes">All Processes</property>
<property name="xalign">1.0</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">left</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="AdwExpanderRow" id="whole_system_row">
<property name="title" translatable="yes">Profile Entire System</property>
<property name="subtitle" translatable="yes">Sysprof can generate callgraphs for one or more processes on your system.</property>
<property name="expanded" bind-source="whole_system_switch" bind-property="active" bind-flags="invert-boolean|bidirectional|sync-create"/>
<child type="action">
<object class="GtkSwitch" id="whole_system_switch">
<property name="active">true</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="visible">true</property>
<layout>
<property name="column">center</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="visible">true</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Include all applications and operating system kernel in callgraph. This may not be possible on some system configurations.</property>
<property name="margin-bottom">6</property>
<property name="max-width-chars">10</property>
<property name="wrap">true</property>
<property name="visible">true</property>
<property name="xalign">0.0</property>
<attributes>
<attribute name="scale" value="0.8333"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkRevealer" id="process_revealer">
<property name="reveal-child" bind-source="whole_system_switch" bind-property="active" bind-flags="sync-create|invert-boolean"/>
<property name="visible">true</property>
<child>
<object class="GtkBox">
<property name="margin-bottom">12</property>
<property name="orientation">vertical</property>
<property name="visible">true</property>
<style>
<class name="linked"/>
</style>
<child>
<object class="GtkSearchEntry" id="search_entry">
<property name="placeholder-text" translatable="yes">Search Processes…</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">175</property>
<property name="max-content-height">175</property>
<property name="visible">true</property>
<child>
<object class="GtkListBox" id="process_list_box">
<property name="selection-mode">none</property>
<property name="visible">true</property>
<child type="placeholder">
<object class="GtkLabel">
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="label" translatable="yes">Loading Processes…</property>
<property name="valign">center</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<layout>
<property name="column">center</property>
<property name="row">1</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="label" translatable="yes">Launch Application</property>
<property name="xalign">1.0</property>
<property name="valign">start</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">left</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="width-request">500</property>
<property name="valign">start</property>
<property name="visible">true</property>
<child>
<object class="GtkSwitch" id="launch_switch">
<property name="active">false</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Enable to launch a program of your choosing before profiling.</property>
<property name="margin-top">6</property>
<property name="margin-bottom">6</property>
<property name="max-width-chars">10</property>
<property name="wrap">true</property>
<property name="visible">true</property>
<property name="xalign">0.0</property>
<attributes>
<attribute name="scale" value="0.8333"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkRevealer" id="launch_revealer">
<property name="reveal-child" bind-source="launch_switch" bind-property="active" bind-flags="sync-create"/>
<property name="visible">true</property>
<child>
<object class="GtkBox">
<property name="margin-top">6</property>
<property name="spacing">6</property>
<property name="margin-bottom">12</property>
<property name="orientation">vertical</property>
<property name="visible">true</property>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Command Line</property>
<property name="xalign">0.0</property>
<property name="visible">true</property>
<attributes>
<attribute name="scale" value="0.8333"/>
<attribute name="weight" value="bold"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkEntry" id="command_line">
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Environment</property>
<property name="margin-top">12</property>
<property name="xalign">0.0</property>
<property name="visible">true</property>
<attributes>
<attribute name="scale" value="0.8333"/>
<attribute name="weight" value="bold"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkFrame">
<property name="visible">true</property>
<child>
<object class="SysprofEnvironEditor" id="environ_editor">
<property name="visible">true</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Inherit Environment</property>
<property name="margin-top">12</property>
<property name="max-width-chars">10</property>
<property name="wrap">true</property>
<property name="visible">true</property>
<property name="xalign">0.0</property>
<attributes>
<attribute name="scale" value="0.8333"/>
<attribute name="weight" value="bold"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<child>
<object class="GtkSwitch" id="inherit_switch">
<property name="active">true</property>
<property name="halign">start</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">Enable to ensure your application shares the display, message-bus, and other desktop environment settings.</property>
<property name="margin-bottom">12</property>
<property name="max-width-chars">10</property>
<property name="wrap">true</property>
<property name="visible">true</property>
<property name="xalign">0.0</property>
<attributes>
<attribute name="scale" value="0.8333"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
<layout>
<property name="column">center</property>
<property name="row">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="label" translatable="yes">Allow CPU Throttling</property>
<property name="xalign">1.0</property>
<property name="valign">start</property>
<property name="visible">true</property>
<style>
<class name="dim-label"/>
</style>
<layout>
<property name="column">left</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="visible">true</property>
<child>
<object class="GtkSwitch" id="allow_throttling">
<property name="active">true</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="visible">true</property>
</object>
</child>
<child>
<object class="GtkLabel">
<property name="label" translatable="yes">If disabled, your CPU will be placed in performance mode. It will be restored after profiling.</property>
<property name="max-width-chars">10</property>
<property name="wrap">true</property>
<property name="visible">true</property>
<property name="xalign">0.0</property>
<attributes>
<attribute name="scale" value="0.8333"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
<layout>
<property name="column">center</property>
<property name="row">3</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="record_button">
<property name="label" translatable="yes">_Record</property>
<property name="use-underline">true</property>
<property name="halign">end</property>
<property name="width-request">125</property>
<property name="visible">true</property>
<property name="margin-top">24</property>
<property name="margin-bottom">12</property>
<style>
<class name="suggested-action"/>
</style>
<layout>
<property name="column">center</property>
<property name="row">4</property>
</layout>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="AdwEntryRow" id="search_entry">
<property name="title" translatable="yes">Search Processes</property>
</object>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="hscrollbar-policy">never</property>
<property name="min-content-height">175</property>
<property name="max-content-height">175</property>
<child>
<object class="GtkListBox" id="process_list_box">
<property name="selection-mode">none</property>
<child type="placeholder">
<object class="GtkLabel">
<property name="margin-start">12</property>
<property name="margin-end">12</property>
<property name="label" translatable="yes">Loading Processes…</property>
<property name="valign">center</property>
<style>
<class name="dim-label"/>
</style>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwExpanderRow">
<property name="title" translatable="yes">Launch Application</property>
<property name="subtitle" translatable="yes">Sysprof can launch an application to be profiled. The profiler will automatically stop when it exits.</property>
<property name="expanded" bind-source="launch_switch" bind-property="active" bind-flags="bidirectional|sync-create"/>
<child type="action">
<object class="GtkSwitch" id="launch_switch">
<property name="active">false</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
<child>
<object class="AdwEntryRow" id="command_line">
<property name="title" translatable="yes">Command Line</property>
</object>
</child>
<child>
<object class="SysprofEnvironEditor" id="environ_editor">
</object>
</child>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Inherit Environment</property>
<property name="subtitle" translatable="yes">Enable to ensure your application shares the display, message-bus, and other desktop environment settings.</property>
<property name="activatable-widget">inherit_switch</property>
<child>
<object class="GtkSwitch" id="inherit_switch">
<property name="active">true</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Performance</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Allow CPU Throttling</property>
<property name="subtitle" translatable="yes">When enabled, your system is allowed to scale CPU frequency as necessary.</property>
<property name="activatable-widget">allow_throttling</property>
<child>
<object class="GtkSwitch" id="allow_throttling">
<property name="active">true</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Instruments</property>
<child>
<object class="GtkFlowBox" id="aid_flow_box">
<property name="activate-on-single-click">true</property>
<property name="column-spacing">24</property>
<property name="row-spacing">12</property>
<property name="max-children-per-line">4</property>
<property name="min-children-per-line">4</property>
<property name="halign">fill</property>
<property name="homogeneous">true</property>
<property name="selection-mode">single</property>
<child>
<object class="SysprofAidIcon">
<property name="aid">callgraph_aid</property>
<property name="selected">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">cpu_aid</property>
<property name="selected">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">memory_aid</property>
<property name="selected">false</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">mutter_aid</property>
<property name="selected">false</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">gjs_aid</property>
<property name="selected">false</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">app_aid</property>
<property name="selected">true</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">rapl_aid</property>
<property name="selected">false</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">battery_aid</property>
<property name="selected">false</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">network_aid</property>
<property name="selected">false</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="aid">diskstat_aid</property>
<property name="selected">false</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="tooltip-text" translatable="yes">Track application memory allocations (Sysprof must launch target application)</property>
<property name="aid">memprof_aid</property>
<property name="selected">false</property>
</object>
</child>
<child>
<object class="SysprofAidIcon">
<property name="tooltip-text" translatable="yes">Track slow operations on your applications main loop</property>
<property name="aid">speedtrack_aid</property>
<property name="selected">false</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<child>
<object class="GtkButton" id="record_button">
<property name="label" translatable="yes">_Record</property>
<property name="use-underline">true</property>
<property name="halign">end</property>
<property name="width-request">125</property>
<style>
<class name="suggested-action"/>
</style>
</object>
</child>
</object>
@ -532,20 +276,4 @@
</object>
</child>
</template>
<object class="GtkSizeGroup">
<property name="mode">vertical</property>
<widgets>
<widget name="label1"/>
<widget name="whole_system_switch"/>
</widgets>
</object>
<object class="GtkSizeGroup">
<property name="mode">vertical</property>
<widgets>
<widget name="label2"/>
<widget name="label3"/>
<widget name="allow_throttling"/>
<widget name="launch_switch"/>
</widgets>
</object>
</interface>