mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
sysprof: add indicators to various sections
This helps seeing at a glance if a recording when a bit sideways.
This commit is contained in:
@ -108,3 +108,13 @@ tracks row track info {
|
||||
.utility .view {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.navigation-sidebar label.indicator {
|
||||
background: alpha(@accent_bg_color, .5);
|
||||
color: @accent_fg_color;
|
||||
border-radius: 50px;
|
||||
padding: 1px 5px;
|
||||
font-feature-settings: 'tnum';
|
||||
font-size: .8em;
|
||||
border: 1px solid alpha(@accent_bg_color,.6);
|
||||
}
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
|
||||
#include <sysprof-gtk.h>
|
||||
|
||||
#include "sysprof-document-bitset-index-private.h"
|
||||
#include "sysprof-frame-utility.h"
|
||||
#include "sysprof-logs-section.h"
|
||||
|
||||
@ -75,6 +76,13 @@ sysprof_logs_section_activate_layer_item_cb (SysprofLogsSection *self,
|
||||
}
|
||||
}
|
||||
|
||||
static char *
|
||||
format_number (gpointer unused,
|
||||
guint number)
|
||||
{
|
||||
return g_strdup_printf ("%'u", number);
|
||||
}
|
||||
|
||||
static char *
|
||||
format_severity (gpointer unused,
|
||||
GLogLevelFlags severity)
|
||||
@ -121,9 +129,11 @@ sysprof_logs_section_class_init (SysprofLogsSectionClass *klass)
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-logs-section.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofLogsSection, column_view);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofLogsSection, time_column);
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_number);
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_severity);
|
||||
gtk_widget_class_bind_template_callback (widget_class, sysprof_logs_section_activate_layer_item_cb);
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_DOCUMENT_BITSET_INDEX);
|
||||
g_type_ensure (SYSPROF_TYPE_DOCUMENT_LOG);
|
||||
g_type_ensure (SYSPROF_TYPE_FRAME_UTILITY);
|
||||
g_type_ensure (SYSPROF_TYPE_TIME_LABEL);
|
||||
|
||||
@ -2,6 +2,17 @@
|
||||
<interface>
|
||||
<template class="SysprofLogsSection" parent="SysprofSection">
|
||||
<property name="title" translatable="yes">Logs</property>
|
||||
<binding name="indicator">
|
||||
<closure type="gchararray" function="format_number">
|
||||
<lookup name="n-items" type="SysprofDocumentBitsetIndex">
|
||||
<lookup name="logs" type="SysprofDocument">
|
||||
<lookup name="document" type="SysprofSession">
|
||||
<lookup name="session">SysprofLogsSection</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
@ -34,6 +34,13 @@ struct _SysprofMarksSection
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofMarksSection, sysprof_marks_section, SYSPROF_TYPE_SECTION)
|
||||
|
||||
static char *
|
||||
format_number (gpointer unused,
|
||||
guint number)
|
||||
{
|
||||
return g_strdup_printf ("%'u", number);
|
||||
}
|
||||
|
||||
static void
|
||||
sysprof_marks_section_dispose (GObject *object)
|
||||
{
|
||||
@ -55,6 +62,7 @@ sysprof_marks_section_class_init (SysprofMarksSectionClass *klass)
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-marks-section.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofMarksSection, mark_chart);
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofMarksSection, mark_table);
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_number);
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_CHART);
|
||||
g_type_ensure (SYSPROF_TYPE_DOCUMENT_MARK);
|
||||
|
||||
@ -2,6 +2,17 @@
|
||||
<interface>
|
||||
<template class="SysprofMarksSection" parent="SysprofSection">
|
||||
<property name="title" translatable="yes">Marks</property>
|
||||
<binding name="indicator">
|
||||
<closure type="gchararray" function="format_number">
|
||||
<lookup name="n-items" type="SysprofDocumentBitsetIndex">
|
||||
<lookup name="marks" type="SysprofDocument">
|
||||
<lookup name="document" type="SysprofSession">
|
||||
<lookup name="session">SysprofMarksSection</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
@ -38,6 +38,13 @@ struct _SysprofProcessesSection
|
||||
|
||||
G_DEFINE_FINAL_TYPE (SysprofProcessesSection, sysprof_processes_section, SYSPROF_TYPE_SECTION)
|
||||
|
||||
static char *
|
||||
format_number (gpointer unused,
|
||||
guint number)
|
||||
{
|
||||
return g_strdup_printf ("%'u", number);
|
||||
}
|
||||
|
||||
static void
|
||||
activate_layer_item_cb (GtkListItem *list_item,
|
||||
SysprofChartLayer *layer,
|
||||
@ -84,6 +91,7 @@ sysprof_processes_section_class_init (SysprofProcessesSectionClass *klass)
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/sysprof/sysprof-processes-section.ui");
|
||||
gtk_widget_class_bind_template_child (widget_class, SysprofProcessesSection, list_view);
|
||||
gtk_widget_class_bind_template_callback (widget_class, activate_layer_item_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_number);
|
||||
|
||||
g_type_ensure (SYSPROF_TYPE_CHART);
|
||||
g_type_ensure (SYSPROF_TYPE_CHART_LAYER);
|
||||
|
||||
@ -2,6 +2,17 @@
|
||||
<interface>
|
||||
<template class="SysprofProcessesSection" parent="SysprofSection">
|
||||
<property name="title" translatable="yes">Processes</property>
|
||||
<binding name="indicator">
|
||||
<closure type="gchararray" function="format_number">
|
||||
<lookup name="n-items" type="SysprofDocumentBitsetIndex">
|
||||
<lookup name="processes" type="SysprofDocument">
|
||||
<lookup name="document" type="SysprofSession">
|
||||
<lookup name="session">SysprofProcessesSection</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
</lookup>
|
||||
</closure>
|
||||
</binding>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
@ -27,6 +27,7 @@ typedef struct
|
||||
{
|
||||
char *category;
|
||||
char *icon_name;
|
||||
char *indicator;
|
||||
char *title;
|
||||
SysprofSession *session;
|
||||
GtkWidget *utility;
|
||||
@ -39,6 +40,7 @@ enum {
|
||||
PROP_SESSION,
|
||||
PROP_CATEGORY,
|
||||
PROP_ICON_NAME,
|
||||
PROP_INDICATOR,
|
||||
PROP_TITLE,
|
||||
PROP_UTILITY,
|
||||
N_PROPS
|
||||
@ -61,6 +63,7 @@ sysprof_section_dispose (GObject *object)
|
||||
g_clear_pointer (&priv->title, g_free);
|
||||
g_clear_pointer (&priv->category, g_free);
|
||||
g_clear_pointer (&priv->icon_name, g_free);
|
||||
g_clear_pointer (&priv->indicator, g_free);
|
||||
|
||||
G_OBJECT_CLASS (sysprof_section_parent_class)->dispose (object);
|
||||
}
|
||||
@ -83,6 +86,10 @@ sysprof_section_get_property (GObject *object,
|
||||
g_value_set_string (value, sysprof_section_get_category (self));
|
||||
break;
|
||||
|
||||
case PROP_INDICATOR:
|
||||
g_value_set_string (value, sysprof_section_get_indicator (self));
|
||||
break;
|
||||
|
||||
case PROP_ICON_NAME:
|
||||
g_value_set_string (value, sysprof_section_get_icon_name (self));
|
||||
break;
|
||||
@ -122,6 +129,10 @@ sysprof_section_set_property (GObject *object,
|
||||
sysprof_section_set_icon_name (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_INDICATOR:
|
||||
sysprof_section_set_indicator (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_TITLE:
|
||||
sysprof_section_set_title (self, g_value_get_string (value));
|
||||
break;
|
||||
@ -165,6 +176,11 @@ sysprof_section_class_init (SysprofSectionClass *klass)
|
||||
NULL,
|
||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties[PROP_INDICATOR] =
|
||||
g_param_spec_string ("indicator", NULL, NULL,
|
||||
NULL,
|
||||
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
|
||||
|
||||
properties[PROP_UTILITY] =
|
||||
g_param_spec_object ("utility", NULL, NULL,
|
||||
GTK_TYPE_WIDGET,
|
||||
@ -269,6 +285,28 @@ sysprof_section_set_icon_name (SysprofSection *self,
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ICON_NAME]);
|
||||
}
|
||||
|
||||
const char *
|
||||
sysprof_section_get_indicator (SysprofSection *self)
|
||||
{
|
||||
SysprofSectionPrivate *priv = sysprof_section_get_instance_private (self);
|
||||
|
||||
g_return_val_if_fail (SYSPROF_IS_SECTION (self), NULL);
|
||||
|
||||
return priv->indicator;
|
||||
}
|
||||
|
||||
void
|
||||
sysprof_section_set_indicator (SysprofSection *self,
|
||||
const char *indicator)
|
||||
{
|
||||
SysprofSectionPrivate *priv = sysprof_section_get_instance_private (self);
|
||||
|
||||
g_return_if_fail (SYSPROF_IS_SECTION (self));
|
||||
|
||||
if (g_set_str (&priv->indicator, indicator))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INDICATOR]);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
sysprof_section_get_utility (SysprofSection *self)
|
||||
{
|
||||
|
||||
@ -44,6 +44,9 @@ void sysprof_section_set_category (SysprofSection *self,
|
||||
const char *sysprof_section_get_icon_name (SysprofSection *self);
|
||||
void sysprof_section_set_icon_name (SysprofSection *self,
|
||||
const char *icon_name);
|
||||
const char *sysprof_section_get_indicator (SysprofSection *self);
|
||||
void sysprof_section_set_indicator (SysprofSection *self,
|
||||
const char *indicator);
|
||||
const char *sysprof_section_get_title (SysprofSection *self);
|
||||
void sysprof_section_set_title (SysprofSection *self,
|
||||
const char *title);
|
||||
|
||||
@ -40,6 +40,16 @@ G_DEFINE_FINAL_TYPE (SysprofSidebar, sysprof_sidebar, GTK_TYPE_WIDGET)
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
static gboolean
|
||||
string_to_boolean (GBinding *binding,
|
||||
const GValue *from_value,
|
||||
GValue *to_value,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_value_set_boolean (to_value, !!g_value_get_string (from_value));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
sysprof_sidebar_create_row (gpointer item,
|
||||
gpointer user_data)
|
||||
@ -48,6 +58,7 @@ sysprof_sidebar_create_row (gpointer item,
|
||||
SysprofSidebar *sidebar = user_data;
|
||||
SysprofSection *section;
|
||||
GtkListBoxRow *row;
|
||||
GtkLabel *indicator;
|
||||
GtkImage *image;
|
||||
GtkLabel *label;
|
||||
GtkBox *box;
|
||||
@ -64,12 +75,26 @@ sysprof_sidebar_create_row (gpointer item,
|
||||
label = g_object_new (GTK_TYPE_LABEL,
|
||||
"xalign", .0f,
|
||||
"label", sysprof_section_get_title (section),
|
||||
"hexpand", TRUE,
|
||||
NULL);
|
||||
image = g_object_new (GTK_TYPE_IMAGE,
|
||||
"icon-name", sysprof_section_get_icon_name (section),
|
||||
NULL);
|
||||
indicator = g_object_new (GTK_TYPE_LABEL,
|
||||
"css-classes", (const char * const[]) {"indicator", NULL},
|
||||
"valign", GTK_ALIGN_CENTER,
|
||||
NULL);
|
||||
gtk_box_append (box, GTK_WIDGET (image));
|
||||
gtk_box_append (box, GTK_WIDGET (label));
|
||||
gtk_box_append (box, GTK_WIDGET (indicator));
|
||||
|
||||
g_object_bind_property (section, "indicator",
|
||||
indicator, "label",
|
||||
G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property_full (section, "indicator",
|
||||
indicator, "visible",
|
||||
G_BINDING_SYNC_CREATE,
|
||||
string_to_boolean, NULL, NULL, NULL);
|
||||
|
||||
row = g_object_new (GTK_TYPE_LIST_BOX_ROW,
|
||||
"child", box,
|
||||
|
||||
Reference in New Issue
Block a user