mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-25 13:55:34 -05:00
[Theme] Print known colors as color name.
When printing look if the set color has a known color name, print this.
This commit is contained in:
parent
abe4d2d85e
commit
4face975a9
4 changed files with 42 additions and 13 deletions
|
@ -348,6 +348,7 @@ helper_pidfile_SOURCES=\
|
||||||
include/mode-private.h\
|
include/mode-private.h\
|
||||||
source/helper.c\
|
source/helper.c\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
source/rofi-types.c\
|
source/rofi-types.c\
|
||||||
include/rofi-types.h\
|
include/rofi-types.h\
|
||||||
include/helper.h\
|
include/helper.h\
|
||||||
|
@ -468,6 +469,7 @@ helper_test_SOURCES=\
|
||||||
include/xrmoptions.h\
|
include/xrmoptions.h\
|
||||||
source/xrmoptions.c\
|
source/xrmoptions.c\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
source/rofi-types.c\
|
source/rofi-types.c\
|
||||||
include/rofi-types.h\
|
include/rofi-types.h\
|
||||||
test/helper-test.c
|
test/helper-test.c
|
||||||
|
@ -505,6 +507,7 @@ helper_expand_SOURCES=\
|
||||||
include/mode-private.h\
|
include/mode-private.h\
|
||||||
source/helper.c\
|
source/helper.c\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
include/helper.h\
|
include/helper.h\
|
||||||
include/helper-theme.h\
|
include/helper-theme.h\
|
||||||
include/xrmoptions.h\
|
include/xrmoptions.h\
|
||||||
|
@ -527,6 +530,7 @@ helper_config_cmdline_parser_SOURCES=\
|
||||||
include/mode-private.h\
|
include/mode-private.h\
|
||||||
source/helper.c\
|
source/helper.c\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
source/rofi-types.c\
|
source/rofi-types.c\
|
||||||
include/rofi-types.h\
|
include/rofi-types.h\
|
||||||
include/helper.h\
|
include/helper.h\
|
||||||
|
@ -544,6 +548,7 @@ mode_test_SOURCES=\
|
||||||
source/dialogs/help-keys.c\
|
source/dialogs/help-keys.c\
|
||||||
source/helper.c\
|
source/helper.c\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
source/mode.c\
|
source/mode.c\
|
||||||
source/rofi-types.c\
|
source/rofi-types.c\
|
||||||
include/rofi-types.h\
|
include/rofi-types.h\
|
||||||
|
@ -560,6 +565,7 @@ helper_tokenize_SOURCES=\
|
||||||
include/mode-private.h\
|
include/mode-private.h\
|
||||||
source/helper.c\
|
source/helper.c\
|
||||||
source/theme.c\
|
source/theme.c\
|
||||||
|
source/css-colors.c\
|
||||||
source/rofi-types.c\
|
source/rofi-types.c\
|
||||||
include/rofi-types.h\
|
include/rofi-types.h\
|
||||||
include/helper.h\
|
include/helper.h\
|
||||||
|
|
|
@ -86,7 +86,6 @@ typedef struct _ParseObject {
|
||||||
} ParseObject;
|
} ParseObject;
|
||||||
|
|
||||||
|
|
||||||
GList *prev_imported_files = NULL;
|
|
||||||
GQueue *file_queue = NULL;
|
GQueue *file_queue = NULL;
|
||||||
GQueue *queue = NULL;
|
GQueue *queue = NULL;
|
||||||
|
|
||||||
|
|
11
meson.build
11
meson.build
|
@ -299,6 +299,7 @@ test('helper_pidfile test', executable('helper_pidfile.test', [
|
||||||
objects: rofi.extract_objects([
|
objects: rofi.extract_objects([
|
||||||
'config/config.c',
|
'config/config.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
'source/xrmoptions.c',
|
'source/xrmoptions.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
|
@ -317,6 +318,7 @@ test('widget test', executable('widget.test', [
|
||||||
'source/widgets/widget.c',
|
'source/widgets/widget.c',
|
||||||
'source/widgets/textbox.c',
|
'source/widgets/textbox.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
'source/css-colors.c',
|
'source/css-colors.c',
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
|
@ -335,6 +337,7 @@ test('box test', executable('box.test', [
|
||||||
'source/widgets/widget.c',
|
'source/widgets/widget.c',
|
||||||
'source/widgets/box.c',
|
'source/widgets/box.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
'source/css-colors.c',
|
'source/css-colors.c',
|
||||||
'config/config.c',
|
'config/config.c',
|
||||||
|
@ -352,6 +355,7 @@ test('scrollbar test', executable('scrollbar.test', [
|
||||||
'source/widgets/widget.c',
|
'source/widgets/widget.c',
|
||||||
'source/widgets/scrollbar.c',
|
'source/widgets/scrollbar.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
'source/css-colors.c',
|
'source/css-colors.c',
|
||||||
'config/config.c',
|
'config/config.c',
|
||||||
|
@ -369,6 +373,7 @@ test('textbox test', executable('textbox.test', [
|
||||||
'source/widgets/widget.c',
|
'source/widgets/widget.c',
|
||||||
'source/widgets/textbox.c',
|
'source/widgets/textbox.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
'source/css-colors.c',
|
'source/css-colors.c',
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
|
@ -383,6 +388,7 @@ test('helper test', executable('helper.test', [
|
||||||
objects: rofi.extract_objects([
|
objects: rofi.extract_objects([
|
||||||
'config/config.c',
|
'config/config.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
'source/xrmoptions.c',
|
'source/xrmoptions.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
|
@ -396,6 +402,7 @@ test('helper_expand test', executable('helper_expand.test', [
|
||||||
objects: rofi.extract_objects([
|
objects: rofi.extract_objects([
|
||||||
'config/config.c',
|
'config/config.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
'source/xrmoptions.c',
|
'source/xrmoptions.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
|
@ -409,6 +416,7 @@ test('helper_config_cmdline_parser test', executable('helper_config_cmdline_pars
|
||||||
objects: rofi.extract_objects([
|
objects: rofi.extract_objects([
|
||||||
'config/config.c',
|
'config/config.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
'source/xrmoptions.c',
|
'source/xrmoptions.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
|
@ -430,6 +438,7 @@ if check.found()
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
'source/xrmoptions.c',
|
'source/xrmoptions.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
'source/css-colors.c',
|
'source/css-colors.c',
|
||||||
]),
|
]),
|
||||||
|
@ -444,6 +453,7 @@ if check.found()
|
||||||
'source/dialogs/help-keys.c',
|
'source/dialogs/help-keys.c',
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/mode.c',
|
'source/mode.c',
|
||||||
'source/xrmoptions.c',
|
'source/xrmoptions.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
|
@ -459,6 +469,7 @@ if check.found()
|
||||||
'config/config.c',
|
'config/config.c',
|
||||||
'source/helper.c',
|
'source/helper.c',
|
||||||
'source/theme.c',
|
'source/theme.c',
|
||||||
|
'source/css-colors.c',
|
||||||
'source/xrmoptions.c',
|
'source/xrmoptions.c',
|
||||||
'source/rofi-types.c',
|
'source/rofi-types.c',
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -293,6 +293,27 @@ static void rofi_theme_print_distance_unit(RofiDistanceUnit *unit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void rofi_theme_print_color(ThemeColor color) {
|
||||||
|
uint8_t r, g, b;
|
||||||
|
g = 255 * color.green;
|
||||||
|
r = 255 * color.red;
|
||||||
|
b = 255 * color.blue;
|
||||||
|
if (color.alpha < 0.00001) {
|
||||||
|
printf("transparent");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (uint32_t x = 0; x < num_CSSColors; x++) {
|
||||||
|
if (CSSColors[x].r == r && CSSColors[x].g == g && CSSColors[x].b == b) {
|
||||||
|
printf("%s", CSSColors[x].name);
|
||||||
|
if (color.alpha < 1) {
|
||||||
|
printf("/%.0f%%", color.alpha * 100.0);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
printf("rgba ( %.0f, %.0f, %.0f, %.0f %% )", (color.red * 255.0),
|
||||||
|
(color.green * 255.0), (color.blue * 255.0), (color.alpha * 100.0));
|
||||||
|
}
|
||||||
static void rofi_theme_print_distance(RofiDistance d) {
|
static void rofi_theme_print_distance(RofiDistance d) {
|
||||||
if (d.base.modtype == ROFI_DISTANCE_MODIFIER_GROUP) {
|
if (d.base.modtype == ROFI_DISTANCE_MODIFIER_GROUP) {
|
||||||
fputs("calc( ", stdout);
|
fputs("calc( ", stdout);
|
||||||
|
@ -345,11 +366,7 @@ static void int_rofi_theme_print_property(Property *p) {
|
||||||
printf("italic ");
|
printf("italic ");
|
||||||
}
|
}
|
||||||
if (p->value.highlight.style & ROFI_HL_COLOR) {
|
if (p->value.highlight.style & ROFI_HL_COLOR) {
|
||||||
printf("rgba ( %.0f, %.0f, %.0f, %.0f %% )",
|
rofi_theme_print_color(p->value.highlight.color);
|
||||||
(p->value.highlight.color.red * 255.0),
|
|
||||||
(p->value.highlight.color.green * 255.0),
|
|
||||||
(p->value.highlight.color.blue * 255.0),
|
|
||||||
(p->value.highlight.color.alpha * 100.0));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case P_POSITION: {
|
case P_POSITION: {
|
||||||
|
@ -401,9 +418,7 @@ static void int_rofi_theme_print_property(Property *p) {
|
||||||
printf("%s", p->value.b ? "true" : "false");
|
printf("%s", p->value.b ? "true" : "false");
|
||||||
break;
|
break;
|
||||||
case P_COLOR:
|
case P_COLOR:
|
||||||
printf("rgba ( %.0f, %.0f, %.0f, %.0f %% )", (p->value.color.red * 255.0),
|
rofi_theme_print_color(p->value.color);
|
||||||
(p->value.color.green * 255.0), (p->value.color.blue * 255.0),
|
|
||||||
(p->value.color.alpha * 100.0));
|
|
||||||
break;
|
break;
|
||||||
case P_IMAGE: {
|
case P_IMAGE: {
|
||||||
if (p->value.image.type == ROFI_IMAGE_URL) {
|
if (p->value.image.type == ROFI_IMAGE_URL) {
|
||||||
|
@ -415,9 +430,7 @@ static void int_rofi_theme_print_property(Property *p) {
|
||||||
for (GList *l = g_list_first(p->value.image.colors); l != NULL;
|
for (GList *l = g_list_first(p->value.image.colors); l != NULL;
|
||||||
l = g_list_next(l)) {
|
l = g_list_next(l)) {
|
||||||
ThemeColor *color = (ThemeColor *)l->data;
|
ThemeColor *color = (ThemeColor *)l->data;
|
||||||
printf("rgba ( %.0f, %.0f, %.0f, %.0f %% )", (color->red * 255.0),
|
rofi_theme_print_color(*color);
|
||||||
(color->green * 255.0), (color->blue * 255.0),
|
|
||||||
(color->alpha * 100.0));
|
|
||||||
index++;
|
index++;
|
||||||
if (index < length) {
|
if (index < length) {
|
||||||
printf(", ");
|
printf(", ");
|
||||||
|
|
Loading…
Reference in a new issue