mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Merge branch 'gbsneto/mark-name-in-waterfall' into 'master'
sysprof: show mark name in waterfall marks See merge request GNOME/sysprof!98
This commit is contained in:
@ -83,3 +83,7 @@ timescrubber timecode {
|
||||
flamegraph {
|
||||
font-size: 11px;
|
||||
}
|
||||
|
||||
timespanlayer {
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
@ -42,6 +42,25 @@ struct _SysprofMarksSection
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofMarksSection, sysprof_marks_section, SYSPROF_TYPE_SECTION)
|
||||
|
||||
static char *
|
||||
format_mark_label (gpointer unused,
|
||||
SysprofDocumentMark *mark)
|
||||
{
|
||||
const char *message;
|
||||
const char *name;
|
||||
|
||||
if (mark == NULL)
|
||||
return NULL;
|
||||
|
||||
name = sysprof_document_mark_get_name (mark);
|
||||
message = sysprof_document_mark_get_message (mark);
|
||||
|
||||
if (name && *name && message && *message)
|
||||
return g_strdup_printf ("%s – %s", name, message);
|
||||
else
|
||||
return g_strdup_printf ("%s", name);
|
||||
}
|
||||
|
||||
static char *
|
||||
format_number (gpointer unused,
|
||||
guint number)
|
||||
@ -74,6 +93,7 @@ sysprof_marks_section_class_init (SysprofMarksSectionClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofMarksSection, mark_table);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofMarksSection, median_column);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofMarksSection, summary_column_view);
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_mark_label);
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_number);
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_CHART);
|
||||
|
||||
@ -175,9 +175,9 @@
|
||||
</object>
|
||||
</property>
|
||||
<property name="label-expression">
|
||||
<lookup name="message" type="SysprofDocumentMark">
|
||||
<closure type="gchararray" function="format_mark_label">
|
||||
<lookup name="item" type="SysprofSessionModelItem"/>
|
||||
</lookup>
|
||||
</closure>
|
||||
</property>
|
||||
<property name="begin-time-expression">
|
||||
<lookup name="time" type="SysprofDocumentMark">
|
||||
|
||||
@ -330,7 +330,6 @@ sysprof_time_series_dup_label (SysprofTimeSeries *self,
|
||||
if (!(item = g_list_model_get_item (model, position)))
|
||||
return NULL;
|
||||
|
||||
g_value_init (&value, G_TYPE_STRING);
|
||||
gtk_expression_evaluate (self->label_expression, item, &value);
|
||||
return g_value_dup_string (&value);
|
||||
}
|
||||
|
||||
@ -216,12 +216,28 @@ sysprof_time_span_layer_snapshot (GtkWidget *widget,
|
||||
gtk_snapshot_append_color (snapshot, color, &rect);
|
||||
}
|
||||
|
||||
if (rect.size.width > 20)
|
||||
if (label != NULL)
|
||||
{
|
||||
gboolean rect_fits_text;
|
||||
int right_empty_space;
|
||||
int label_width;
|
||||
|
||||
if (label != NULL)
|
||||
pango_layout_set_text (layout, label, -1);
|
||||
pango_layout_set_alignment (layout, PANGO_ALIGN_LEFT);
|
||||
|
||||
pango_layout_get_pixel_size (layout, &label_width, NULL);
|
||||
|
||||
/* If it fits 75% of the text inside the rect, it's enough and
|
||||
* won't look too busy.
|
||||
*/
|
||||
rect_fits_text = ((rect.size.width - 6) / (float) label_width) > 0.75;
|
||||
right_empty_space = width - (rect.origin.x + rect.size.width) - 6;
|
||||
|
||||
/* Draw inside the rect if the label fits, or if there's not more
|
||||
* space outside the rect.
|
||||
*/
|
||||
if (rect_fits_text || (rect.size.width - 6) > right_empty_space)
|
||||
{
|
||||
pango_layout_set_text (layout, label, -1);
|
||||
pango_layout_set_width (layout, (rect.size.width - 6) * PANGO_SCALE);
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
@ -229,6 +245,15 @@ sysprof_time_span_layer_snapshot (GtkWidget *widget,
|
||||
gtk_snapshot_append_layout (snapshot, layout, label_color);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
else if (n_values == 1 && right_empty_space > 20)
|
||||
{
|
||||
pango_layout_set_width (layout, right_empty_space * PANGO_SCALE);
|
||||
|
||||
gtk_snapshot_save (snapshot);
|
||||
gtk_snapshot_translate (snapshot, &GRAPHENE_POINT_INIT (rect.origin.x + rect.size.width + 3, layout_y));
|
||||
gtk_snapshot_append_layout (snapshot, layout, label_color);
|
||||
gtk_snapshot_restore (snapshot);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -472,6 +497,8 @@ sysprof_time_span_layer_class_init (SysprofTimeSpanLayerClass *klass)
|
||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, "timespanlayer");
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
Reference in New Issue
Block a user