mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-gtk: add timespan to session
We want to be able to monitor this from session observers to be able to update the visible area and/or what is rendered.
This commit is contained in:
@ -3,6 +3,7 @@ libsysprof_gtk_public_sources = [
|
||||
'sysprof-mark-chart.c',
|
||||
'sysprof-mark-table.c',
|
||||
'sysprof-session.c',
|
||||
'sysprof-time-span.c',
|
||||
'sysprof-weighted-callgraph-view.c',
|
||||
]
|
||||
|
||||
@ -21,6 +22,7 @@ libsysprof_gtk_public_headers = [
|
||||
'sysprof-mark-chart.h',
|
||||
'sysprof-mark-table.h',
|
||||
'sysprof-session.h',
|
||||
'sysprof-time-span.h',
|
||||
'sysprof-weighted-callgraph-view.h',
|
||||
]
|
||||
|
||||
|
||||
@ -27,6 +27,7 @@ G_BEGIN_DECLS
|
||||
# include "sysprof-mark-chart.h"
|
||||
# include "sysprof-mark-table.h"
|
||||
# include "sysprof-session.h"
|
||||
# include "sysprof-time-span.h"
|
||||
# include "sysprof-weighted-callgraph-view.h"
|
||||
#undef SYSPROF_GTK_INSIDE
|
||||
|
||||
|
||||
@ -25,14 +25,20 @@
|
||||
struct _SysprofSession
|
||||
{
|
||||
GObject parent_instance;
|
||||
|
||||
SysprofDocument *document;
|
||||
GtkCustomFilter *filter;
|
||||
|
||||
SysprofTimeSpan selected_time;
|
||||
SysprofTimeSpan visible_time;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DOCUMENT,
|
||||
PROP_FILTER,
|
||||
PROP_SELECTED_TIME,
|
||||
PROP_VISIBLE_TIME,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
@ -69,6 +75,14 @@ sysprof_session_get_property (GObject *object,
|
||||
g_value_set_object (value, sysprof_session_get_filter (self));
|
||||
break;
|
||||
|
||||
case PROP_SELECTED_TIME:
|
||||
g_value_set_boxed (value, sysprof_session_get_selected_time (self));
|
||||
break;
|
||||
|
||||
case PROP_VISIBLE_TIME:
|
||||
g_value_set_boxed (value, sysprof_session_get_visible_time (self));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
@ -112,6 +126,16 @@ sysprof_session_class_init (SysprofSessionClass *klass)
|
||||
GTK_TYPE_FILTER,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties [PROP_SELECTED_TIME] =
|
||||
g_param_spec_boxed ("selected-time", NULL, NULL,
|
||||
SYSPROF_TYPE_TIME_SPAN,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties [PROP_VISIBLE_TIME] =
|
||||
g_param_spec_boxed ("visible-time", NULL, NULL,
|
||||
SYSPROF_TYPE_TIME_SPAN,
|
||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
}
|
||||
|
||||
@ -160,3 +184,19 @@ sysprof_session_get_filter (SysprofSession *self)
|
||||
|
||||
return GTK_FILTER (self->filter);
|
||||
}
|
||||
|
||||
const SysprofTimeSpan *
|
||||
sysprof_session_get_selected_time (SysprofSession *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_SESSION (self), NULL);
|
||||
|
||||
return &self->selected_time;
|
||||
}
|
||||
|
||||
const SysprofTimeSpan *
|
||||
sysprof_session_get_visible_time (SysprofSession *self)
|
||||
{
|
||||
g_return_val_if_fail (SYSPROF_IS_SESSION (self), NULL);
|
||||
|
||||
return &self->visible_time;
|
||||
}
|
||||
|
||||
@ -24,6 +24,8 @@
|
||||
|
||||
#include <sysprof-analyze.h>
|
||||
|
||||
#include "sysprof-time-span.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_SESSION (sysprof_session_get_type())
|
||||
@ -32,10 +34,14 @@ SYSPROF_AVAILABLE_IN_ALL
|
||||
G_DECLARE_FINAL_TYPE (SysprofSession, sysprof_session, SYSPROF, SESSION, GObject)
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofSession *sysprof_session_new (SysprofDocument *document);
|
||||
SysprofSession *sysprof_session_new (SysprofDocument *document);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofDocument *sysprof_session_get_document (SysprofSession *self);
|
||||
SysprofDocument *sysprof_session_get_document (SysprofSession *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GtkFilter *sysprof_session_get_filter (SysprofSession *self);
|
||||
GtkFilter *sysprof_session_get_filter (SysprofSession *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofTimeSpan *sysprof_session_get_selected_time (SysprofSession *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
const SysprofTimeSpan *sysprof_session_get_visible_time (SysprofSession *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
37
src/libsysprof-gtk/sysprof-time-span.c
Normal file
37
src/libsysprof-gtk/sysprof-time-span.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* sysprof-time-span.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-time-span.h"
|
||||
|
||||
G_DEFINE_BOXED_TYPE (SysprofTimeSpan, sysprof_time_span, sysprof_time_span_copy, sysprof_time_span_free)
|
||||
|
||||
SysprofTimeSpan *
|
||||
sysprof_time_span_copy (const SysprofTimeSpan *self)
|
||||
{
|
||||
return g_memdup2 (self, sizeof *self);
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_time_span_free (SysprofTimeSpan *self)
|
||||
{
|
||||
g_free (self);
|
||||
}
|
||||
44
src/libsysprof-gtk/sysprof-time-span.h
Normal file
44
src/libsysprof-gtk/sysprof-time-span.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* sysprof-time-span.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 <glib-object.h>
|
||||
|
||||
#include <sysprof-capture.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define SYSPROF_TYPE_TIME_SPAN (sysprof_time_span_get_type())
|
||||
|
||||
typedef struct _SysprofTimeSpan
|
||||
{
|
||||
gint64 begin_nsec;
|
||||
gint64 end_nsec;
|
||||
} SysprofTimeSpan;
|
||||
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
GType sysprof_time_span_get_type (void) G_GNUC_CONST;
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
SysprofTimeSpan *sysprof_time_span_copy (const SysprofTimeSpan *self);
|
||||
SYSPROF_AVAILABLE_IN_ALL
|
||||
void sysprof_time_span_free (SysprofTimeSpan *self);
|
||||
|
||||
G_END_DECLS
|
||||
Reference in New Issue
Block a user