summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Davenport <qball@blame.services>2022-12-30 11:54:15 +0100
committerDave Davenport <qball@blame.services>2022-12-30 11:54:15 +0100
commitd464822505f5b57e6f5984f5468c62af83d88b2f (patch)
tree8e91d7d29c4241013b8aa18ed04bb1c82c5b96f0
parentd47b1515b5d189f7e080ffe00a62651308b65741 (diff)
[Theme] support rasinc for theme include files.
-rw-r--r--Makefile.am2
-rw-r--r--doc/rofi-theme.51
-rw-r--r--doc/rofi-theme.5.markdown1
-rw-r--r--include/helper.h4
-rw-r--r--lexer/theme-lexer.l5
-rw-r--r--meson.build2
-rw-r--r--source/helper.c13
-rw-r--r--test/box-test.c2
-rw-r--r--test/scrollbar-test.c2
-rw-r--r--themes/gruvbox-common.rasinc (renamed from themes/gruvbox-common.rasi)0
-rw-r--r--themes/gruvbox-dark-hard.rasi2
-rw-r--r--themes/gruvbox-dark-soft.rasi2
-rw-r--r--themes/gruvbox-dark.rasi2
-rw-r--r--themes/gruvbox-light-hard.rasi2
-rw-r--r--themes/gruvbox-light-soft.rasi2
-rw-r--r--themes/gruvbox-light.rasi2
16 files changed, 28 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am
index 2a14c198..174ea9fe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -214,7 +214,7 @@ theme_DATA=\
themes/dmenu.rasi\
themes/docu.rasi\
themes/glue_pro_blue.rasi\
- themes/gruvbox-common.rasi\
+ themes/gruvbox-common.rasinc\
themes/gruvbox-dark-hard.rasi\
themes/gruvbox-dark-soft.rasi\
themes/gruvbox-dark.rasi\
diff --git a/doc/rofi-theme.5 b/doc/rofi-theme.5
index f70aa560..b7b64b25 100644
--- a/doc/rofi-theme.5
+++ b/doc/rofi-theme.5
@@ -353,6 +353,7 @@ name
.PP
The preferred file extension for the new theme format is \fBrasi\fP\&. This is an
abbreviation for \fBr\fPofi \fBa\fPdvanced \fBs\fPtyle \fBi\fPnformation.
+If a theme file is split over multiple files, include files can have the: \fBrasinc\fP extension.
.SH Basic Structure
.PP
diff --git a/doc/rofi-theme.5.markdown b/doc/rofi-theme.5.markdown
index 24388f58..bec95423 100644
--- a/doc/rofi-theme.5.markdown
+++ b/doc/rofi-theme.5.markdown
@@ -233,6 +233,7 @@ name
The preferred file extension for the new theme format is **rasi**. This is an
abbreviation for **r**ofi **a**dvanced **s**tyle **i**nformation.
+If a theme file is split over multiple files, include files can have the: **rasinc** extension.
## Basic Structure
diff --git a/include/helper.h b/include/helper.h
index bcae4810..efe6b07c 100644
--- a/include/helper.h
+++ b/include/helper.h
@@ -393,11 +393,11 @@ char *helper_string_replace_if_exists(char *string, ...);
/**
* @param file File name passed to option.
- * @param ext File extension passed to option.
+ * @param ext NULL terminated array of file extension passed to option.
*
* @returns path to theme or copy of filename if not found.
*/
-char *helper_get_theme_path(const char *file, const char *ext);
+char *helper_get_theme_path(const char *file, const char **ext);
/**
* @param name The name of the element to find.
diff --git a/lexer/theme-lexer.l b/lexer/theme-lexer.l
index 0763b22e..25e8bd71 100644
--- a/lexer/theme-lexer.l
+++ b/lexer/theme-lexer.l
@@ -50,6 +50,7 @@
#define LOG_DOMAIN "Parser"
int last_state = 0;
+const char *rasi_theme_file_extensions[] = {".rasi", ".rasinc", NULL};
/**
* Type of Object to parse.
*/
@@ -413,7 +414,7 @@ if ( queue == NULL ) {
yytext[yyleng-1] = '\0';
ParseObject *top = g_queue_peek_head ( file_queue );
g_assert ( top != NULL );
- char *file2 = helper_get_theme_path ( &yytext[1], ".rasi" );
+ char *file2 = helper_get_theme_path ( &yytext[1], rasi_theme_file_extensions );
char *filename = rofi_theme_parse_prepare_file ( file2, top->filename );
g_free ( file2 );
FILE *f = fopen ( filename, "rb" );
@@ -880,7 +881,7 @@ if ( queue == NULL ) {
gboolean rofi_theme_parse_file ( const char *file )
{
- char *file2 = helper_get_theme_path ( file, ".rasi" );
+ char *file2 = helper_get_theme_path ( file, rasi_theme_file_extensions );
char *filename = rofi_theme_parse_prepare_file ( file2, NULL );
g_free ( file2 );
diff --git a/meson.build b/meson.build
index 4cc7b7c8..6061a62d 100644
--- a/meson.build
+++ b/meson.build
@@ -293,7 +293,7 @@ install_data(
'themes/dmenu.rasi',
'themes/docu.rasi',
'themes/glue_pro_blue.rasi',
- 'themes/gruvbox-common.rasi',
+ 'themes/gruvbox-common.rasinc',
'themes/gruvbox-dark-hard.rasi',
'themes/gruvbox-dark-soft.rasi',
'themes/gruvbox-dark.rasi',
diff --git a/source/helper.c b/source/helper.c
index 583d128c..8f5f95ff 100644
--- a/source/helper.c
+++ b/source/helper.c
@@ -1067,7 +1067,7 @@ gboolean helper_execute_command(const char *wd, const char *cmd,
return helper_execute(wd, args, "", cmd, context);
}
-char *helper_get_theme_path(const char *file, const char *ext) {
+char *helper_get_theme_path(const char *file, const char **ext) {
char *filename = rofi_expand_path(file);
g_debug("Opening theme, testing: %s\n", filename);
if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
@@ -1075,7 +1075,16 @@ char *helper_get_theme_path(const char *file, const char *ext) {
}
g_free(filename);
- if (g_str_has_suffix(file, ext)) {
+ gboolean ext_found = FALSE;
+ if (ext) {
+ for (const char **i = ext; *i != NULL; i++) {
+ if (g_str_has_suffix(file, *i)) {
+ ext_found = TRUE;
+ break;
+ }
+ }
+ }
+ if (ext_found) {
filename = g_strdup(file);
} else {
filename = g_strconcat(file, ext, NULL);
diff --git a/test/box-test.c b/test/box-test.c
index 12b83200..36bbaaf1 100644
--- a/test/box-test.c
+++ b/test/box-test.c
@@ -92,7 +92,7 @@ gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
}
char *rofi_expand_path(G_GNUC_UNUSED const char *path) { return NULL; }
-char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char *ext) {
+char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char **ext) {
return g_strdup(file);
}
void rofi_add_error_message(G_GNUC_UNUSED GString *msg) {}
diff --git a/test/scrollbar-test.c b/test/scrollbar-test.c
index d79154a8..cb58bdcf 100644
--- a/test/scrollbar-test.c
+++ b/test/scrollbar-test.c
@@ -77,7 +77,7 @@ cairo_surface_t *rofi_icon_fetcher_get(G_GNUC_UNUSED const uint32_t uid) {
int monitor_active(G_GNUC_UNUSED workarea *mon) { return 0; }
-char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char *ext) {
+char *helper_get_theme_path(const char *file, G_GNUC_UNUSED const char **ext) {
return g_strdup(file);
}
gboolean config_parse_set_property(G_GNUC_UNUSED const Property *p,
diff --git a/themes/gruvbox-common.rasi b/themes/gruvbox-common.rasinc
index 69330e27..69330e27 100644
--- a/themes/gruvbox-common.rasi
+++ b/themes/gruvbox-common.rasinc
diff --git a/themes/gruvbox-dark-hard.rasi b/themes/gruvbox-dark-hard.rasi
index f09507e6..10be00f0 100644
--- a/themes/gruvbox-dark-hard.rasi
+++ b/themes/gruvbox-dark-hard.rasi
@@ -58,5 +58,5 @@
selected-urgent-foreground: @urgent-foreground;
}
-@import "gruvbox-common.rasi"
+@import "gruvbox-common.rasinc"
diff --git a/themes/gruvbox-dark-soft.rasi b/themes/gruvbox-dark-soft.rasi
index d080824a..03b120cc 100644
--- a/themes/gruvbox-dark-soft.rasi
+++ b/themes/gruvbox-dark-soft.rasi
@@ -58,5 +58,5 @@
selected-urgent-foreground: @urgent-foreground;
}
-@import "gruvbox-common.rasi"
+@import "gruvbox-common.rasinc"
diff --git a/themes/gruvbox-dark.rasi b/themes/gruvbox-dark.rasi
index 6bec1275..bc59022f 100644
--- a/themes/gruvbox-dark.rasi
+++ b/themes/gruvbox-dark.rasi
@@ -58,5 +58,5 @@
selected-urgent-foreground: @urgent-foreground;
}
-@import "gruvbox-common.rasi"
+@import "gruvbox-common.rasinc"
diff --git a/themes/gruvbox-light-hard.rasi b/themes/gruvbox-light-hard.rasi
index e0efe33f..18e51f47 100644
--- a/themes/gruvbox-light-hard.rasi
+++ b/themes/gruvbox-light-hard.rasi
@@ -58,5 +58,5 @@
selected-urgent-foreground: @urgent-foreground;
}
-@import "gruvbox-common.rasi"
+@import "gruvbox-common.rasinc"
diff --git a/themes/gruvbox-light-soft.rasi b/themes/gruvbox-light-soft.rasi
index 43ddb6b4..f386da75 100644
--- a/themes/gruvbox-light-soft.rasi
+++ b/themes/gruvbox-light-soft.rasi
@@ -58,5 +58,5 @@
selected-urgent-foreground: @urgent-foreground;
}
-@import "gruvbox-common.rasi"
+@import "gruvbox-common.rasinc"
diff --git a/themes/gruvbox-light.rasi b/themes/gruvbox-light.rasi
index f8041564..29190683 100644
--- a/themes/gruvbox-light.rasi
+++ b/themes/gruvbox-light.rasi
@@ -58,5 +58,5 @@
selected-urgent-foreground: @urgent-foreground;
}
-@import "gruvbox-common.rasi"
+@import "gruvbox-common.rasinc"