sysprof: start wiring up template to controls

This commit is contained in:
Christian Hergert
2023-08-06 01:14:10 -07:00
parent 8bf8b4455f
commit 57aabaf6f9
3 changed files with 54 additions and 31 deletions

View File

@ -29,29 +29,31 @@
#include "sysprof-entry-popover.h"
#include "sysprof-greeter.h"
#include "sysprof-recording-pad.h"
#include "sysprof-recording-template.h"
G_DEFINE_AUTOPTR_CLEANUP_FUNC (SysprofCaptureWriter, sysprof_capture_writer_unref)
struct _SysprofGreeter
{
AdwWindow parent_instance;
AdwWindow parent_instance;
GFile *file;
GtkStringList *envvars;
GFile *file;
GtkStringList *envvars;
AdwViewStack *view_stack;
GtkListBox *sidebar_list_box;
AdwPreferencesPage *record_page;
GtkListBox *app_environment;
GtkSwitch *sample_native_stacks;
GtkSwitch *sample_javascript_stacks;
GtkSwitch *record_disk_usage;
GtkSwitch *record_network_usage;
GtkSwitch *record_compositor;
GtkSwitch *record_system_logs;
GtkSwitch *record_session_bus;
GtkSwitch *record_system_bus;
GtkSwitch *bundle_symbols;
AdwViewStack *view_stack;
GtkListBox *sidebar_list_box;
AdwPreferencesPage *record_page;
GtkListBox *app_environment;
GtkSwitch *sample_native_stacks;
GtkSwitch *sample_javascript_stacks;
GtkSwitch *record_disk_usage;
GtkSwitch *record_network_usage;
GtkSwitch *record_compositor;
GtkSwitch *record_system_logs;
GtkSwitch *record_session_bus;
GtkSwitch *record_system_bus;
GtkSwitch *bundle_symbols;
SysprofRecordingTemplate *recording_template;
};
enum {
@ -590,6 +592,7 @@ sysprof_greeter_class_init (SysprofGreeterClass *klass)
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, app_environment);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, bundle_symbols);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, envvars);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, record_compositor);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, record_disk_usage);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, record_network_usage);
@ -597,8 +600,9 @@ sysprof_greeter_class_init (SysprofGreeterClass *klass)
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, record_session_bus);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, record_system_bus);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, record_system_logs);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, sample_native_stacks);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, recording_template);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, sample_javascript_stacks);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, sample_native_stacks);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, sidebar_list_box);
gtk_widget_class_bind_template_child (widget_class, SysprofGreeter, view_stack);
@ -612,6 +616,7 @@ sysprof_greeter_class_init (SysprofGreeterClass *klass)
gtk_widget_class_install_action (widget_class, "win.select-file", NULL, sysprof_greeter_select_file_action);
g_type_ensure (SYSPROF_TYPE_ENTRY_POPOVER);
g_type_ensure (SYSPROF_TYPE_RECORDING_TEMPLATE);
}
static void
@ -619,14 +624,14 @@ sysprof_greeter_init (SysprofGreeter *self)
{
GtkListBoxRow *row;
self->envvars = gtk_string_list_new (NULL);
gtk_widget_init_template (GTK_WIDGET (self));
g_signal_connect_object (self->envvars,
"items-changed",
G_CALLBACK (on_env_items_changed_cb),
self,
G_CONNECT_SWAPPED);
gtk_widget_init_template (GTK_WIDGET (self));
on_env_items_changed_cb (self, 0, 0, 0, G_LIST_MODEL (self->envvars));
gtk_list_box_bind_model (self->sidebar_list_box,
G_LIST_MODEL (adw_view_stack_get_pages (self->view_stack)),

View File

@ -87,8 +87,8 @@
<property name="subtitle" translatable="yes">Record native stack traces using a sampling profiler</property>
<child type="suffix">
<object class="GtkSwitch" id="sample_native_stacks">
<property name="active">true</property>
<property name="valign">center</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="native-stacks"/>
</object>
</child>
</object>
@ -105,6 +105,7 @@
<child type="suffix">
<object class="GtkSwitch" id="sample_javascript_stacks">
<property name="valign">center</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="javascript-stacks"/>
</object>
</child>
</object>
@ -133,6 +134,7 @@
<child type="suffix">
<object class="GtkSwitch" id="trace_malloc">
<property name="valign">center</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="memory-allocations"/>
</object>
</child>
</object>
@ -166,6 +168,7 @@
<child>
<object class="AdwEntryRow" id="app_command_line">
<property name="title" translatable="yes">Command Line</property>
<property name="text" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="command-line"/>
</object>
</child>
<child>
@ -191,8 +194,8 @@
<property name="subtitle" translatable="yes">Clear the environment before launching application</property>
<child type="suffix">
<object class="GtkSwitch" id="clear_environment">
<property name="active">false</property>
<property name="valign">center</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="clear-environ"/>
</object>
</child>
</object>
@ -251,8 +254,8 @@
<property name="subtitle" translatable="yes">Record coarse-grained counters about CPU usage and frequency</property>
<child type="suffix">
<object class="GtkSwitch" id="record_cpu_usage">
<property name="active">true</property>
<property name="valign">center</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="cpu-usage"/>
</object>
</child>
</object>
@ -264,8 +267,8 @@
<property name="subtitle" translatable="yes">Record coarse-grained counters about system memory usage</property>
<child type="suffix">
<object class="GtkSwitch" id="record_memory_counters">
<property name="active">true</property>
<property name="valign">center</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="memory-usage"/>
</object>
</child>
</object>
@ -277,7 +280,7 @@
<property name="subtitle" translatable="yes">Record coarse-grained counters about storage throughput</property>
<child type="suffix">
<object class="GtkSwitch" id="record_disk_usage">
<property name="active">true</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="disk-usage"/>
<property name="valign">center</property>
</object>
</child>
@ -290,7 +293,7 @@
<property name="subtitle" translatable="yes">Record coarse-grained counters about network traffic</property>
<child type="suffix">
<object class="GtkSwitch" id="record_network_usage">
<property name="active">true</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="network-usage"/>
<property name="valign">center</property>
</object>
</child>
@ -307,7 +310,7 @@
<property name="subtitle" translatable="yes">Record coarse-grained counters about energy usage in Watts</property>
<child type="suffix">
<object class="GtkSwitch" id="record_energy_usage">
<property name="active">true</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="energy-usage"/>
<property name="valign">center</property>
</object>
</child>
@ -320,7 +323,7 @@
<property name="subtitle" translatable="yes">Record coarse-grained counters about battery charge or discharge rates</property>
<child type="suffix">
<object class="GtkSwitch" id="record_battery_charge">
<property name="active">true</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="battery-charge"/>
<property name="valign">center</property>
</object>
</child>
@ -348,6 +351,7 @@
<property name="subtitle" translatable="yes">Record messages on the D-Bus system bus</property>
<child type="suffix">
<object class="GtkSwitch" id="record_system_bus">
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="system-bus"/>
<property name="valign">center</property>
</object>
</child>
@ -364,6 +368,7 @@
<property name="subtitle" translatable="yes">Record messages on the D-Bus user session bus</property>
<child type="suffix">
<object class="GtkSwitch" id="record_session_bus">
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="session-bus"/>
<property name="valign">center</property>
</object>
</child>
@ -402,7 +407,7 @@
<property name="subtitle" translatable="yes">Record frame-timing information from the GNOME Shell compositor</property>
<child type="suffix">
<object class="GtkSwitch" id="record_compositor">
<property name="active">true</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="frame-timings"/>
<property name="valign">center</property>
</object>
</child>
@ -479,7 +484,7 @@
<property name="subtitle" translatable="yes">Watch the system log for new messages and record them</property>
<child type="suffix">
<object class="GtkSwitch" id="record_system_logs">
<property name="active">true</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="system-log"/>
<property name="valign">center</property>
</object>
</child>
@ -497,7 +502,7 @@
<property name="subtitle" translatable="yes">Make recording shareable by symbolizing stack traces after recording</property>
<child type="suffix">
<object class="GtkSwitch" id="bundle_symbols">
<property name="active">true</property>
<property name="active" bind-source="recording_template" bind-flags="bidirectional|sync-create" bind-property="bundle-symbols"/>
<property name="valign">center</property>
</object>
</child>
@ -535,4 +540,8 @@
</item>
</section>
</menu>
<object class="SysprofRecordingTemplate" id="recording_template">
</object>
<object class="GtkStringList" id="envvars">
</object>
</interface>

View File

@ -147,6 +147,10 @@ sysprof_recording_template_get_property (GObject *object,
g_value_set_boolean (value, self->memory_allocations);
break;
case PROP_MEMORY_USAGE:
g_value_set_boolean (value, self->memory_usage);
break;
case PROP_NATIVE_STACKS:
g_value_set_boolean (value, self->native_stacks);
break;
@ -235,6 +239,10 @@ sysprof_recording_template_set_property (GObject *object,
self->memory_allocations = g_value_get_boolean (value);
break;
case PROP_MEMORY_USAGE:
self->memory_usage = g_value_get_boolean (value);
break;
case PROP_NATIVE_STACKS:
self->native_stacks = g_value_get_boolean (value);
break;
@ -382,6 +390,7 @@ sysprof_recording_template_init (SysprofRecordingTemplate *self)
self->native_stacks = TRUE;
self->network_usage = TRUE;
self->system_log = TRUE;
self->command_line = g_strdup ("");
}
SysprofRecordingTemplate *