mirror of
https://github.com/lbonn/rofi
synced 2024-11-10 06:14:14 +00:00
[Theme] support rasinc for theme include files.
This commit is contained in:
parent
d47b1515b5
commit
d464822505
16 changed files with 28 additions and 16 deletions
|
@ -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\
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -58,5 +58,5 @@
|
|||
selected-urgent-foreground: @urgent-foreground;
|
||||
}
|
||||
|
||||
@import "gruvbox-common.rasi"
|
||||
@import "gruvbox-common.rasinc"
|
||||
|
||||
|
|
|
@ -58,5 +58,5 @@
|
|||
selected-urgent-foreground: @urgent-foreground;
|
||||
}
|
||||
|
||||
@import "gruvbox-common.rasi"
|
||||
@import "gruvbox-common.rasinc"
|
||||
|
||||
|
|
|
@ -58,5 +58,5 @@
|
|||
selected-urgent-foreground: @urgent-foreground;
|
||||
}
|
||||
|
||||
@import "gruvbox-common.rasi"
|
||||
@import "gruvbox-common.rasinc"
|
||||
|
||||
|
|
|
@ -58,5 +58,5 @@
|
|||
selected-urgent-foreground: @urgent-foreground;
|
||||
}
|
||||
|
||||
@import "gruvbox-common.rasi"
|
||||
@import "gruvbox-common.rasinc"
|
||||
|
||||
|
|
|
@ -58,5 +58,5 @@
|
|||
selected-urgent-foreground: @urgent-foreground;
|
||||
}
|
||||
|
||||
@import "gruvbox-common.rasi"
|
||||
@import "gruvbox-common.rasinc"
|
||||
|
||||
|
|
|
@ -58,5 +58,5 @@
|
|||
selected-urgent-foreground: @urgent-foreground;
|
||||
}
|
||||
|
||||
@import "gruvbox-common.rasi"
|
||||
@import "gruvbox-common.rasinc"
|
||||
|
||||
|
|
Loading…
Reference in a new issue