mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-gtk: start on SysprofTracksView
This is eventually going to contain the list of tracks we have at the top of the analysis view.
This commit is contained in:
@ -5,6 +5,8 @@
|
||||
<file preprocess="xml-stripblanks">sysprof-mark-chart.ui</file>
|
||||
<file preprocess="xml-stripblanks">sysprof-mark-chart-row.ui</file>
|
||||
<file preprocess="xml-stripblanks">sysprof-mark-table.ui</file>
|
||||
<file preprocess="xml-stripblanks">sysprof-track-view.ui</file>
|
||||
<file preprocess="xml-stripblanks">sysprof-tracks-view.ui</file>
|
||||
<file preprocess="xml-stripblanks">sysprof-weighted-callgraph-view.ui</file>
|
||||
<file>style.css</file>
|
||||
</gresource>
|
||||
|
||||
@ -19,6 +19,9 @@ libsysprof_gtk_public_sources = [
|
||||
'sysprof-time-span-layer.c',
|
||||
'sysprof-time-series.c',
|
||||
'sysprof-time-series-item.c',
|
||||
'sysprof-track.c',
|
||||
'sysprof-track-view.c',
|
||||
'sysprof-tracks-view.c',
|
||||
'sysprof-value-axis.c',
|
||||
'sysprof-weighted-callgraph-view.c',
|
||||
'sysprof-xy-layer.c',
|
||||
@ -49,6 +52,9 @@ libsysprof_gtk_public_headers = [
|
||||
'sysprof-time-series.h',
|
||||
'sysprof-time-series-item.h',
|
||||
'sysprof-time-span-layer.h',
|
||||
'sysprof-track.h',
|
||||
'sysprof-track-view.h',
|
||||
'sysprof-tracks-view.h',
|
||||
'sysprof-weighted-callgraph-view.h',
|
||||
'sysprof-value-axis.h',
|
||||
'sysprof-xy-layer.h',
|
||||
|
||||
@ -43,6 +43,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-time-series.h"
|
||||
# include "sysprof-time-series-item.h"
|
||||
# include "sysprof-time-span-layer.h"
|
||||
# include "sysprof-tracks-view.h"
|
||||
# include "sysprof-value-axis.h"
|
||||
# include "sysprof-weighted-callgraph-view.h"
|
||||
# include "sysprof-xy-layer.h"
|
||||
|
||||
148
src/libsysprof-gtk/sysprof-track-view.c
Normal file
148
src/libsysprof-gtk/sysprof-track-view.c
Normal file
@ -0,0 +1,148 @@
|
||||
/* sysprof-track-view.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-track-view.h"
|
||||
|
||||
struct _SysprofTrackView
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
SysprofTrack *track;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_TRACK,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofTrackView, sysprof_track_view, GTK_TYPE_WIDGET)
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
sysprof_track_view_dispose (GObject *object)
|
||||
{
|
||||
SysprofTrackView *self = (SysprofTrackView *)object;
|
||||
|
||||
gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_TRACK_VIEW);
|
||||
|
||||
g_clear_object (&self->track);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_track_view_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_track_view_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofTrackView *self = SYSPROF_TRACK_VIEW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TRACK:
|
||||
g_value_set_object (value, sysprof_track_view_get_track (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_track_view_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofTrackView *self = SYSPROF_TRACK_VIEW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TRACK:
|
||||
sysprof_track_view_set_track (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_track_view_class_init (SysprofTrackViewClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = sysprof_track_view_dispose;
|
||||
object_class->get_property = sysprof_track_view_get_property;
|
||||
object_class->set_property = sysprof_track_view_set_property;
|
||||
|
||||
properties[PROP_TRACK] =
|
||||
g_param_spec_object ("track", NULL, NULL,
|
||||
SYSPROF_TYPE_TRACK,
|
||||
(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, "/libsysprof-gtk/sysprof-track-view.ui");
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_TRACK);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_track_view_init (SysprofTrackView *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
sysprof_track_view_new (void)
|
||||
{
|
||||
return g_object_new (SYSPROF_TYPE_TRACK_VIEW, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_track_view_get_track:
|
||||
* @self: a #SysprofTrackView
|
||||
*
|
||||
* Returns: (transfer none) (nullable): A #SysprofTrack or %NULL
|
||||
*/
|
||||
SysprofTrack *
|
||||
sysprof_track_view_get_track (SysprofTrackView *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_TRACK_VIEW (self), NULL);
|
||||
|
||||
return self->track;
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_track_view_set_track (SysprofTrackView *self,
|
||||
SysprofTrack *track)
|
||||
{
|
||||
g_return_if_fail (SYSPROF_IS_TRACK_VIEW (self));
|
||||
g_return_if_fail (!track || SYSPROF_IS_TRACK (track));
|
||||
|
||||
if (g_set_object (&self->track, track))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TRACK]);
|
||||
}
|
||||
42
src/libsysprof-gtk/sysprof-track-view.h
Normal file
42
src/libsysprof-gtk/sysprof-track-view.h
Normal file
@ -0,0 +1,42 @@
|
||||
/* sysprof-track-view.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-track.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_TRACK_VIEW (sysprof_track_view_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SysprofTrackView, sysprof_track_view, SYSPROF, TRACK_VIEW, GtkWidget)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GtkWidget *sysprof_track_view_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofTrack *sysprof_track_view_get_track (SysprofTrackView *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_track_view_set_track (SysprofTrackView *self,
|
||||
SysprofTrack *track);
|
||||
|
||||
G_END_DECLS
|
||||
21
src/libsysprof-gtk/sysprof-track-view.ui
Normal file
21
src/libsysprof-gtk/sysprof-track-view.ui
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="SysprofTrackView" parent="GtkWidget">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<child>
|
||||
<object class="GtkInscription" id="title">
|
||||
<property name="nat-chars">30</property>
|
||||
<property name="min-chars">30</property>
|
||||
<property name="text-overflow">ellipsize-end</property>
|
||||
<binding name="text">
|
||||
<lookup name="title" type="SysprofTrack">
|
||||
<lookup name="track">SysprofTrackView</lookup>
|
||||
</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
117
src/libsysprof-gtk/sysprof-track.c
Normal file
117
src/libsysprof-gtk/sysprof-track.c
Normal file
@ -0,0 +1,117 @@
|
||||
/* sysprof-track.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-track.h"
|
||||
|
||||
struct _SysprofTrack
|
||||
{
|
||||
GObject parent_instance;
|
||||
char *title;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_TITLE,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofTrack, sysprof_track, G_TYPE_OBJECT)
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
sysprof_track_dispose (GObject *object)
|
||||
{
|
||||
SysprofTrack *self = (SysprofTrack *)object;
|
||||
|
||||
g_clear_pointer (&self->title, g_free);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_track_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_track_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofTrack *self = SYSPROF_TRACK (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, sysprof_track_get_title (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_track_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofTrack *self = SYSPROF_TRACK (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_TITLE:
|
||||
self->title = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_track_class_init (SysprofTrackClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->dispose = sysprof_track_dispose;
|
||||
object_class->get_property = sysprof_track_get_property;
|
||||
object_class->set_property = sysprof_track_set_property;
|
||||
|
||||
properties[PROP_TITLE] =
|
||||
g_param_spec_string ("title", NULL, NULL,
|
||||
NULL,
|
||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_track_init (SysprofTrack *self)
|
||||
{
|
||||
}
|
||||
|
||||
const char *
|
||||
sysprof_track_get_title (SysprofTrack *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_TRACK (self), NULL);
|
||||
|
||||
return self->title;
|
||||
}
|
||||
35
src/libsysprof-gtk/sysprof-track.h
Normal file
35
src/libsysprof-gtk/sysprof-track.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* sysprof-track.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 <sysprof-analyze.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_TRACK (sysprof_track_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SysprofTrack, sysprof_track, SYSPROF, TRACK, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const char *sysprof_track_get_title (SysprofTrack *self);
|
||||
|
||||
G_END_DECLS
|
||||
159
src/libsysprof-gtk/sysprof-tracks-view.c
Normal file
159
src/libsysprof-gtk/sysprof-tracks-view.c
Normal file
@ -0,0 +1,159 @@
|
||||
/* sysprof-tracks-view.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-css-private.h"
|
||||
#include "sysprof-track-view.h"
|
||||
#include "sysprof-tracks-view.h"
|
||||
|
||||
struct _SysprofTracksView
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
SysprofSession *session;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_SESSION,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofTracksView, sysprof_tracks_view, GTK_TYPE_WIDGET)
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
sysprof_tracks_view_dispose (GObject *object)
|
||||
{
|
||||
SysprofTracksView *self = (SysprofTracksView *)object;
|
||||
GtkWidget *child;
|
||||
|
||||
g_clear_object (&self->session);
|
||||
|
||||
gtk_widget_dispose_template (GTK_WIDGET (self), SYSPROF_TYPE_TRACKS_VIEW);
|
||||
|
||||
while ((child = gtk_widget_get_first_child (GTK_WIDGET (self))))
|
||||
gtk_widget_unparent (child);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_tracks_view_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_tracks_view_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofTracksView *self = SYSPROF_TRACKS_VIEW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SESSION:
|
||||
g_value_set_object (value, sysprof_tracks_view_get_session (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_tracks_view_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
SysprofTracksView *self = SYSPROF_TRACKS_VIEW (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_SESSION:
|
||||
sysprof_tracks_view_set_session (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_tracks_view_class_init (SysprofTracksViewClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = sysprof_tracks_view_dispose;
|
||||
object_class->get_property = sysprof_tracks_view_get_property;
|
||||
object_class->set_property = sysprof_tracks_view_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, "/libsysprof-gtk/sysprof-tracks-view.ui");
|
||||
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_TRACK_VIEW);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_tracks_view_init (SysprofTracksView *self)
|
||||
{
|
||||
_sysprof_css_init ();
|
||||
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
sysprof_tracks_view_new (void)
|
||||
{
|
||||
return g_object_new (SYSPROF_TYPE_TRACKS_VIEW, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* sysprof_tracks_view_get_session:
|
||||
* @self: a #SysprofTracksView
|
||||
*
|
||||
* Gets the session for the tracks.
|
||||
*
|
||||
* Returns: (transfer none) (nullable): a #SysprofSession or %NULL
|
||||
*/
|
||||
SysprofSession *
|
||||
sysprof_tracks_view_get_session (SysprofTracksView *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_TRACKS_VIEW (self), NULL);
|
||||
|
||||
return self->session;
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_tracks_view_set_session (SysprofTracksView *self,
|
||||
SysprofSession *session)
|
||||
{
|
||||
g_return_if_fail (SYSPROF_IS_TRACKS_VIEW (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]);
|
||||
}
|
||||
44
src/libsysprof-gtk/sysprof-tracks-view.h
Normal file
44
src/libsysprof-gtk/sysprof-tracks-view.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* sysprof-tracks-view.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>
|
||||
|
||||
#include "sysprof-session.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_TRACKS_VIEW (sysprof_tracks_view_get_type())
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SysprofTracksView, sysprof_tracks_view, SYSPROF, TRACKS_VIEW, GtkWidget)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GtkWidget *sysprof_tracks_view_new (void);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofSession *sysprof_tracks_view_get_session (SysprofTracksView *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_tracks_view_set_session (SysprofTracksView *self,
|
||||
SysprofSession *session);
|
||||
|
||||
G_END_DECLS
|
||||
38
src/libsysprof-gtk/sysprof-tracks-view.ui
Normal file
38
src/libsysprof-gtk/sysprof-tracks-view.ui
Normal file
@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="SysprofTracksView" parent="GtkWidget">
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<child>
|
||||
<object class="GtkListView" id="list_view">
|
||||
<property name="factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListItem">
|
||||
<property name="child">
|
||||
<object class="SysprofTrackView">
|
||||
<binding name="track">
|
||||
<lookup name="item">GtkListItem</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</template>
|
||||
</interface>
|
||||
]]>
|
||||
</property>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
@ -14,6 +14,7 @@ libsysprof_gtk_testsuite_c_args = [
|
||||
libsysprof_gtk_testsuite = {
|
||||
'test-callgraph' : {'skip': true},
|
||||
'test-charts' : {'skip': true},
|
||||
'test-tracks' : {'skip': true},
|
||||
'test-mark-chart' : {'skip': true},
|
||||
'test-mark-table' : {'skip': true},
|
||||
}
|
||||
|
||||
207
src/libsysprof-gtk/tests/test-tracks.c
Normal file
207
src/libsysprof-gtk/tests/test-tracks.c
Normal file
@ -0,0 +1,207 @@
|
||||
/* test-tracks.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 <adwaita.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <sysprof-analyze.h>
|
||||
#include <sysprof-gtk.h>
|
||||
|
||||
static GMainLoop *main_loop;
|
||||
static char *filename;
|
||||
static const GOptionEntry entries[] = {
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
#define TEST_TYPE_TRACKS (test_tracks_get_type())
|
||||
G_DECLARE_FINAL_TYPE (TestTracks, test_tracks, TEST, TRACKS, AdwWindow)
|
||||
|
||||
struct _TestTracks
|
||||
{
|
||||
AdwWindow parent_instance;
|
||||
|
||||
SysprofDocument *document;
|
||||
SysprofSession *session;
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (TestTracks, test_tracks, ADW_TYPE_WINDOW)
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DOCUMENT,
|
||||
PROP_SESSION,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static void
|
||||
test_tracks_set_document (TestTracks *self,
|
||||
SysprofDocument *document)
|
||||
{
|
||||
if (g_set_object (&self->document, document))
|
||||
{
|
||||
g_clear_object (&self->session);
|
||||
|
||||
self->session = sysprof_session_new (self->document);
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DOCUMENT]);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SESSION]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_tracks_dispose (GObject *object)
|
||||
{
|
||||
TestTracks *self = (TestTracks *)object;
|
||||
|
||||
g_clear_object (&self->document);
|
||||
g_clear_object (&self->session);
|
||||
|
||||
G_OBJECT_CLASS (test_tracks_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
test_tracks_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
TestTracks *self = TEST_TRACKS (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DOCUMENT:
|
||||
g_value_set_object (value, self->document);
|
||||
break;
|
||||
|
||||
case PROP_SESSION:
|
||||
g_value_set_object (value, self->session);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_tracks_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
TestTracks *self = TEST_TRACKS (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_DOCUMENT:
|
||||
test_tracks_set_document (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_tracks_class_init (TestTracksClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
object_class->dispose = test_tracks_dispose;
|
||||
object_class->get_property = test_tracks_get_property;
|
||||
object_class->set_property = test_tracks_set_property;
|
||||
|
||||
properties [PROP_DOCUMENT] =
|
||||
g_param_spec_object ("document", NULL, NULL,
|
||||
SYSPROF_TYPE_DOCUMENT,
|
||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties [PROP_SESSION] =
|
||||
g_param_spec_object ("session", NULL, NULL,
|
||||
SYSPROF_TYPE_SESSION,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/test-tracks.ui");
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_TRACKS_VIEW);
|
||||
}
|
||||
|
||||
static void
|
||||
test_tracks_init (TestTracks *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
{
|
||||
g_autoptr(GOptionContext) context = g_option_context_new ("- test track layout");
|
||||
g_autoptr(SysprofDocumentLoader) loader = NULL;
|
||||
g_autoptr(SysprofDocument) document = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
GtkWindow *window;
|
||||
|
||||
sysprof_clock_init ();
|
||||
|
||||
gtk_init ();
|
||||
adw_init ();
|
||||
|
||||
g_option_context_add_main_entries (context, entries, NULL);
|
||||
if (!g_option_context_parse (context, &argc, &argv, &error))
|
||||
{
|
||||
g_printerr ("%s\n", error->message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argc != 2)
|
||||
{
|
||||
g_print ("usage: %s [OPTIONS] CAPTURE_FILE\n", argv[0]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
filename = argv[1];
|
||||
|
||||
main_loop = g_main_loop_new (NULL, FALSE);
|
||||
|
||||
loader = sysprof_document_loader_new (filename);
|
||||
if (!(document = sysprof_document_loader_load (loader, NULL, &error)))
|
||||
g_error ("Failed to load document: %s", error->message);
|
||||
|
||||
window = g_object_new (TEST_TYPE_TRACKS,
|
||||
"default-width", 800,
|
||||
"default-height", 600,
|
||||
"document", document,
|
||||
NULL);
|
||||
g_signal_connect_swapped (window,
|
||||
"close-request",
|
||||
G_CALLBACK (g_main_loop_quit),
|
||||
main_loop);
|
||||
gtk_window_present (window);
|
||||
g_main_loop_run (main_loop);
|
||||
|
||||
return 0;
|
||||
}
|
||||
21
src/libsysprof-gtk/tests/test-tracks.ui
Normal file
21
src/libsysprof-gtk/tests/test-tracks.ui
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="TestTracks" parent="AdwWindow">
|
||||
<child>
|
||||
<object class="AdwToolbarView">
|
||||
<property name="top-bar-style">raised</property>
|
||||
<child type="top">
|
||||
<object class="AdwHeaderBar">
|
||||
</object>
|
||||
</child>
|
||||
<property name="content">
|
||||
<object class="SysprofTracksView">
|
||||
<binding name="session">
|
||||
<lookup name="session">TestTracks</lookup>
|
||||
</binding>
|
||||
</object>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
||||
@ -2,5 +2,6 @@
|
||||
<gresources>
|
||||
<gresource prefix="/">
|
||||
<file preprocess="xml-stripblanks">test-charts.ui</file>
|
||||
<file preprocess="xml-stripblanks">test-tracks.ui</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
||||
Reference in New Issue
Block a user