mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
markvisualizer: port to GTK 4
This commit is contained in:
@ -70,25 +70,27 @@ sysprof_mark_visualizer_new (GHashTable *groups)
|
|||||||
return SYSPROF_VISUALIZER (g_steal_pointer (&self));
|
return SYSPROF_VISUALIZER (g_steal_pointer (&self));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static void
|
||||||
sysprof_mark_visualizer_draw (GtkWidget *widget,
|
sysprof_mark_visualizer_snapshot (GtkWidget *widget,
|
||||||
cairo_t *cr)
|
GtkSnapshot *snapshot)
|
||||||
{
|
{
|
||||||
SysprofMarkVisualizer *self = (SysprofMarkVisualizer *)widget;
|
SysprofMarkVisualizer *self = (SysprofMarkVisualizer *)widget;
|
||||||
SysprofVisualizer *vis = (SysprofVisualizer *)widget;
|
SysprofVisualizer *vis = (SysprofVisualizer *)widget;
|
||||||
|
static const GdkRGBA black = {0,0,0,1};
|
||||||
|
const GdkRGBA *rgba = &black;
|
||||||
GHashTableIter iter;
|
GHashTableIter iter;
|
||||||
GtkAllocation alloc;
|
GtkAllocation alloc;
|
||||||
gpointer k, v;
|
gpointer k, v;
|
||||||
gboolean ret;
|
int n_groups = 0;
|
||||||
gint n_groups = 0;
|
int y = 0;
|
||||||
gint y = 0;
|
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_MARK_VISUALIZER (self));
|
g_assert (SYSPROF_IS_MARK_VISUALIZER (self));
|
||||||
g_assert (cr != NULL);
|
g_assert (snapshot != NULL);
|
||||||
|
|
||||||
|
GTK_WIDGET_CLASS (sysprof_mark_visualizer_parent_class)->snapshot (widget, snapshot);
|
||||||
|
|
||||||
ret = GTK_WIDGET_CLASS (sysprof_mark_visualizer_parent_class)->draw (widget, cr);
|
|
||||||
if (self->spans_by_group == NULL)
|
if (self->spans_by_group == NULL)
|
||||||
return ret;
|
return;
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &alloc);
|
gtk_widget_get_allocation (widget, &alloc);
|
||||||
|
|
||||||
@ -117,19 +119,14 @@ sysprof_mark_visualizer_draw (GtkWidget *widget,
|
|||||||
g_hash_table_iter_init (&iter, self->spans_by_group);
|
g_hash_table_iter_init (&iter, self->spans_by_group);
|
||||||
while (g_hash_table_iter_next (&iter, &k, &v))
|
while (g_hash_table_iter_next (&iter, &k, &v))
|
||||||
{
|
{
|
||||||
static const GdkRGBA black = {0, 0, 0, 1};
|
|
||||||
SysprofMarkTimeSpan *span;
|
SysprofMarkTimeSpan *span;
|
||||||
const gchar *group = k;
|
const gchar *group = k;
|
||||||
const GArray *spans = v;
|
const GArray *spans = v;
|
||||||
const GdkRGBA *rgba;
|
|
||||||
const GdkRGBA *kindrgba;
|
const GdkRGBA *kindrgba;
|
||||||
const GdkRGBA *grouprgba;
|
const GdkRGBA *grouprgba;
|
||||||
|
|
||||||
if ((grouprgba = g_hash_table_lookup (self->rgba_by_group, group)))
|
if ((grouprgba = g_hash_table_lookup (self->rgba_by_group, group)))
|
||||||
{
|
rgba = grouprgba;
|
||||||
rgba = grouprgba;
|
|
||||||
gdk_cairo_set_source_rgba (cr, rgba);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (guint i = 0; i < spans->len; i++)
|
for (guint i = 0; i < spans->len; i++)
|
||||||
{
|
{
|
||||||
@ -144,7 +141,6 @@ sysprof_mark_visualizer_draw (GtkWidget *widget,
|
|||||||
rgba = kindrgba;
|
rgba = kindrgba;
|
||||||
else if ((grouprgba = g_hash_table_lookup (self->rgba_by_group, group)))
|
else if ((grouprgba = g_hash_table_lookup (self->rgba_by_group, group)))
|
||||||
rgba = grouprgba;
|
rgba = grouprgba;
|
||||||
gdk_cairo_set_source_rgba (cr, rgba);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
x1 = span->x;
|
x1 = span->x;
|
||||||
@ -180,31 +176,24 @@ sysprof_mark_visualizer_draw (GtkWidget *widget,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_rectangle (cr, x1, y, x2 - x1, RECT_HEIGHT);
|
gtk_snapshot_append_color (snapshot, rgba, &GRAPHENE_RECT_INIT (x1, y, x2 - x1, RECT_HEIGHT));
|
||||||
|
|
||||||
if (n_groups == 1)
|
|
||||||
cairo_fill (cr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (n_groups > 1)
|
|
||||||
cairo_fill (cr);
|
|
||||||
|
|
||||||
y += RECT_HEIGHT + RECT_OVERLAP;
|
y += RECT_HEIGHT + RECT_OVERLAP;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sysprof_mark_visualizer_size_allocate (GtkWidget *widget,
|
sysprof_mark_visualizer_size_allocate (GtkWidget *widget,
|
||||||
GtkAllocation *alloc)
|
int width,
|
||||||
|
int height,
|
||||||
|
int baseline)
|
||||||
{
|
{
|
||||||
SysprofMarkVisualizer *self = (SysprofMarkVisualizer *)widget;
|
SysprofMarkVisualizer *self = (SysprofMarkVisualizer *)widget;
|
||||||
|
|
||||||
g_assert (SYSPROF_IS_MARK_VISUALIZER (self));
|
g_assert (SYSPROF_IS_MARK_VISUALIZER (self));
|
||||||
g_assert (alloc != NULL);
|
|
||||||
|
|
||||||
GTK_WIDGET_CLASS (sysprof_mark_visualizer_parent_class)->size_allocate (widget, alloc);
|
GTK_WIDGET_CLASS (sysprof_mark_visualizer_parent_class)->size_allocate (widget, width, height, baseline);
|
||||||
|
|
||||||
reset_positions (self);
|
reset_positions (self);
|
||||||
}
|
}
|
||||||
@ -230,7 +219,7 @@ sysprof_mark_visualizer_class_init (SysprofMarkVisualizerClass *klass)
|
|||||||
|
|
||||||
object_class->finalize = sysprof_mark_visualizer_finalize;
|
object_class->finalize = sysprof_mark_visualizer_finalize;
|
||||||
|
|
||||||
widget_class->draw = sysprof_mark_visualizer_draw;
|
widget_class->snapshot = sysprof_mark_visualizer_snapshot;
|
||||||
widget_class->size_allocate = sysprof_mark_visualizer_size_allocate;
|
widget_class->size_allocate = sysprof_mark_visualizer_size_allocate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user