summaryrefslogtreecommitdiff
path: root/eel/eel-gdk-extensions.c
blob: fc7e36729e5124063e3a14abda2f5654773bb648 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */

/* eel-gdk-extensions.c: Graphics routines to augment what's in gdk.

   Copyright (C) 1999, 2000 Eazel, Inc.

   The Mate Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public License as
   published by the Free Software Foundation; either version 2 of the
   License, or (at your option) any later version.

   The Mate Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public
   License along with the Mate Library; see the file COPYING.LIB.  If not,
   write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
   Boston, MA 02110-1301, USA.

   Authors: Darin Adler <darin@eazel.com>,
            Pavel Cisler <pavel@eazel.com>,
            Ramiro Estrugo <ramiro@eazel.com>
*/

#include <config.h>
#include "eel-gdk-extensions.h"

#include "eel-glib-extensions.h"
#include "eel-lib-self-check-functions.h"
#include "eel-string.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdkprivate.h>
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <stdlib.h>
#include <pango/pango.h>

/**
 * eel_gradient_new
 * @start_color: Color for the top or left.
 * @end_color: Color for the bottom or right.
 * @is_horizontal: Direction of the gradient.
 *
 * Create a string that combines the start and end colors along
 * with the direction of the gradient in a standard format.
 */
char *
eel_gradient_new (const char *start_color,
                  const char *end_color,
                  gboolean is_horizontal)
{
    /* Handle the special case where the start and end colors are identical.
       Handle the special case where the end color is an empty string.
    */
    if (eel_strcmp(start_color, end_color) == 0 || end_color == NULL || end_color[0] == '\0')
    {
        return g_strdup (start_color);
    }

    /* Handle the special case where the start color is an empty string. */
    if (start_color == NULL || start_color[0] == '\0')
    {
        return g_strdup (end_color);
    }

    /* Handle the general case. */
    return g_strconcat (start_color, "-", end_color, is_horizontal ? ":h" : NULL, NULL);
}

/**
 * eel_gradient_is_gradient
 * @gradient_spec: A gradient spec. string.
 *
 * Return true if the spec. specifies a gradient instead of a solid color.
 */
gboolean
eel_gradient_is_gradient (const char *gradient_spec)
{
    return eel_strchr (gradient_spec, '-') != NULL;
}

/**
 * eel_gradient_is_horizontal
 * @gradient_spec: A gradient spec. string.
 *
 * Return true if the spec. specifies a horizontal gradient.
 */
gboolean
eel_gradient_is_horizontal (const char *gradient_spec)
{
    size_t length;

    length = eel_strlen (gradient_spec);
    return length >= 2 && gradient_spec[length - 2] == ':' && gradient_spec[length - 1] == 'h';
}

static char *
eel_gradient_strip_trailing_direction_if_any (const char *gradient_spec)
{
    size_t length;

    length = eel_strlen (gradient_spec);
    if (length >= 2 && gradient_spec[length - 2] == ':'
            && (gradient_spec[length - 1] == 'v' || gradient_spec[length - 1] == 'h'))
    {
        length -= 2;
    }

    return g_strndup (gradient_spec, length);
}

/* For parsing n-point gradients. Successive calls should pass the next_spec value
 * set by the previous call as their first argument - to continue parsing where the
 * previous call left off.
 */
char *
eel_gradient_parse_one_color_spec (const char *spec, int *percent, const char **next_spec)
{
    char *result;
    const char *rgb_end_ptr;
    const char *percent_ptr;
    const char *separator_ptr;

    percent_ptr   = eel_strchr (spec, '%');
    separator_ptr = eel_strchr (spec, '-');

    if (percent_ptr != NULL && (separator_ptr == NULL || percent_ptr < separator_ptr))
    {
        if (percent != NULL)
        {
            *percent = (int) strtol (percent_ptr + 1, NULL, 10);
        }
        rgb_end_ptr = percent_ptr;
    }
    else
    {
        if (percent != NULL)
        {
            *percent = 100;
        }
        rgb_end_ptr = separator_ptr;
    }

    if (rgb_end_ptr != NULL)
    {
        result = g_strndup (spec, rgb_end_ptr - spec);
    }
    else
    {
        result = eel_gradient_strip_trailing_direction_if_any (spec);
    }

    /* It's important not to use spec after setting *next_spec because it's
     * likely that *next_spec == spec.
     */
    if (next_spec != NULL)
    {
        *next_spec = (separator_ptr != NULL) ? separator_ptr + 1 : NULL;
    }

    return result;
}

