From 09f7be93567dac8a011fd88dde3d92d122182774 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Fri, 17 May 2019 18:28:05 -0700 Subject: [PATCH] libsysprof-ui: use threegrid for details This allows us to tweak the design of the marks. --- src/libsysprof-ui/sysprof-capture-view.c | 90 +++-- src/libsysprof-ui/sysprof-details-view.c | 54 +-- src/libsysprof-ui/ui/sysprof-details-view.ui | 351 ++++++++++--------- 3 files changed, 279 insertions(+), 216 deletions(-) diff --git a/src/libsysprof-ui/sysprof-capture-view.c b/src/libsysprof-ui/sysprof-capture-view.c index 01b96be0..1066e5b7 100644 --- a/src/libsysprof-ui/sysprof-capture-view.c +++ b/src/libsysprof-ui/sysprof-capture-view.c @@ -145,6 +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; @@ -157,46 +159,78 @@ 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)) { - g_autofree gchar *str = NULL; SysprofMarkStat *st = v; - GtkLabel *left_label; - GtkLabel *center_label; + 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); if (st->avg == 0) continue; - left_label = g_object_new (GTK_TYPE_LABEL, - "selectable", TRUE, - "visible", TRUE, - "xalign", 1.0f, - "label", st->name, - "ellipsize", PANGO_ELLIPSIZE_START, - NULL); - gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (left_label)), - GTK_STYLE_CLASS_DIM_LABEL); - str = g_strdup_printf ("Min: %.4lf " - "Max: %.4lf " - "Ø: %.4lf", - st->min / (gdouble)NSEC_PER_SEC, - st->max / (gdouble)NSEC_PER_SEC, - st->avg / (gdouble)NSEC_PER_SEC); - center_label = g_object_new (GTK_TYPE_LABEL, - "label", str, - "selectable", TRUE, - "use-markup", TRUE, - "visible", TRUE, - "xalign", 0.0f, - NULL); + 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, - GTK_WIDGET (left_label), - GTK_WIDGET (center_label)); + 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, + "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, + "xalign", 0.0f, + "visible", TRUE, + NULL)); + + sysprof_details_view_add_item (priv->details_view, + g_object_new (GTK_TYPE_LABEL, + "attributes", dim_attrs, + "label", "Ø", + "xalign", 1.0f, + "visible", TRUE, + NULL), + g_object_new (GTK_TYPE_LABEL, + "label", avgstr, + "xalign", 0.0f, + "visible", TRUE, + NULL)); count++; } + + pango_attr_list_unref (attrs); + pango_attr_list_unref (dim_attrs); } static void @@ -961,8 +995,6 @@ sysprof_capture_view_fit_to_width (SysprofCaptureView *self) duration = priv->features.end_time - priv->features.begin_time; - g_print ("DURATION: %ld\n", duration); - if (duration <= 0) return; diff --git a/src/libsysprof-ui/sysprof-details-view.c b/src/libsysprof-ui/sysprof-details-view.c index d09ccbb5..480a9cb3 100644 --- a/src/libsysprof-ui/sysprof-details-view.c +++ b/src/libsysprof-ui/sysprof-details-view.c @@ -22,6 +22,7 @@ #include "config.h" +#include #include #include "sysprof-details-view.h" @@ -30,19 +31,19 @@ struct _SysprofDetailsView { - GtkBin parent_instance; + GtkBin parent_instance; /* Template Objects */ - GtkBox *left_box; - GtkBox *center_box; - GtkLabel *duration; - GtkLabel *filename; - GtkLabel *forks; - GtkLabel *marks; - GtkLabel *processes; - GtkLabel *samples; - GtkLabel *start_time; - GtkBox *vbox; + DzlThreeGrid *three_grid; + GtkLabel *duration; + GtkLabel *filename; + GtkLabel *forks; + GtkLabel *marks; + GtkLabel *processes; + GtkLabel *samples; + GtkLabel *start_time; + + guint next_row; }; G_DEFINE_TYPE (SysprofDetailsView, sysprof_details_view, GTK_TYPE_BIN) @@ -92,15 +93,17 @@ sysprof_details_view_class_init (SysprofDetailsViewClass *klass) 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); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, vbox); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, left_box); - gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, center_box); + gtk_widget_class_bind_template_child (widget_class, SysprofDetailsView, three_grid); + + g_type_ensure (DZL_TYPE_THREE_GRID); } static void sysprof_details_view_init (SysprofDetailsView *self) { gtk_widget_init_template (GTK_WIDGET (self)); + + self->next_row = 7; } GtkWidget * @@ -165,13 +168,20 @@ sysprof_details_view_add_item (SysprofDetailsView *self, GtkWidget *center) { g_return_if_fail (SYSPROF_IS_DETAILS_VIEW (self)); - g_return_if_fail (GTK_IS_WIDGET (left)); - g_return_if_fail (GTK_IS_WIDGET (center)); + g_return_if_fail (!left || GTK_IS_WIDGET (left)); + g_return_if_fail (!center || GTK_IS_WIDGET (center)); - gtk_container_add_with_properties (GTK_CONTAINER (self->left_box), left, - "pack-type", GTK_PACK_START, - "expand", TRUE, - "fill", TRUE, - NULL); - gtk_container_add (GTK_CONTAINER (self->center_box), center); + if (left) + gtk_container_add_with_properties (GTK_CONTAINER (self->three_grid), left, + "row", self->next_row, + "column", DZL_THREE_GRID_COLUMN_LEFT, + NULL); + + if (center) + gtk_container_add_with_properties (GTK_CONTAINER (self->three_grid), center, + "row", self->next_row, + "column", DZL_THREE_GRID_COLUMN_CENTER, + NULL); + + self->next_row++; } diff --git a/src/libsysprof-ui/ui/sysprof-details-view.ui b/src/libsysprof-ui/ui/sysprof-details-view.ui index 87652dd6..16382d75 100644 --- a/src/libsysprof-ui/ui/sysprof-details-view.ui +++ b/src/libsysprof-ui/ui/sysprof-details-view.ui @@ -10,176 +10,197 @@ true true - + 36 - True - False - vertical + 12 + 6 + true - + + true + Filename + 1 + + + + left + 0 + + + + + true + Captured at + 1 + + + + left + 1 + + + + True False - 12 - - - True - False - end - vertical - 6 - - - True - False - Filename - 1 - - - - - - True - False - Captured At - 1 - - - - - - True - False - Duration - 1 - - - - - - 12 - True - False - Samples Captured - 1 - - - - - - True - False - Marks Captured - 1 - - - - - - True - False - Processes Captured - 1 - - - - - - True - False - 12 - Forks Captured - 1 - - - - - - start - 0 - true - true - - - - - True - False - vertical - 6 - - - True - False - start - 0 - - - - - True - False - start - 0 - - - - - True - False - 0 - - - - - 12 - True - False - start - 0 - - - - - True - False - start - 0 - - - - - True - False - start - 0 - - - - - True - False - start - 12 - 0 - - - - + Duration + 1 + + + left + 2 + + + + + 12 + True + Samples Captured + 1 + + + + left + 3 + + + + + True + Marks Captured + 1 + + + + left + 4 + + + + + True + Processes Captured + 1 + + + + left + 5 + + + + + True + 12 + Forks Captured + 1 + + + + left + 6 + + + + + 35 + True + False + start + 0 + + + 1 + 0 + + + + + True + False + start + 0 + + + center + 1 + + + + + True + False + 0 + + + center + 2 + + + + + 12 + True + False + start + 0 + + + center + 3 + + + + + True + False + start + 0 + + + center + 4 + + + + + True + False + start + 0 + + + center + 5 + + + + + True + False + start + 12 + 0 + + + center + 6 +