sysprof: add helper to get category color

This commit is contained in:
Christian Hergert
2023-08-23 15:25:07 -07:00
parent be2970929f
commit 9de7199373
2 changed files with 16 additions and 0 deletions

View File

@ -168,3 +168,17 @@ sysprof_category_icon_set_category (SysprofCategoryIcon *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CATEGORY]);
gtk_widget_queue_draw (GTK_WIDGET (self));
}
const GdkRGBA *
sysprof_callgraph_category_get_color (SysprofCallgraphCategory category)
{
static GdkRGBA gray;
if (category < G_N_ELEMENTS (category_colors) && category_colors[category].alpha > 0)
return &category_colors[category];
if (gray.alpha == 0)
gdk_rgba_parse (&gray, "#77767b");
return &gray;
}

View File

@ -34,4 +34,6 @@ SysprofCallgraphCategory sysprof_category_icon_get_category (SysprofCategoryIcon
void sysprof_category_icon_set_category (SysprofCategoryIcon *self,
SysprofCallgraphCategory category);
const GdkRGBA *sysprof_callgraph_category_get_color (SysprofCallgraphCategory category);
G_END_DECLS