mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-12 08:00:53 +00:00
libsysprof-gtk: give session a visible/selected time axis
This makes it easier to bind to various charts and have them auto-update when the axis changes.
This commit is contained in:
@ -21,6 +21,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "sysprof-session.h"
|
#include "sysprof-session.h"
|
||||||
|
#include "sysprof-value-axis.h"
|
||||||
|
|
||||||
struct _SysprofSession
|
struct _SysprofSession
|
||||||
{
|
{
|
||||||
@ -29,6 +30,9 @@ struct _SysprofSession
|
|||||||
SysprofDocument *document;
|
SysprofDocument *document;
|
||||||
GtkEveryFilter *filter;
|
GtkEveryFilter *filter;
|
||||||
|
|
||||||
|
SysprofAxis *visible_time_axis;
|
||||||
|
SysprofAxis *selected_time_axis;
|
||||||
|
|
||||||
SysprofTimeSpan selected_time;
|
SysprofTimeSpan selected_time;
|
||||||
SysprofTimeSpan visible_time;
|
SysprofTimeSpan visible_time;
|
||||||
};
|
};
|
||||||
@ -39,6 +43,8 @@ enum {
|
|||||||
PROP_FILTER,
|
PROP_FILTER,
|
||||||
PROP_SELECTED_TIME,
|
PROP_SELECTED_TIME,
|
||||||
PROP_VISIBLE_TIME,
|
PROP_VISIBLE_TIME,
|
||||||
|
PROP_SELECTED_TIME_AXIS,
|
||||||
|
PROP_VISIBLE_TIME_AXIS,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -46,6 +52,22 @@ G_DEFINE_FINAL_TYPE (SysprofSession, sysprof_session, G_TYPE_OBJECT)
|
|||||||
|
|
||||||
static GParamSpec *properties [N_PROPS];
|
static GParamSpec *properties [N_PROPS];
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_session_update_axis (SysprofSession *self)
|
||||||
|
{
|
||||||
|
g_assert (SYSPROF_IS_SESSION (self));
|
||||||
|
|
||||||
|
sysprof_value_axis_set_min_value (SYSPROF_VALUE_AXIS (self->visible_time_axis),
|
||||||
|
self->visible_time.begin_nsec);
|
||||||
|
sysprof_value_axis_set_max_value (SYSPROF_VALUE_AXIS (self->visible_time_axis),
|
||||||
|
self->visible_time.end_nsec);
|
||||||
|
|
||||||
|
sysprof_value_axis_set_min_value (SYSPROF_VALUE_AXIS (self->selected_time_axis),
|
||||||
|
self->selected_time.begin_nsec);
|
||||||
|
sysprof_value_axis_set_max_value (SYSPROF_VALUE_AXIS (self->selected_time_axis),
|
||||||
|
self->selected_time.end_nsec);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sysprof_session_set_document (SysprofSession *self,
|
sysprof_session_set_document (SysprofSession *self,
|
||||||
SysprofDocument *document)
|
SysprofDocument *document)
|
||||||
@ -57,6 +79,8 @@ sysprof_session_set_document (SysprofSession *self,
|
|||||||
|
|
||||||
self->visible_time = *sysprof_document_get_time_span (document);
|
self->visible_time = *sysprof_document_get_time_span (document);
|
||||||
self->selected_time = self->visible_time;
|
self->selected_time = self->visible_time;
|
||||||
|
|
||||||
|
sysprof_session_update_axis (self);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -64,6 +88,8 @@ sysprof_session_dispose (GObject *object)
|
|||||||
{
|
{
|
||||||
SysprofSession *self = (SysprofSession *)object;
|
SysprofSession *self = (SysprofSession *)object;
|
||||||
|
|
||||||
|
g_clear_object (&self->visible_time_axis);
|
||||||
|
g_clear_object (&self->selected_time_axis);
|
||||||
g_clear_object (&self->document);
|
g_clear_object (&self->document);
|
||||||
g_clear_object (&self->filter);
|
g_clear_object (&self->filter);
|
||||||
|
|
||||||
@ -96,6 +122,14 @@ sysprof_session_get_property (GObject *object,
|
|||||||
g_value_set_boxed (value, sysprof_session_get_visible_time (self));
|
g_value_set_boxed (value, sysprof_session_get_visible_time (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_SELECTED_TIME_AXIS:
|
||||||
|
g_value_set_object (value, sysprof_session_get_selected_time_axis (self));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_VISIBLE_TIME_AXIS:
|
||||||
|
g_value_set_object (value, sysprof_session_get_visible_time_axis (self));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
@ -149,6 +183,16 @@ sysprof_session_class_init (SysprofSessionClass *klass)
|
|||||||
SYSPROF_TYPE_TIME_SPAN,
|
SYSPROF_TYPE_TIME_SPAN,
|
||||||
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_SELECTED_TIME_AXIS] =
|
||||||
|
g_param_spec_object ("selected-time-axis", NULL, NULL,
|
||||||
|
SYSPROF_TYPE_AXIS,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
properties [PROP_VISIBLE_TIME_AXIS] =
|
||||||
|
g_param_spec_object ("visible-time-axis", NULL, NULL,
|
||||||
|
SYSPROF_TYPE_AXIS,
|
||||||
|
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,6 +200,8 @@ static void
|
|||||||
sysprof_session_init (SysprofSession *self)
|
sysprof_session_init (SysprofSession *self)
|
||||||
{
|
{
|
||||||
self->filter = gtk_every_filter_new ();
|
self->filter = gtk_every_filter_new ();
|
||||||
|
self->selected_time_axis = sysprof_value_axis_new (0, 0);
|
||||||
|
self->visible_time_axis = sysprof_value_axis_new (0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
SysprofSession *
|
SysprofSession *
|
||||||
@ -243,8 +289,38 @@ sysprof_session_select_time (SysprofSession *self,
|
|||||||
emit_for_visible = TRUE;
|
emit_for_visible = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sysprof_session_update_axis (self);
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED_TIME]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTED_TIME]);
|
||||||
|
|
||||||
if (emit_for_visible)
|
if (emit_for_visible)
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VISIBLE_TIME]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VISIBLE_TIME]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_session_get_selected_time_axis:
|
||||||
|
* @self: a #SysprofSession
|
||||||
|
*
|
||||||
|
* Returns: (transfer none) (nullable): a #SysprofAxis
|
||||||
|
*/
|
||||||
|
SysprofAxis *
|
||||||
|
sysprof_session_get_selected_time_axis (SysprofSession *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_SESSION (self), NULL);
|
||||||
|
|
||||||
|
return self->selected_time_axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sysprof_session_get_visible_time_axis:
|
||||||
|
* @self: a #SysprofSession
|
||||||
|
*
|
||||||
|
* Returns: (transfer none) (nullable): a #SysprofAxis
|
||||||
|
*/
|
||||||
|
SysprofAxis *
|
||||||
|
sysprof_session_get_visible_time_axis (SysprofSession *self)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (SYSPROF_IS_SESSION (self), NULL);
|
||||||
|
|
||||||
|
return self->visible_time_axis;
|
||||||
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include <sysprof-analyze.h>
|
#include <sysprof-analyze.h>
|
||||||
|
|
||||||
|
#include "sysprof-axis.h"
|
||||||
#include "sysprof-time-span.h"
|
#include "sysprof-time-span.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
@ -34,17 +35,21 @@ SYSPROF_AVAILABLE_IN_ALL
|
|||||||
G_DECLARE_FINAL_TYPE (SysprofSession, sysprof_session, SYSPROF, SESSION, GObject)
|
G_DECLARE_FINAL_TYPE (SysprofSession, sysprof_session, SYSPROF, SESSION, GObject)
|
||||||
|
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
SysprofSession *sysprof_session_new (SysprofDocument *document);
|
SysprofSession *sysprof_session_new (SysprofDocument *document);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
SysprofDocument *sysprof_session_get_document (SysprofSession *self);
|
SysprofDocument *sysprof_session_get_document (SysprofSession *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
GtkFilter *sysprof_session_get_filter (SysprofSession *self);
|
GtkFilter *sysprof_session_get_filter (SysprofSession *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
const SysprofTimeSpan *sysprof_session_get_selected_time (SysprofSession *self);
|
const SysprofTimeSpan *sysprof_session_get_selected_time (SysprofSession *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
const SysprofTimeSpan *sysprof_session_get_visible_time (SysprofSession *self);
|
const SysprofTimeSpan *sysprof_session_get_visible_time (SysprofSession *self);
|
||||||
SYSPROF_AVAILABLE_IN_ALL
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
void sysprof_session_select_time (SysprofSession *self,
|
SysprofAxis *sysprof_session_get_visible_time_axis (SysprofSession *self);
|
||||||
const SysprofTimeSpan *time_span);
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
SysprofAxis *sysprof_session_get_selected_time_axis (SysprofSession *self);
|
||||||
|
SYSPROF_AVAILABLE_IN_ALL
|
||||||
|
void sysprof_session_select_time (SysprofSession *self,
|
||||||
|
const SysprofTimeSpan *time_span);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user