sysprof: start on SysprofTimeScrubber

This is going to be used to bring the whole tracksview thing we did before
and make the selections work directly on charts. We can probably use the
same thing w/ a GtkOverlay and custom positioning to replace the old
usage too.
This commit is contained in:
Christian Hergert
2023-07-12 17:26:56 -07:00
parent 03bc678daa
commit 83e7579460
7 changed files with 289 additions and 28 deletions

View File

@ -15,6 +15,7 @@ sysprof_sources = [
'sysprof-section.c',
'sysprof-sidebar.c',
'sysprof-single-model.c',
'sysprof-time-scrubber.c',
'sysprof-traceables-utility.c',
'sysprof-window.c',
]

View File

@ -24,6 +24,7 @@
#include "sysprof-samples-section.h"
#include "sysprof-traceables-utility.h"
#include "sysprof-time-scrubber.h"
struct _SysprofSamplesSection
{
@ -58,6 +59,7 @@ sysprof_samples_section_class_init (SysprofSamplesSectionClass *klass)
g_type_ensure (SYSPROF_TYPE_CHART);
g_type_ensure (SYSPROF_TYPE_XY_SERIES);
g_type_ensure (SYSPROF_TYPE_COLUMN_LAYER);
g_type_ensure (SYSPROF_TYPE_TIME_SCRUBBER);
g_type_ensure (SYSPROF_TYPE_TRACEABLES_UTILITY);
g_type_ensure (SYSPROF_TYPE_VALUE_AXIS);
g_type_ensure (SYSPROF_TYPE_WEIGHTED_CALLGRAPH_VIEW);

View File

@ -6,43 +6,54 @@
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
<object class="SysprofChart">
<property name="height-request">32</property>
<child>
<object class="SysprofColumnLayer">
<property name="title">Stack Traces</property>
<binding name="x-axis">
<lookup name="selected-time-axis" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<property name="y-axis">
<object class="SysprofValueAxis">
<property name="min-value">0</property>
<property name="max-value">128</property>
</object>
</property>
<property name="series">
<object class="SysprofXYSeries">
<binding name="model">
<lookup name="samples" type="SysprofDocument">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
<object class="SysprofTimeScrubber" id="scrubber">
<binding name="session">
<lookup name="session">SysprofSamplesSection</lookup>
</binding>
<child type="chart">
<object class="SysprofChart">
<property name="height-request">32</property>
<child>
<object class="SysprofColumnLayer">
<property name="title">Stack Traces</property>
<binding name="x-axis">
<lookup name="selected-time-axis" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</binding>
<property name="x-expression">
<lookup name="time" type="SysprofDocumentFrame"/>
<property name="y-axis">
<object class="SysprofValueAxis">
<property name="min-value">0</property>
<property name="max-value">128</property>
</object>
</property>
<property name="y-expression">
<lookup name="stack-depth" type="SysprofDocumentTraceable"/>
<property name="series">
<object class="SysprofXYSeries">
<binding name="model">
<lookup name="samples" type="SysprofDocument">
<lookup name="document" type="SysprofSession">
<lookup name="session">SysprofSamplesSection</lookup>
</lookup>
</lookup>
</binding>
<property name="x-expression">
<lookup name="time" type="SysprofDocumentFrame"/>
</property>
<property name="y-expression">
<lookup name="stack-depth" type="SysprofDocumentTraceable"/>
</property>
</object>
</property>
</object>
</property>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSeparator">
</object>
</child>
<child>
<object class="SysprofWeightedCallgraphView" id="callgraph_view">
<property name="vexpand">true</property>

View File

@ -0,0 +1,186 @@
/* sysprof-time-scrubber.c
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include <sysprof-gtk.h>
#include "sysprof-time-scrubber.h"
struct _SysprofTimeScrubber
{
GtkWidget parent_instance;
SysprofSession *session;
SysprofTimeRuler *ruler;
GtkBox *vbox;
};
enum {
PROP_0,
PROP_SESSION,
N_PROPS
};
static void buildable_iface_init (GtkBuildableIface *iface);
static GtkBuildableIface *buildable_parent;
G_DEFINE_FINAL_TYPE_WITH_CODE (SysprofTimeScrubber, sysprof_time_scrubber, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, buildable_iface_init))
static GParamSpec *properties[N_PROPS];
static void
sysprof_time_scrubber_dispose (GObject *object)
{
SysprofTimeScrubber *self = (SysprofTimeScrubber *)object;
GtkWidget *child;
gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_TIME_SCRUBBER);
while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
gtk_widget_unparent (child);
g_clear_object (&self->session);
G_OBJECT_CLASS (sysprof_time_scrubber_parent_class)->dispose (object);
}
static void
sysprof_time_scrubber_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
SysprofTimeScrubber *self = SYSPROF_TIME_SCRUBBER (object);
switch (prop_id)
{
case PROP_SESSION:
g_value_set_object (value, sysprof_time_scrubber_get_session (self));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sysprof_time_scrubber_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
SysprofTimeScrubber *self = SYSPROF_TIME_SCRUBBER (object);
switch (prop_id)
{
case PROP_SESSION:
sysprof_time_scrubber_set_session (self, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
sysprof_time_scrubber_class_init (SysprofTimeScrubberClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->dispose = sysprof_time_scrubber_dispose;
object_class->get_property = sysprof_time_scrubber_get_property;
object_class->set_property = sysprof_time_scrubber_set_property;
properties[PROP_SESSION] =
g_param_spec_object ("session", NULL, NULL,
SYSPROF_TYPE_SESSION,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-time-scrubber.ui");
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
gtk_widget_class_bind_template_child (widget_class, SysprofTimeScrubber, vbox);
gtk_widget_class_bind_template_child (widget_class, SysprofTimeScrubber, ruler);
g_type_ensure (SYSPROF_TYPE_TIME_RULER);
}
static void
sysprof_time_scrubber_init (SysprofTimeScrubber *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
SysprofSession *
sysprof_time_scrubber_get_session (SysprofTimeScrubber *self)
{
g_return_val_if_fail (SYSPROF_IS_TIME_SCRUBBER (self), NULL);
return self->session;
}
void
sysprof_time_scrubber_set_session (SysprofTimeScrubber *self,
SysprofSession *session)
{
g_return_if_fail (SYSPROF_IS_TIME_SCRUBBER (self));
g_return_if_fail (!session || SYSPROF_IS_SESSION (session));
if (g_set_object (&self->session, session))
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SESSION]);
}
static void
sysprof_time_scrubber_add_chart (SysprofTimeScrubber *self,
GtkWidget *chart)
{
g_assert (SYSPROF_IS_TIME_SCRUBBER (self));
g_assert (GTK_IS_WIDGET (chart));
gtk_box_append (self->vbox, chart);
}
static void
sysprof_time_scrubber_add_child (GtkBuildable *buildable,
GtkBuilder *builder,
GObject *object,
const char *type)
{
SysprofTimeScrubber *self = (SysprofTimeScrubber *)buildable;
g_assert (SYSPROF_IS_TIME_SCRUBBER (self));
if (g_strcmp0 (type, "chart") == 0)
sysprof_time_scrubber_add_chart (self, GTK_WIDGET (object));
else
buildable_parent->add_child (buildable, builder, object, type);
}
static void
buildable_iface_init (GtkBuildableIface *iface)
{
buildable_parent = g_type_interface_peek_parent (iface);
iface->add_child = sysprof_time_scrubber_add_child;
}

View File

@ -0,0 +1,38 @@
/* sysprof-time-scrubber.h
*
* Copyright 2023 Christian Hergert <chergert@redhat.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#pragma once
#include <gtk/gtk.h>
#include <sysprof-analyze.h>
G_BEGIN_DECLS
#define SYSPROF_TYPE_TIME_SCRUBBER (sysprof_time_scrubber_get_type())
G_DECLARE_FINAL_TYPE (SysprofTimeScrubber, sysprof_time_scrubber, SYSPROF, TIME_SCRUBBER, GtkWidget)
GtkWidget *sysprof_time_scrubber_new (void);
SysprofSession *sysprof_time_scrubber_get_session (SysprofTimeScrubber *self);
void sysprof_time_scrubber_set_session (SysprofTimeScrubber *self,
SysprofSession *session);
G_END_DECLS

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="SysprofTimeScrubber" parent="GtkWidget">
<child>
<object class="GtkBox" id="main">
<property name="orientation">vertical</property>
<child>
<object class="SysprofTimeRuler" id="ruler">
<binding name="session">
<lookup name="session">SysprofTimeScrubber</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkBox" id="vbox">
<property name="orientation">vertical</property>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@ -15,6 +15,7 @@
<file preprocess="xml-stripblanks">sysprof-recording-pad.ui</file>
<file preprocess="xml-stripblanks">sysprof-samples-section.ui</file>
<file preprocess="xml-stripblanks">sysprof-sidebar.ui</file>
<file preprocess="xml-stripblanks">sysprof-time-scrubber.ui</file>
<file preprocess="xml-stripblanks">sysprof-traceables-utility.ui</file>
<file preprocess="xml-stripblanks">sysprof-window.ui</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/address-layout-symbolic.svg</file>