/* FIXME bugzilla.eazel.com 5076:
 * anyone using eel_gradient_get_start_color_spec or
 * eel_gradient_get_end_color_spec is assuming the gradient
 * is 2 colors which is questionable.
 *
 * Callers should be rewritten and these fns eliminated.
 */

/**
 * eel_gradient_get_start_color_spec
 * @gradient_spec: A gradient spec. string.
 *
 * Return the start color.
 * This may be the entire gradient_spec if it's a solid color.
 */
char *
eel_gradient_get_start_color_spec (const char *gradient_spec)
{
    return eel_gradient_parse_one_color_spec (gradient_spec, NULL, NULL);
}

/**
 * eel_gradient_get_end_color_spec
 * @gradient_spec: A gradient spec. string.
 *
 * Return the end color.
 * This may be the entire gradient_spec if it's a solid color.
 */
char *
eel_gradient_get_end_color_spec (const char *gradient_spec)
{
    char* color = NULL;

    do
    {
        g_free (color);
        color = eel_gradient_parse_one_color_spec (gradient_spec, NULL, &gradient_spec);
    }
    while (gradient_spec != NULL);

    return color;
}

/* Do the work shared by all the set_color_spec functions below. */
static char *
eel_gradient_set_edge_color (const char *gradient_spec,
                             const char *edge_color,
                             gboolean is_horizontal,
                             gboolean change_end)
{
    char *opposite_color;
    char *result;

    g_assert (edge_color != NULL);

    /* Get the color from the existing gradient spec. for the opposite
       edge. This will parse away all the stuff we don't want from the
       old gradient spec.
    */
    opposite_color = change_end
                     ? eel_gradient_get_start_color_spec (gradient_spec)
                     : eel_gradient_get_end_color_spec (gradient_spec);

    /* Create a new gradient spec. The eel_gradient_new function handles
       some special cases, so we don't have to bother with them here.
    */
    result = eel_gradient_new (change_end ? opposite_color : edge_color,
                               change_end ? edge_color : opposite_color,
                               is_horizontal);

    g_free (opposite_color);

    return result;
}

/**
 * eel_gradient_set_left_color_spec
 * @gradient_spec: A gradient spec. string.
 * @left_color: Color spec. to replace left color with.
 *
 * Changes the left color to what's passed in.
 * This creates a horizontal gradient.
 */
char *
eel_gradient_set_left_color_spec (const char *gradient_spec,
                                  const char *left_color)
{
    g_return_val_if_fail (gradient_spec != NULL, NULL);
    g_return_val_if_fail (left_color != NULL, NULL);

    return eel_gradient_set_edge_color (gradient_spec, left_color, TRUE, FALSE);
}

/**
 * eel_gradient_set_top_color_spec
 * @gradient_spec: A gradient spec. string.
 * @top_color: Color spec. to replace top color with.
 *
 * Changes the top color to what's passed in.
 * This creates a vertical gradient.
 */
char *
eel_gradient_set_top_color_spec (const char *gradient_spec,
                                 const char *top_color)
{
    g_return_val_if_fail (gradient_spec != NULL, NULL);
    g_return_val_if_fail (top_color != NULL, NULL);

    return eel_gradient_set_edge_color (gradient_spec, top_color, FALSE, FALSE);
}

/**
 * eel_gradient_set_right_color_spec
 * @gradient_spec: A gradient spec. string.
 * @right_color: Color spec. to replace right color with.
 *
 * Changes the right color to what's passed in.
 * This creates a horizontal gradient.
 */
char *
eel_gradient_set_right_color_spec (const char *gradient_spec,
                                   const char *right_color)
{
    g_return_val_if_fail (gradient_spec != NULL, NULL);
    g_return_val_if_fail (right_color != NULL, NULL);

    return eel_gradient_set_edge_color (gradient_spec, right_color, TRUE, TRUE);
}

/**
 * eel_gradient_set_bottom_color_spec
 * @gradient_spec: A gradient spec. string.
 * @bottom_color: Color spec. to replace bottom color with.
 *
 * Changes the bottom color to what's passed in.
 * This creates a vertical gradient.
 */
char *
eel_gradient_set_bottom_color_spec (const char *gradient_spec,
                                    const char *bottom_color)
{
    g_return_val_if_fail (gradient_spec != NULL, NULL);
    g_return_val_if_fail (bottom_color != NULL, NULL);

    return eel_gradient_set_edge_color (gradient_spec, bottom_color, FALSE, TRUE);
}

/**
 * eel_gdk_rgba_parse_with_white_default
 * @color: Pointer to place to put resulting color.
 * @color_spec: A color spec, or NULL.
 *
 * The same as gdk_rgba_parse, except sets the color to white if
 * the spec. can't be parsed, instead of returning a boolean flag.
 */
