all repos — tint2 @ 207129447df447c00ad3c271fa0bfe8d3cd39dc7

fork of the tint2 desktop panel for my custom setup - only minimized windows across all desktops for the taskbar

Allow a single gradient per bg/state
o9000 mrovi9000@gmail.com
commit

207129447df447c00ad3c271fa0bfe8d3cd39dc7

parent

15150fb57797b00d5496a4cdf1a9ecccf052d62d

7 files changed, 18 insertions(+), 38 deletions(-)

jump to
M doc/manual.htmldoc/manual.html

@@ -288,14 +288,12 @@ task_active_background_id = 2

systray_background_id = 0 clock_background_id = 0 </code></pre> -<p>Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.</p><h3 id="gradients">Gradients<a name="gradients" href="#gradients" class="md2man-permalink" title="permalink"></a></h3><p>(Available since 0.13.0)</p><p>Backgrounds also allow specifying one or more gradient layers +<p>Identifier 0 refers to a special background which is fully transparent, identifier 1 applies the first background defined in the config file etc.</p><h3 id="gradients">Gradients<a name="gradients" href="#gradients" class="md2man-permalink" title="permalink"></a></h3><p>(Available since 0.13.0)</p><p>Backgrounds also allow specifying gradient layers that are drawn on top of the solid color background.</p><p>First the user must define one or more gradients in the config file, each starting with <code>gradient = TYPE</code>. These must be added before backgrounds.</p><p>Then gradients can be added by index to backgrounds, using the <code>gradient_id = INDEX</code>, <code>hover_gradient_id = INDEX</code> and <code>pressed_gradient_id = INDEX</code>, where <code>INDEX</code> is -the gradient index, starting from 1. The <code>*gradient_id</code> option can be repeated -for the same background, which results in multiple gradients -being drawn on top of each other in the given order.</p><h4 id="simple-gradients">Simple gradients<a name="simple-gradients" href="#simple-gradients" class="md2man-permalink" title="permalink"></a></h4><p>These are gradients that vary from fixed control points (top-to-bottom, left-to-right +the gradient index, starting from 1.</p><h4 id="simple-gradients">Simple gradients<a name="simple-gradients" href="#simple-gradients" class="md2man-permalink" title="permalink"></a></h4><p>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.</p><h5 id="vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors">Vertical gradient, with color varying from the top edge to the bottom edge, two colors<a name="vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors" href="#vertical-gradient-with-color-varying-from-the-top-edge-to-the-bottom-edge-two-colors" class="md2man-permalink" title="permalink"></a></h5><pre class="highlight plaintext"><code>gradient = vertical start_color = #rrggbb opacity
M doc/tint2.1doc/tint2.1

@@ -179,7 +179,7 @@ .SS Gradients

.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 @@ .PP

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
M doc/tint2.mddoc/tint2.md

@@ -142,7 +142,7 @@ ### Gradients

(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 @@

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
M src/config.csrc/config.c

@@ -318,19 +318,19 @@ 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_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 */
M src/panel.csrc/panel.c

@@ -156,10 +156,7 @@ panels = NULL;

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++)
M src/util/area.csrc/util/area.c

@@ -40,16 +40,6 @@ memset(bg, 0, sizeof(Background));

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 @@ if (debug_gradients)

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); } }
M src/util/area.hsrc/util/area.h

@@ -152,8 +152,8 @@ Color border_color_hover;

// 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 @@ } Area;

// Initializes the Background member to default values. void init_background(Background *bg); -void cleanup_background(Background *bg); // Layout