diff --git a/src/libsysprof-ui/sysprof-capture-view.c b/src/libsysprof-ui/sysprof-capture-view.c index 6a0f315c..c70b4998 100644 --- a/src/libsysprof-ui/sysprof-capture-view.c +++ b/src/libsysprof-ui/sysprof-capture-view.c @@ -145,11 +145,8 @@ static void add_marks_to_details (SysprofCaptureView *self) { SysprofCaptureViewPrivate *priv = sysprof_capture_view_get_instance_private (self); - PangoAttrList *attrs; - PangoAttrList *dim_attrs; GHashTableIter iter; gpointer k, v; - guint count = 0; g_assert (SYSPROF_IS_CAPTURE_VIEW (self)); @@ -159,81 +156,14 @@ add_marks_to_details (SysprofCaptureView *self) if (g_hash_table_size (priv->mark_stats) == 0) return; - attrs = pango_attr_list_new (); - pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); - pango_attr_list_insert (attrs, pango_attr_foreground_alpha_new (65535/2)); - - dim_attrs = pango_attr_list_new (); - pango_attr_list_insert (dim_attrs, pango_attr_foreground_alpha_new (65535/2)); - g_hash_table_iter_init (&iter, priv->mark_stats); - while (count < 100 && g_hash_table_iter_next (&iter, &k, &v)) + while (g_hash_table_iter_next (&iter, &k, &v)) { - SysprofMarkStat *st = v; - g_autofree gchar *minstr = _sysprof_format_duration (st->min); - g_autofree gchar *maxstr = _sysprof_format_duration (st->max); - g_autofree gchar *avgstr = _sysprof_format_duration (st->avg); + const gchar *name = k; + const SysprofMarkStat *st = v; - if (st->avg == 0) - continue; - - sysprof_details_view_add_item (priv->details_view, - g_object_new (GTK_TYPE_LABEL, - "margin-top", 6, - "label", st->name, - "attributes", attrs, - "xalign", 1.0f, - "visible", TRUE, - NULL), - NULL); - - sysprof_details_view_add_item (priv->details_view, - g_object_new (GTK_TYPE_LABEL, - "attributes", dim_attrs, - "label", "Min", - "xalign", 1.0f, - "visible", TRUE, - NULL), - g_object_new (GTK_TYPE_LABEL, - "label", minstr, - "selectable", TRUE, - "xalign", 0.0f, - "visible", TRUE, - NULL)); - - sysprof_details_view_add_item (priv->details_view, - g_object_new (GTK_TYPE_LABEL, - "attributes", dim_attrs, - "label", "Max", - "xalign", 1.0f, - "visible", TRUE, - NULL), - g_object_new (GTK_TYPE_LABEL, - "label", maxstr, - "selectable", TRUE, - "xalign", 0.0f, - "visible", TRUE, - NULL)); - - sysprof_details_view_add_item (priv->details_view, - g_object_new (GTK_TYPE_LABEL, - "attributes", dim_attrs, - "label", "Avg", - "xalign", 1.0f, - "visible", TRUE, - NULL), - g_object_new (GTK_TYPE_LABEL, - "label", avgstr, - "selectable", TRUE, - "xalign", 0.0f, - "visible", TRUE, - NULL)); - - count++; + sysprof_details_view_add_mark (priv->details_view, name, st->min, st->max, st->avg); } - - pango_attr_list_unref (attrs); - pango_attr_list_unref (dim_attrs); } static void diff --git a/src/libsysprof-ui/sysprof-details-view.c b/src/libsysprof-ui/sysprof-details-view.c index 480a9cb3..8a55942c 100644 --- a/src/libsysprof-ui/sysprof-details-view.c +++ b/src/libsysprof-ui/sysprof-details-view.c @@ -26,6 +26,7 @@ #include #include "sysprof-details-view.h" +#include "sysprof-ui-private.h" #define NSEC_PER_SEC (G_USEC_PER_SEC * 1000L) @@ -35,6 +36,7 @@ struct _SysprofDetailsView /* Template Objects */ DzlThreeGrid *three_grid; + GtkListStore *marks_store; GtkLabel *duration; GtkLabel *filename; GtkLabel *forks; @@ -90,6 +92,7 @@ sysprof_details_view_class_init (SysprofDetailsViewClass *klass) gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, filename); gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, forks); gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, marks); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, marks_store); gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, processes); gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, samples); gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, start_time); @@ -103,7 +106,7 @@ sysprof_details_view_init (SysprofDetailsView *self) { gtk_widget_init_template (GTK_WIDGET (self)); - self->next_row = 7; + self->next_row = 8; } GtkWidget * @@ -185,3 +188,23 @@ sysprof_details_view_add_item (SysprofDetailsView *self, self->next_row++; } + +void +sysprof_details_view_add_mark (SysprofDetailsView *self, + const gchar *mark, + gint64 min, + gint64 max, + gint64 avg) +{ + GtkTreeIter iter; + + g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self)); + + gtk_list_store_append (self->marks_store, &iter); + gtk_list_store_set (self->marks_store, &iter, + 0, mark, + 1, min ? _sysprof_format_duration (min) : "—", + 2, max ? _sysprof_format_duration (max) : "—", + 3, avg ? _sysprof_format_duration (avg) : "—", + -1); +} diff --git a/src/libsysprof-ui/sysprof-details-view.h b/src/libsysprof-ui/sysprof-details-view.h index defe8bf8..993b08ff 100644 --- a/src/libsysprof-ui/sysprof-details-view.h +++ b/src/libsysprof-ui/sysprof-details-view.h @@ -32,6 +32,11 @@ G_DECLARE_FINAL_TYPE (SysprofDetailsView, sysprof_details_view, SYSPROF, DETAILS GtkWidget *sysprof_details_view_new (void); void sysprof_details_view_set_reader (SysprofDetailsView *self, SysprofCaptureReader *reader); +void sysprof_details_view_add_mark (SysprofDetailsView *self, + const gchar *mark, + gint64 min, + gint64 max, + gint64 avg); void sysprof_details_view_add_item (SysprofDetailsView *self, GtkWidget *left, GtkWidget *center); diff --git a/src/libsysprof-ui/ui/sysprof-details-view.ui b/src/libsysprof-ui/ui/sysprof-details-view.ui index 16382d75..71dffeb3 100644 --- a/src/libsysprof-ui/ui/sysprof-details-view.ui +++ b/src/libsysprof-ui/ui/sysprof-details-view.ui @@ -202,9 +202,94 @@ 6 + + + True + in + 12 + + + marks_store + 500 + 100 + both + true + + + true + Mark + + + 0.0 + + + 0 + + + + + + + Min + + + 0.0 + + + 1 + + + + + + + Max + + + 0.0 + + + 2 + + + + + + + Avg + + + 0.0 + + + 3 + + + + + + + + + center + 7 + + + + + + + + + + + + + +