mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
color-cycle: add reset helper
This will reset the colors and move back to position 0.
This commit is contained in:
@ -120,3 +120,17 @@ sp_color_cycle_next (SpColorCycle *self,
|
||||
|
||||
self->position = (self->position + 1) % self->n_colors;
|
||||
}
|
||||
|
||||
void
|
||||
sp_color_cycle_reset (SpColorCycle *self)
|
||||
{
|
||||
g_return_if_fail (self != NULL);
|
||||
|
||||
for (guint i = 0; default_colors[i]; i++)
|
||||
{
|
||||
if G_UNLIKELY (!gdk_rgba_parse (&self->colors[i], default_colors[i]))
|
||||
g_warning ("Failed to parse color %s into an RGBA", default_colors[i]);
|
||||
}
|
||||
|
||||
self->position = 0;
|
||||
}
|
||||
|
||||
@ -31,6 +31,7 @@ GType sp_color_cycle_get_type (void);
|
||||
SpColorCycle *sp_color_cycle_ref (SpColorCycle *self);
|
||||
void sp_color_cycle_unref (SpColorCycle *self);
|
||||
SpColorCycle *sp_color_cycle_new (void);
|
||||
void sp_color_cycle_reset (SpColorCycle *self);
|
||||
void sp_color_cycle_next (SpColorCycle *self,
|
||||
GdkRGBA *rgba);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user