1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-25 13:55:34 -05:00

[Theme] Fix opening abs path if no/wrong extension (backward comp.)

This commit is contained in:
Dave Davenport 2023-08-15 19:28:33 +02:00
parent a7aa8224cb
commit 6caaf36df6
2 changed files with 14 additions and 16 deletions

View file

@ -1067,6 +1067,14 @@ gboolean helper_execute_command(const char *wd, const char *cmd,
char *helper_get_theme_path(const char *file, const char **ext,
const char *parent_file) {
char *filename = rofi_expand_path(file);
g_debug("Opening theme, testing: %s\n", filename);
if (g_path_is_absolute(filename)) {
g_debug("Opening theme, path is absolute: %s", filename);
if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
return filename;
}
}
gboolean ext_found = FALSE;
for (const char **i = ext; *i != NULL; i++) {
if (g_str_has_suffix(file, *i)) {
@ -1074,17 +1082,15 @@ char *helper_get_theme_path(const char *file, const char **ext,
break;
}
}
char *filename = NULL;
if (ext_found) {
filename = rofi_expand_path(file);
} else {
g_assert_nonnull(ext[0]);
char *temp = rofi_expand_path(file);
char *temp = filename;
// TODO: Pick the first extension. needs fixing.
filename = g_strconcat(temp, ext[0], NULL);
g_free(temp);
}
g_debug("Opening theme, testing: %s\n", filename);
if (g_path_is_absolute(filename)) {
g_debug("Opening theme, path is absolute: %s", filename);
if (g_file_test(filename, G_FILE_TEST_EXISTS)) {

View file

@ -1698,7 +1698,8 @@ START_TEST(test_prepare_environment_media_f) {
wid.name = "window";
wid.state = "";
setenv("QER_TEST", "true", 1);
rofi_theme_parse_string("window { width: 32; } @media( enabled: env(QER_TEST,false)){ window {width:64; }}");
rofi_theme_parse_string("window { width: 32; } @media( enabled: "
"env(QER_TEST,false)){ window {width:64; }}");
rofi_theme_parse_process_conditionals();
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
@ -1716,7 +1717,8 @@ START_TEST(test_prepare_environment_media_nf) {
widget wid;
wid.name = "window";
wid.state = "";
rofi_theme_parse_string("window { width: 32; } @media( enabled: env(QER_TEST,false)){ window {width:64; }}");
rofi_theme_parse_string("window { width: 32; } @media( enabled: "
"env(QER_TEST,false)){ window {width:64; }}");
ck_assert_ptr_nonnull(rofi_theme);
// ck_assert_ptr_null ( rofi_theme->widgets );
ck_assert_ptr_null(rofi_theme->properties);
@ -1731,23 +1733,13 @@ END_TEST
START_TEST(test_prepare_path) {
char *current_dir = g_get_current_dir();
ck_assert_ptr_nonnull(current_dir);
char *f = rofi_theme_parse_prepare_file("../", NULL);
char *f = rofi_theme_parse_prepare_file("../");
ck_assert_ptr_nonnull(f);
ck_assert_int_eq(*f, '/');
ck_assert_str_ne(f, current_dir);
ck_assert(g_str_has_prefix(current_dir, f) == TRUE);
g_free(f);
f = rofi_theme_parse_prepare_file("../", "/tmp/");
ck_assert_ptr_nonnull(f);
ck_assert_str_eq(f, "/");
g_free(f);
f = rofi_theme_parse_prepare_file("/tmp/test.rasi", "/random/");
ck_assert_ptr_nonnull(f);
ck_assert_str_eq(f, "/tmp/test.rasi");
g_free(f);
g_free(current_dir);
}
END_TEST