[main] Try to fix default theme loading.

* Add more debug output on failing to load theme.
 * Don't load default theme, if empty theme is explicitly loaded.
This commit is contained in:
Dave Davenport 2021-08-23 22:57:39 +02:00
parent 45561359de
commit 3c8ca2390d
2 changed files with 6 additions and 11 deletions

View File

@ -946,6 +946,7 @@ int main(int argc, char *argv[]) {
TICK_N("Parse theme");
rofi_theme_reset();
if (rofi_theme_parse_file(config.theme)) {
g_warning("Failed to parse theme: \"%s\"", config.theme);
// TODO: instantiate fallback theme.?
rofi_theme_free(rofi_theme);
rofi_theme = NULL;
@ -986,7 +987,9 @@ int main(int argc, char *argv[]) {
windowid = config.monitor;
}
}
if (rofi_theme_is_empty()) {
// Load default theme, if no theme was set and we don't have a current theme
// loaded.
if (config.theme == NULL && rofi_theme_is_empty()) {
GBytes *theme_data = g_resource_lookup_data(
resources_get_resource(), "/org/qtools/rofi/default_theme.rasi",
G_RESOURCE_LOOKUP_FLAGS_NONE, NULL);
@ -1016,6 +1019,8 @@ int main(int argc, char *argv[]) {
if (theme_str) {
for (int index = 0; theme_str && theme_str[index]; index++) {
if (rofi_theme_parse_string(theme_str[index])) {
g_warning("Failed to parse -theme-str option: \"%s\"",
theme_str[index]);
rofi_theme_free(rofi_theme);
rofi_theme = NULL;
}

View File

@ -1313,16 +1313,6 @@ gboolean rofi_theme_is_empty(void) {
if (rofi_theme->properties == NULL && rofi_theme->num_widgets == 0) {
return TRUE;
}
if (rofi_theme->num_widgets == 3) {
// HACK: check for default added elements.
for (unsigned int i = 0; i < rofi_theme->num_widgets; i++) {
if (strncmp(rofi_theme->widgets[i]->name, "element", 7) != 0) {
return FALSE;
}
}
return TRUE;
}
return FALSE;
}