mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2026-02-11 07:30:54 +00:00
libsysprof-gtk: add intermediate chart item
This will give us a place to deal with filtering as well as caching points based on the selected time range.
This commit is contained in:
@ -22,14 +22,16 @@
|
|||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "sysprof-mark-chart-item-private.h"
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define SYSPROF_TYPE_MARK_CHART_ROW (sysprof_mark_chart_row_get_type())
|
#define SYSPROF_TYPE_MARK_CHART_ROW (sysprof_mark_chart_row_get_type())
|
||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (SysprofMarkChartRow, sysprof_mark_chart_row, SYSPROF, MARK_CHART_ROW, GtkWidget)
|
G_DECLARE_FINAL_TYPE (SysprofMarkChartRow, sysprof_mark_chart_row, SYSPROF, MARK_CHART_ROW, GtkWidget)
|
||||||
|
|
||||||
GListModel *sysprof_mark_chart_row_get_model (SysprofMarkChartRow *self);
|
SysprofMarkChartItem *sysprof_mark_chart_row_get_item (SysprofMarkChartRow *self);
|
||||||
void sysprof_mark_chart_row_set_model (SysprofMarkChartRow *self,
|
void sysprof_mark_chart_row_set_item (SysprofMarkChartRow *self,
|
||||||
GListModel *model);
|
SysprofMarkChartItem *item);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|||||||
@ -27,12 +27,12 @@
|
|||||||
struct _SysprofMarkChartRow
|
struct _SysprofMarkChartRow
|
||||||
{
|
{
|
||||||
GtkWidget parent_instance;
|
GtkWidget parent_instance;
|
||||||
GListModel *model;
|
SysprofMarkChartItem *item;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_MODEL,
|
PROP_ITEM,
|
||||||
N_PROPS
|
N_PROPS
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,13 +57,13 @@ sysprof_mark_chart_row_snapshot (GtkWidget *widget,
|
|||||||
g_assert (SYSPROF_IS_MARK_CHART_ROW (self));
|
g_assert (SYSPROF_IS_MARK_CHART_ROW (self));
|
||||||
g_assert (GTK_IS_SNAPSHOT (snapshot));
|
g_assert (GTK_IS_SNAPSHOT (snapshot));
|
||||||
|
|
||||||
if (self->model == NULL)
|
if (self->item == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
width = gtk_widget_get_width (widget);
|
width = gtk_widget_get_width (widget);
|
||||||
height = gtk_widget_get_height (widget);
|
height = gtk_widget_get_height (widget);
|
||||||
|
|
||||||
model = G_LIST_MODEL (self->model);
|
model = sysprof_mark_chart_item_get_marks (self->item);
|
||||||
n_items = g_list_model_get_n_items (model);
|
n_items = g_list_model_get_n_items (model);
|
||||||
|
|
||||||
layout = gtk_widget_create_pango_layout (widget, NULL);
|
layout = gtk_widget_create_pango_layout (widget, NULL);
|
||||||
@ -110,12 +110,19 @@ sysprof_mark_chart_row_snapshot (GtkWidget *widget,
|
|||||||
g_object_unref (layout);
|
g_object_unref (layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
sysprof_mark_chart_row_queue_update (SysprofMarkChartRow *self)
|
||||||
|
{
|
||||||
|
g_assert (SYSPROF_IS_MARK_CHART_ROW (self));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sysprof_mark_chart_row_dispose (GObject *object)
|
sysprof_mark_chart_row_dispose (GObject *object)
|
||||||
{
|
{
|
||||||
SysprofMarkChartRow *self = (SysprofMarkChartRow *)object;
|
SysprofMarkChartRow *self = (SysprofMarkChartRow *)object;
|
||||||
|
|
||||||
g_clear_object (&self->model);
|
sysprof_mark_chart_row_set_item (self, NULL);
|
||||||
|
|
||||||
G_OBJECT_CLASS (sysprof_mark_chart_row_parent_class)->dispose (object);
|
G_OBJECT_CLASS (sysprof_mark_chart_row_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
@ -130,8 +137,8 @@ sysprof_mark_chart_row_get_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_MODEL:
|
case PROP_ITEM:
|
||||||
g_value_set_object (value, sysprof_mark_chart_row_get_model (self));
|
g_value_set_object (value, sysprof_mark_chart_row_get_item (self));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -149,8 +156,8 @@ sysprof_mark_chart_row_set_property (GObject *object,
|
|||||||
|
|
||||||
switch (prop_id)
|
switch (prop_id)
|
||||||
{
|
{
|
||||||
case PROP_MODEL:
|
case PROP_ITEM:
|
||||||
sysprof_mark_chart_row_set_model (self, g_value_get_object (value));
|
sysprof_mark_chart_row_set_item (self, g_value_get_object (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -170,9 +177,9 @@ sysprof_mark_chart_row_class_init (SysprofMarkChartRowClass *klass)
|
|||||||
|
|
||||||
widget_class->snapshot = sysprof_mark_chart_row_snapshot;
|
widget_class->snapshot = sysprof_mark_chart_row_snapshot;
|
||||||
|
|
||||||
properties [PROP_MODEL] =
|
properties [PROP_ITEM] =
|
||||||
g_param_spec_object ("model", NULL, NULL,
|
g_param_spec_object ("item", NULL, NULL,
|
||||||
G_TYPE_LIST_MODEL,
|
SYSPROF_TYPE_MARK_CHART_ITEM,
|
||||||
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
(G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||||
@ -183,39 +190,39 @@ sysprof_mark_chart_row_init (SysprofMarkChartRow *self)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
GListModel *
|
SysprofMarkChartItem *
|
||||||
sysprof_mark_chart_row_get_model (SysprofMarkChartRow *self)
|
sysprof_mark_chart_row_get_item (SysprofMarkChartRow *self)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (SYSPROF_IS_MARK_CHART_ROW (self), NULL);
|
g_return_val_if_fail (SYSPROF_IS_MARK_CHART_ROW (self), NULL);
|
||||||
|
|
||||||
return self->model;
|
return self->item;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sysprof_mark_chart_row_set_model (SysprofMarkChartRow *self,
|
sysprof_mark_chart_row_set_item (SysprofMarkChartRow *self,
|
||||||
GListModel *model)
|
SysprofMarkChartItem *item)
|
||||||
{
|
{
|
||||||
g_return_if_fail (SYSPROF_IS_MARK_CHART_ROW (self));
|
g_return_if_fail (SYSPROF_IS_MARK_CHART_ROW (self));
|
||||||
g_return_if_fail (!model || G_IS_LIST_MODEL (model));
|
g_return_if_fail (!item || SYSPROF_IS_MARK_CHART_ITEM (item));
|
||||||
|
|
||||||
if (self->model == model)
|
if (self->item == item)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (self->model)
|
if (self->item)
|
||||||
g_signal_handlers_disconnect_by_func (self->model,
|
g_signal_handlers_disconnect_by_func (sysprof_mark_chart_item_get_marks (self->item),
|
||||||
G_CALLBACK (gtk_widget_queue_allocate),
|
G_CALLBACK (sysprof_mark_chart_row_queue_update),
|
||||||
self);
|
self);
|
||||||
|
|
||||||
g_set_object (&self->model, model);
|
g_set_object (&self->item, item);
|
||||||
|
|
||||||
if (model)
|
if (item)
|
||||||
g_signal_connect_object (model,
|
g_signal_connect_object (sysprof_mark_chart_item_get_marks (item),
|
||||||
"items-changed",
|
"items-changed",
|
||||||
G_CALLBACK (gtk_widget_queue_allocate),
|
G_CALLBACK (sysprof_mark_chart_row_queue_update),
|
||||||
self,
|
self,
|
||||||
G_CONNECT_SWAPPED);
|
G_CONNECT_SWAPPED);
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MODEL]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ITEM]);
|
||||||
|
|
||||||
gtk_widget_queue_allocate (GTK_WIDGET (self));
|
sysprof_mark_chart_row_queue_update (self);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -62,10 +62,8 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="SysprofMarkChartRow">
|
<object class="SysprofMarkChartRow">
|
||||||
<property name="hexpand">true</property>
|
<property name="hexpand">true</property>
|
||||||
<binding name="model">
|
<binding name="item">
|
||||||
<lookup name="marks" type="SysprofMarkChartItem">
|
<lookup name="item">GtkListItem</lookup>
|
||||||
<lookup name="item">GtkListItem</lookup>
|
|
||||||
</lookup>
|
|
||||||
</binding>
|
</binding>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|||||||
Reference in New Issue
Block a user