From 9de7199373e48912faabc419b39e5593f956ec78 Mon Sep 17 00:00:00 2001 From: Christian Hergert Date: Wed, 23 Aug 2023 15:25:07 -0700 Subject: [PATCH] sysprof: add helper to get category color --- src/sysprof/sysprof-category-icon.c | 14 ++++++++++++++ src/sysprof/sysprof-category-icon.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/src/sysprof/sysprof-category-icon.c b/src/sysprof/sysprof-category-icon.c index 8ee2e5b2..4748426e 100644 --- a/src/sysprof/sysprof-category-icon.c +++ b/src/sysprof/sysprof-category-icon.c @@ -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; +} diff --git a/src/sysprof/sysprof-category-icon.h b/src/sysprof/sysprof-category-icon.h index 35263483..583645ae 100644 --- a/src/sysprof/sysprof-category-icon.h +++ b/src/sysprof/sysprof-category-icon.h @@ -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