mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
libsysprof-ui: use textview for mark information
This commit is contained in:
@ -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
|
||||
|
||||
@ -26,6 +26,7 @@
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -202,9 +202,94 @@
|
||||
<property name="row">6</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkFrame">
|
||||
<property name="visible">True</property>
|
||||
<property name="shadow-type">in</property>
|
||||
<property name="margin-bottom">12</property>
|
||||
<child>
|
||||
<object class="GtkTreeView" id="marks_tree_view">
|
||||
<property name="model">marks_store</property>
|
||||
<property name="width-request">500</property>
|
||||
<property name="height-request">100</property>
|
||||
<property name="enable-grid-lines">both</property>
|
||||
<property name="visible">true</property>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="expand">true</property>
|
||||
<property name="title" translatable="yes">Mark</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">0</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Min</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Max</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">2</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn">
|
||||
<property name="title" translatable="yes">Avg</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText">
|
||||
<property name="xalign">0.0</property>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="text">3</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="column">center</property>
|
||||
<property name="row">7</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
<object class="GtkListStore" id="marks_store">
|
||||
<columns>
|
||||
<!-- column-name Mark -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Min -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Max -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Avg -->
|
||||
<column type="gchararray"/>
|
||||
</columns>
|
||||
</object>
|
||||
</interface>
|
||||
|
||||
Reference in New Issue
Block a user