void
eel_gdk_rgba_parse_with_white_default (GdkRGBA *color,
                                       const char *color_spec)
{
    gboolean got_color;

    g_return_if_fail (color != NULL);

    got_color = FALSE;
    if (color_spec != NULL)
    {
        if (gdk_rgba_parse (color, color_spec))
        {
            got_color = TRUE;
        }
    }

    if (!got_color)
    {
        color->red = 1.0;
        color->green = 1.0;
        color->blue = 1.0;
        color->alpha = 1.0;
    }
}

guint32
eel_rgb16_to_rgb (gushort r, gushort g, gushort b)
{
    guint32 result;

    result = (0xff0000 | (r & 0xff00));
    result <<= 8;
    result |= ((g & 0xff00) | (b >> 8));

    return result;
}

/**
 * eel_gdk_rgba_to_rgb
 * @color: A GdkRGBA style color.
 * Returns: An rgb value.
 *
 * Converts from a GdkRGBA style color to a gdk_rgb one.
 * Alpha gets set to fully opaque
 */
guint32
eel_gdk_rgba_to_rgb (const GdkRGBA *color)
{
    return eel_rgb16_to_rgb ((guint) (color->red * 65535),
                             (guint) (color->green * 65535),
                             (guint) (color->blue * 65535));
}

/**
 * eel_gdk_rgb_to_rgba
 * @color: a gdk_rgb style value.
 *
 * Converts from a gdk_rgb value style to a GdkRGBA one.
 * The gdk_rgb color alpha channel is ignored.
 *
 * Return value: A GdkRGBA structure version of the given RGB color.
 */
GdkRGBA
eel_gdk_rgb_to_rgba (guint32 color)
{
    GdkRGBA result;

    result.red = ((gdouble) ((color >> 16) & 0xFF)) / 0xFF;
    result.green = ((gdouble) ((color >> 8) & 0xFF)) / 0xFF;
    result.blue = ((gdouble) (color & 0xFF)) / 0xFF;
    result.alpha = 1.0;

    return result;
}

/**
 * eel_gdk_rgb_to_color_spec
 * @color: a gdk_rgb style value.
 *
 * Converts from a gdk_rgb value style to a string color spec.
 * The gdk_rgb color alpha channel is ignored.
 *
 * Return value: a newly allocated color spec.
 */
char *
eel_gdk_rgb_to_color_spec (const guint32 color)
{
    return g_strdup_printf ("#%06X", (guint) (color & 0xFFFFFF));
}

/**
 * eel_gdk_rgba_is_dark:
 *
 * Return true if the given color is `dark'
 */
gboolean
eel_gdk_rgba_is_dark (const GdkRGBA *color)
{
    int intensity;

    intensity = (((guint) (color->red * 0xff) * 77)
                 + ((guint) (color->green * 0xff) * 150)
                 + ((guint) (color->blue * 0xff) * 28)) >> 8;

    return intensity < 128;
}

EelGdkGeometryFlags
eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
                        guint *width_return, guint *height_return)
{
    int x11_flags;
    EelGdkGeometryFlags gdk_flags;

    g_return_val_if_fail (string != NULL, EEL_GDK_NO_VALUE);
    g_return_val_if_fail (x_return != NULL, EEL_GDK_NO_VALUE);
    g_return_val_if_fail (y_return != NULL, EEL_GDK_NO_VALUE);
    g_return_val_if_fail (width_return != NULL, EEL_GDK_NO_VALUE);
    g_return_val_if_fail (height_return != NULL, EEL_GDK_NO_VALUE);

    x11_flags = XParseGeometry (string, x_return, y_return,
                                width_return, height_return);

    gdk_flags = EEL_GDK_NO_VALUE;
    if (x11_flags & XValue)
    {
        gdk_flags |= EEL_GDK_X_VALUE;
    }
    if (x11_flags & YValue)
    {
        gdk_flags |= EEL_GDK_Y_VALUE;
    }
    if (x11_flags & WidthValue)
    {
        gdk_flags |= EEL_GDK_WIDTH_VALUE;
    }
    if (x11_flags & HeightValue)
    {
        gdk_flags |= EEL_GDK_HEIGHT_VALUE;
    }
    if (x11_flags & XNegative)
    {
        gdk_flags |= EEL_GDK_X_NEGATIVE;
    }
    if (x11_flags & YNegative)
    {
        gdk_flags |= EEL_GDK_Y_NEGATIVE;
    }

    return gdk_flags;
}

#if ! defined (EEL_OMIT_SELF_CHECK)

