[sysprof/wip/visualizers] cpu-visualizer-row: choose color for row
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/visualizers] cpu-visualizer-row: choose color for row
- Date: Wed, 28 Sep 2016 02:20:09 +0000 (UTC)
commit 4953731dd7c8b5a19949783fdd38cc7de1ffd796
Author: Christian Hergert <chergert redhat com>
Date: Tue Sep 27 19:18:40 2016 -0700
cpu-visualizer-row: choose color for row
For each CPU counter we come across, choose a new color from
the cycle.
lib/sp-cpu-visualizer-row.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/lib/sp-cpu-visualizer-row.c b/lib/sp-cpu-visualizer-row.c
index 121ebf9..9722727 100644
--- a/lib/sp-cpu-visualizer-row.c
+++ b/lib/sp-cpu-visualizer-row.c
@@ -20,11 +20,13 @@
#include "sp-capture-condition.h"
#include "sp-capture-cursor.h"
+#include "sp-color-cycle.h"
#include "sp-cpu-visualizer-row.h"
struct _SpCpuVisualizerRow
{
SpLineVisualizerRow parent_instance;
+ SpColorCycle *colors;
};
G_DEFINE_TYPE (SpCpuVisualizerRow, sp_cpu_visualizer_row, SP_TYPE_LINE_VISUALIZER_ROW)
@@ -98,8 +100,10 @@ complete_counters (GObject *object,
for (guint i = 0; i < counters->len; i++)
{
guint counter_id = g_array_index (counters, guint, i);
+ GdkRGBA color;
- sp_line_visualizer_row_add_counter (SP_LINE_VISUALIZER_ROW (self), counter_id);
+ sp_color_cycle_next (self->colors, &color);
+ sp_line_visualizer_row_add_counter (SP_LINE_VISUALIZER_ROW (self), counter_id, &color);
}
}
@@ -131,16 +135,30 @@ sp_cpu_visualizer_row_set_reader (SpVisualizerRow *row,
}
static void
+sp_cpu_visualizer_row_finalize (GObject *object)
+{
+ SpCpuVisualizerRow *self = (SpCpuVisualizerRow *)object;
+
+ g_clear_pointer (&self->colors, sp_color_cycle_unref);
+
+ G_OBJECT_CLASS (sp_cpu_visualizer_row_parent_class)->finalize (object);
+}
+
+static void
sp_cpu_visualizer_row_class_init (SpCpuVisualizerRowClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
SpVisualizerRowClass *row_class = SP_VISUALIZER_ROW_CLASS (klass);
+ object_class->finalize = sp_cpu_visualizer_row_finalize;
+
row_class->set_reader = sp_cpu_visualizer_row_set_reader;
}
static void
sp_cpu_visualizer_row_init (SpCpuVisualizerRow *self)
{
+ self->colors = sp_color_cycle_new ();
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]