diff --git a/src/libsysprof-gtk/meson.build b/src/libsysprof-gtk/meson.build index dae0173e..88aade31 100644 --- a/src/libsysprof-gtk/meson.build +++ b/src/libsysprof-gtk/meson.build @@ -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', ] diff --git a/src/libsysprof-gtk/sysprof-gtk.h b/src/libsysprof-gtk/sysprof-gtk.h index c886f0c3..e0b22302 100644 --- a/src/libsysprof-gtk/sysprof-gtk.h +++ b/src/libsysprof-gtk/sysprof-gtk.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 diff --git a/src/libsysprof-gtk/sysprof-session.c b/src/libsysprof-gtk/sysprof-session.c index 962982e9..0fe575cc 100644 --- a/src/libsysprof-gtk/sysprof-session.c +++ b/src/libsysprof-gtk/sysprof-session.c @@ -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; +} diff --git a/src/libsysprof-gtk/sysprof-session.h b/src/libsysprof-gtk/sysprof-session.h index cf5c705f..a9c27895 100644 --- a/src/libsysprof-gtk/sysprof-session.h +++ b/src/libsysprof-gtk/sysprof-session.h @@ -24,6 +24,8 @@ #include +#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 diff --git a/src/libsysprof-gtk/sysprof-time-span.c b/src/libsysprof-gtk/sysprof-time-span.c new file mode 100644 index 00000000..d690965b --- /dev/null +++ b/src/libsysprof-gtk/sysprof-time-span.c @@ -0,0 +1,37 @@ +/* sysprof-time-span.c + * + * Copyright 2023 Christian Hergert + * + * 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 . + * + * 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); +} diff --git a/src/libsysprof-gtk/sysprof-time-span.h b/src/libsysprof-gtk/sysprof-time-span.h new file mode 100644 index 00000000..97d70e8a --- /dev/null +++ b/src/libsysprof-gtk/sysprof-time-span.h @@ -0,0 +1,44 @@ +/* sysprof-time-span.h + * + * Copyright 2023 Christian Hergert + * + * 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 . + * + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +#pragma once + +#include + +#include + +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