static char *
eel_gdk_rgba_as_hex_string (GdkRGBA color)
{
    return g_strdup_printf ("%04X%04X%04X",
                            (guint) (color.red * 65535),
                            (guint) (color.green * 65535),
                            (guint) (color.blue * 65535));
}

static char *
eel_self_check_parse (const char *color_spec)
{
    GdkRGBA color;

    eel_gdk_rgba_parse_with_white_default (&color, color_spec);
    return eel_gdk_rgba_as_hex_string (color);
}

static char *
eel_self_check_gdk_rgb_to_color (guint32 color)
{
    GdkRGBA result;

    result = eel_gdk_rgb_to_rgba (color);

    return eel_gdk_rgba_as_hex_string (result);
}

void
eel_self_check_gdk_extensions (void)
{
    /* eel_gradient_new */
    EEL_CHECK_STRING_RESULT (eel_gradient_new ("", "", FALSE), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "b", FALSE), "a-b");
    EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "b", TRUE), "a-b:h");
    EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "a", FALSE), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "a", TRUE), "a");

    /* eel_gradient_is_gradient */
    EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient (""), FALSE);
    EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient ("-"), TRUE);
    EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient ("a"), FALSE);
    EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient ("a-b"), TRUE);
    EEL_CHECK_BOOLEAN_RESULT (eel_gradient_is_gradient ("a-b:h"), TRUE);

    /* eel_gradient_get_start_color_spec */
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec (""), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("-"), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a-b"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a-"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("-b"), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:h"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:v"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:c"), "a:c");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:-b"), "a:");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_start_color_spec ("a:-b:v"), "a:");

    /* eel_gradient_get_end_color_spec */
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec (""), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("-"), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a-b"), "b");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a-"), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("-b"), "b");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:h"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:v"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:c"), "a:c");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:-b"), "b");
    EEL_CHECK_STRING_RESULT (eel_gradient_get_end_color_spec ("a:-b:v"), "b");

    /* eel_gradient_set_left_color_spec */
    EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("", ""), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("", "a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a", ""), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a", "a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a", "b"), "b-a:h");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a-c:v", "b"), "b-c:h");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a-c:v", "c"), "c");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_left_color_spec ("a:-b:v", "d"), "d-b:h");

    /* eel_gradient_set_top_color_spec */
    EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("", ""), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("", "a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a", ""), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a", "a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a", "b"), "b-a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a-c:v", "b"), "b-c");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a-c:v", "c"), "c");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_top_color_spec ("a:-b:h", "d"), "d-b");

    /* eel_gradient_set_right_color_spec */
    EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("", ""), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("", "a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a", ""), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a", "a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a", "b"), "a-b:h");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a-c:v", "b"), "a-b:h");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a-c:v", "c"), "a-c:h");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_right_color_spec ("a:-b:v", "d"), "a:-d:h");

    /* eel_gradient_set_bottom_color_spec */
    EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("", ""), "");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("", "a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a", ""), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a", "a"), "a");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a", "b"), "a-b");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a-c:v", "b"), "a-b");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a-c:v", "c"), "a-c");
    EEL_CHECK_STRING_RESULT (eel_gradient_set_bottom_color_spec ("a:-b:h", "d"), "a:-d");

    /* eel_gdk_rgba_parse_with_white_default */
    EEL_CHECK_STRING_RESULT (eel_self_check_parse (""), "FFFFFFFFFFFF");
    EEL_CHECK_STRING_RESULT (eel_self_check_parse ("a"), "FFFFFFFFFFFF");
    EEL_CHECK_STRING_RESULT (eel_self_check_parse ("white"), "FFFFFFFFFFFF");
    EEL_CHECK_STRING_RESULT (eel_self_check_parse ("black"), "000000000000");
    EEL_CHECK_STRING_RESULT (eel_self_check_parse ("red"), "FFFF00000000");
    EEL_CHECK_STRING_RESULT (eel_self_check_parse ("#012345"), "010123234545");
    /* EEL_CHECK_STRING_RESULT (eel_self_check_parse ("rgb:0123/4567/89AB"), "#014589"); */

    /* eel_gdk_rgb_to_color */
    EEL_CHECK_STRING_RESULT (eel_self_check_gdk_rgb_to_color (EEL_RGB_COLOR_RED), "FFFF00000000");
    EEL_CHECK_STRING_RESULT (eel_self_check_gdk_rgb_to_color (EEL_RGB_COLOR_BLACK), "000000000000");
    EEL_CHECK_STRING_RESULT (eel_self_check_gdk_rgb_to_color (EEL_RGB_COLOR_WHITE), "FFFFFFFFFFFF");
    EEL_CHECK_STRING_RESULT (eel_self_check_gdk_rgb_to_color (EEL_RGB_COLOR_PACK (0x01, 0x23, 0x45)), "010123234545");

    /* EEL_RGBA_COLOR_PACK */
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0xFF, 0x00, 0x00, 00), EEL_RGB_COLOR_RED);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0x00, 0xFF, 0x00, 00), EEL_RGB_COLOR_GREEN);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0x00, 0x00, 0xFF, 00), EEL_RGB_COLOR_BLUE);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0xFF, 0xFF, 0xFF, 00), EEL_RGB_COLOR_WHITE);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0x00, 0x00, 0x00, 00), EEL_RGB_COLOR_BLACK);

    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0xFF, 0x00, 0x00, 0xFF), EEL_RGBA_COLOR_OPAQUE_RED);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0x00, 0xFF, 0x00, 0xFF), EEL_RGBA_COLOR_OPAQUE_GREEN);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0x00, 0x00, 0xFF, 0xFF), EEL_RGBA_COLOR_OPAQUE_BLUE);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0xFF, 0xFF, 0xFF, 0xFF), EEL_RGBA_COLOR_OPAQUE_WHITE);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_PACK (0x00, 0x00, 0x00, 0xFF), EEL_RGBA_COLOR_OPAQUE_BLACK);

    /* EEL_RGB_COLOR_PACK */
    EEL_CHECK_INTEGER_RESULT (EEL_RGB_COLOR_PACK (0xFF, 0x00, 0x00), EEL_RGBA_COLOR_OPAQUE_RED);
    EEL_CHECK_INTEGER_RESULT (EEL_RGB_COLOR_PACK (0x00, 0xFF, 0x00), EEL_RGBA_COLOR_OPAQUE_GREEN);
    EEL_CHECK_INTEGER_RESULT (EEL_RGB_COLOR_PACK (0x00, 0x00, 0xFF), EEL_RGBA_COLOR_OPAQUE_BLUE);
    EEL_CHECK_INTEGER_RESULT (EEL_RGB_COLOR_PACK (0xFF, 0xFF, 0xFF), EEL_RGBA_COLOR_OPAQUE_WHITE);
    EEL_CHECK_INTEGER_RESULT (EEL_RGB_COLOR_PACK (0x00, 0x00, 0x00), EEL_RGBA_COLOR_OPAQUE_BLACK);

    /* EEL_RGBA_COLOR_GET_R */
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGBA_COLOR_OPAQUE_RED), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGBA_COLOR_OPAQUE_GREEN), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGBA_COLOR_OPAQUE_BLUE), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGBA_COLOR_OPAQUE_WHITE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGBA_COLOR_OPAQUE_BLACK), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGB_COLOR_RED), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGB_COLOR_GREEN), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGB_COLOR_BLUE), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGB_COLOR_WHITE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_R (EEL_RGB_COLOR_BLACK), 0x00);

    /* EEL_RGBA_COLOR_GET_G */
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGBA_COLOR_OPAQUE_RED), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGBA_COLOR_OPAQUE_GREEN), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGBA_COLOR_OPAQUE_BLUE), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGBA_COLOR_OPAQUE_WHITE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGBA_COLOR_OPAQUE_BLACK), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGB_COLOR_RED), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGB_COLOR_GREEN), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGB_COLOR_BLUE), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGB_COLOR_WHITE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_G (EEL_RGB_COLOR_BLACK), 0x00);

    /* EEL_RGBA_COLOR_GET_B */
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGBA_COLOR_OPAQUE_RED), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGBA_COLOR_OPAQUE_GREEN), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGBA_COLOR_OPAQUE_BLUE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGBA_COLOR_OPAQUE_WHITE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGBA_COLOR_OPAQUE_BLACK), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGB_COLOR_RED), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGB_COLOR_GREEN), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGB_COLOR_BLUE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGB_COLOR_WHITE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_B (EEL_RGB_COLOR_BLACK), 0x00);

    /* EEL_RGBA_COLOR_GET_A */
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGBA_COLOR_OPAQUE_RED), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGBA_COLOR_OPAQUE_GREEN), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGBA_COLOR_OPAQUE_BLUE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGBA_COLOR_OPAQUE_WHITE), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGBA_COLOR_OPAQUE_BLACK), 0xFF);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGB_COLOR_RED), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGB_COLOR_GREEN), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGB_COLOR_BLUE), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGB_COLOR_WHITE), 0x00);
    EEL_CHECK_INTEGER_RESULT (EEL_RGBA_COLOR_GET_A (EEL_RGB_COLOR_BLACK), 0x00);

}

#endif /* ! EEL_OMIT_SELF_CHECK */