From 0e70d8a5c9c8419abe419fedfc8a3be6d20177e5 Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 21 Sep 2021 12:51:57 +0200 Subject: [PATCH] [Config] Add 'in your face' error message about deprecated theme setting. Issue: #1468 --- lexer/theme-parser.y | 4 ++++ source/xrmoptions.c | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lexer/theme-parser.y b/lexer/theme-parser.y index f2b981af..e9b19888 100644 --- a/lexer/theme-parser.y +++ b/lexer/theme-parser.y @@ -35,6 +35,7 @@ #include "theme.h" #include "xrmoptions.h" #include "css-colors.h" +#include "rofi.h" typedef struct YYLTYPE { int first_line; @@ -447,6 +448,9 @@ t_config_property yyerror ( &(@$), @$.filename, error ); #else g_warning("%s:%d:%d: %s\n", @$.filename, @$.first_line, @$.first_column, error); + GString *str = g_string_new(""); + g_string_append_printf(str,"%s:%d:%d: %s\n", @$.filename, @$.first_line, @$.first_column, error); + rofi_add_error_message(str); #endif g_free(error); } diff --git a/source/xrmoptions.c b/source/xrmoptions.c index f1e8cabc..8bdb8e12 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -644,6 +644,22 @@ static gboolean __config_parser_set_property(XrmOption *option, } gboolean config_parse_set_property(const Property *p, char **error) { + if (g_ascii_strcasecmp(p->name, "theme") == 0) { + if (p->type == P_STRING) { + *error = g_strdup_printf("The option:\n\nconfiguration\n{\n\ttheme: " + "\"%s\";\n}\nis deprecated. Please replace " + "with: @theme \"%s\" " + "after the configuration block.", + p->value.s, p->value.s); + } else { + *error = g_strdup_printf("The option:\n\nconfiguration\n{\n\ttheme: " + "\"%s\";\n}\nis deprecated. Please replace " + "with: @theme \"%s\" " + "after the configuration block.", + "myTheme", "myTheme"); + } + return TRUE; + } for (unsigned int i = 0; i < sizeof(xrmOptions) / sizeof(XrmOption); ++i) { XrmOption *op = &(xrmOptions[i]); if (g_strcmp0(op->name, p->name) == 0) {