diff --git a/doc/manual.html b/doc/manual.html index 1973ba3..bf7a97f 100644 --- a/doc/manual.html +++ b/doc/manual.html @@ -288,14 +288,12 @@ task_active_background_id = 2 systray_background_id = 0 clock_background_id = 0 -
Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.
(Available since 0.13.0)
Backgrounds also allow specifying one or more gradient layers +
Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.
(Available since 0.13.0)
Backgrounds also allow specifying gradient layers that are drawn on top of the solid color background.
First the user must define one or more gradients in the config file,
each starting with gradient = TYPE
. These must be added before backgrounds.
Then gradients can be added by index to backgrounds,
using the gradient_id = INDEX
, hover_gradient_id = INDEX
and
pressed_gradient_id = INDEX
, where INDEX
is
-the gradient index, starting from 1. The *gradient_id
option can be repeated
-for the same background, which results in multiple gradients
-being drawn on top of each other in the given order.
These are gradients that vary from fixed control points (top-to-bottom, left-to-right +the gradient index, starting from 1.
These are gradients that vary from fixed control points (top-to-bottom, left-to-right or center-to-corners). The user must specify the start and end colors, and can optionally add extra color stops in between.
gradient = vertical
start_color = #rrggbb opacity
diff --git a/doc/tint2.1 b/doc/tint2.1
index 0acdaea..8a5cbd9 100644
--- a/doc/tint2.1
+++ b/doc/tint2.1
@@ -179,7 +179,7 @@ Identifier 0 refers to a special background which is fully transparent, identifi
.PP
(Available since 0.13.0)
.PP
-Backgrounds also allow specifying one or more gradient layers
+Backgrounds also allow specifying gradient layers
that are drawn on top of the solid color background.
.PP
First the user must define one or more gradients in the config file,
@@ -188,9 +188,7 @@ each starting with \fB\fCgradient = TYPE\fR\&. These must be added before backgr
Then gradients can be added by index to backgrounds,
using the \fB\fCgradient_id = INDEX\fR, \fB\fChover_gradient_id = INDEX\fR and
\fB\fCpressed_gradient_id = INDEX\fR, where \fB\fCINDEX\fR is
-the gradient index, starting from 1. The \fB\fC*gradient_id\fR option can be repeated
-for the same background, which results in multiple gradients
-being drawn on top of each other in the given order.
+the gradient index, starting from 1.
.SS Simple gradients
.PP
These are gradients that vary from fixed control points (top\-to\-bottom, left\-to\-right
diff --git a/doc/tint2.md b/doc/tint2.md
index 65ed198..e0cf372 100644
--- a/doc/tint2.md
+++ b/doc/tint2.md
@@ -142,7 +142,7 @@ Identifier 0 refers to a special background which is fully transparent, identifi
(Available since 0.13.0)
-Backgrounds also allow specifying one or more gradient layers
+Backgrounds also allow specifying gradient layers
that are drawn on top of the solid color background.
First the user must define one or more gradients in the config file,
@@ -151,9 +151,7 @@ each starting with `gradient = TYPE`. These must be added before backgrounds.
Then gradients can be added by index to backgrounds,
using the `gradient_id = INDEX`, `hover_gradient_id = INDEX` and
`pressed_gradient_id = INDEX`, where `INDEX` is
-the gradient index, starting from 1. The `*gradient_id` option can be repeated
-for the same background, which results in multiple gradients
-being drawn on top of each other in the given order.
+the gradient index, starting from 1.
#### Simple gradients
diff --git a/src/config.c b/src/config.c
index 5fe8d30..cba0cb0 100644
--- a/src/config.c
+++ b/src/config.c
@@ -318,19 +318,19 @@ void add_entry(char *key, char *value)
int id = atoi(value);
id = (id < gradients->len && id >= 0) ? id : -1;
if (id >= 0)
- bg->gradients[MOUSE_NORMAL] = g_list_append(bg->gradients[MOUSE_NORMAL], &g_array_index(gradients, GradientClass, id));
+ bg->gradients[MOUSE_NORMAL] = &g_array_index(gradients, GradientClass, id);
} else if (strcmp(key, "hover_gradient_id") == 0) {
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
int id = atoi(value);
id = (id < gradients->len && id >= 0) ? id : -1;
if (id >= 0)
- bg->gradients[MOUSE_OVER] = g_list_append(bg->gradients[MOUSE_OVER], &g_array_index(gradients, GradientClass, id));
+ bg->gradients[MOUSE_OVER] = &g_array_index(gradients, GradientClass, id);
} else if (strcmp(key, "pressed_gradient_id") == 0) {
Background *bg = &g_array_index(backgrounds, Background, backgrounds->len - 1);
int id = atoi(value);
id = (id < gradients->len && id >= 0) ? id : -1;
if (id >= 0)
- bg->gradients[MOUSE_DOWN] = g_list_append(bg->gradients[MOUSE_DOWN], &g_array_index(gradients, GradientClass, id));
+ bg->gradients[MOUSE_DOWN] = &g_array_index(gradients, GradientClass, id);
}
/* Gradients */
diff --git a/src/panel.c b/src/panel.c
index f079eac..96d5964 100644
--- a/src/panel.c
+++ b/src/panel.c
@@ -156,10 +156,7 @@ void cleanup_panel()
free_area(&panel_config.area);
- if (backgrounds) {
- for (guint i = 0; i < backgrounds->len; i++)
- cleanup_background(&g_array_index(backgrounds, Background, i));
- }
+ g_array_free(backgrounds, TRUE);
backgrounds = NULL;
if (gradients) {
for (guint i = 0; i < gradients->len; i++)
diff --git a/src/util/area.c b/src/util/area.c
index 11da1a7..9991152 100644
--- a/src/util/area.c
+++ b/src/util/area.c
@@ -40,16 +40,6 @@ void init_background(Background *bg)
bg->border.mask = BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT;
}
-void cleanup_background(Background *bg)
-{
- if (debug_gradients)
- fprintf(stderr, YELLOW "freeing gradient list %p" RESET "\n", (void*)bg->gradients);
- for (int i = 0; i < MOUSE_STATE_COUNT; i++) {
- g_list_free(bg->gradients[i]);
- bg->gradients[i] = NULL;
- }
-}
-
void initialize_positions(void *obj, int offset)
{
Area *a = (Area *)obj;
@@ -964,12 +954,12 @@ void instantiate_area_gradients(Area *area)
fprintf(stderr, "Initializing gradients for area %s\n", area->name);
for (int i = 0; i < MOUSE_STATE_COUNT; i++) {
g_assert_null(area->gradient_instances_by_state[i]);
- for (GList *l = area->bg->gradients[i]; l; l = l->next) {
- GradientClass *g = (GradientClass *)l->data;
- GradientInstance *gi = (GradientInstance *)calloc(1, sizeof(GradientInstance));
- instantiate_gradient(area, g, gi);
- area->gradient_instances_by_state[i] = g_list_append(area->gradient_instances_by_state[i], gi);
- }
+ GradientClass *g = area->bg->gradients[i];
+ if (!g)
+ continue;
+ GradientInstance *gi = (GradientInstance *)calloc(1, sizeof(GradientInstance));
+ instantiate_gradient(area, g, gi);
+ area->gradient_instances_by_state[i] = g_list_append(area->gradient_instances_by_state[i], gi);
}
}
diff --git a/src/util/area.h b/src/util/area.h
index cc1fb75..be8d2d8 100644
--- a/src/util/area.h
+++ b/src/util/area.h
@@ -152,8 +152,8 @@ typedef struct Background {
// On mouse press
Color fill_color_pressed;
Color border_color_pressed;
- // Each list element is a pointer to a GradientClass (list can be empty), no ownership
- GList *gradients[MOUSE_STATE_COUNT];
+ // Pointer to a GradientClass or NULL, no ownership
+ GradientClass *gradients[MOUSE_STATE_COUNT];
} Background;
typedef enum Layout {
@@ -244,7 +244,6 @@ typedef struct Area {
// Initializes the Background member to default values.
void init_background(Background *bg);
-void cleanup_background(Background *bg);
// Layout