Commit ba113fd2 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Warn if color cannot be parsed

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent a6e419d7
......@@ -56,9 +56,9 @@ cb_color_change(girara_session_t* session, const char* name,
const char* string_value = (const char*) value;
if (g_strcmp0(name, "highlight-color") == 0) {
gdk_rgba_parse(&(zathura->ui.colors.highlight_color), string_value);
parse_color(&zathura->ui.colors.highlight_color, string_value);
} else if (g_strcmp0(name, "highlight-active-color") == 0) {
gdk_rgba_parse(&(zathura->ui.colors.highlight_color_active), string_value);
parse_color(&zathura->ui.colors.highlight_color_active, string_value);
} else if (g_strcmp0(name, "recolor-darkcolor") == 0) {
if (zathura->sync.render_thread != NULL) {
zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, NULL, string_value);
......@@ -68,9 +68,9 @@ cb_color_change(girara_session_t* session, const char* name,
zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, string_value, NULL);
}
} else if (g_strcmp0(name, "render-loading-bg") == 0) {
gdk_rgba_parse(&(zathura->ui.colors.render_loading_bg), string_value);
parse_color(&zathura->ui.colors.render_loading_bg, string_value);
} else if (g_strcmp0(name, "render-loading-fg") == 0) {
gdk_rgba_parse(&(zathura->ui.colors.render_loading_fg), string_value);
parse_color(&zathura->ui.colors.render_loading_fg, string_value);
}
render_all(zathura);
......
......@@ -375,13 +375,15 @@ zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
if (dark != NULL) {
GdkRGBA color;
gdk_rgba_parse(&color, dark);
zathura_renderer_set_recolor_colors(renderer, NULL, &color);
if (parse_color(&color, dark) == true) {
zathura_renderer_set_recolor_colors(renderer, NULL, &color);
}
}
if (light != NULL) {
GdkRGBA color;
gdk_rgba_parse(&color, light);
zathura_renderer_set_recolor_colors(renderer, &color, NULL);
if (parse_color(&color, light) == true) {
zathura_renderer_set_recolor_colors(renderer, &color, NULL);
}
}
}
......
......@@ -280,3 +280,13 @@ find_first_page_column(const char* first_page_column_list,
return first_page_column;
}
bool
parse_color(GdkRGBA* color, const char* str)
{
if (gdk_rgba_parse(color, str) == FALSE) {
girara_warning("Failed to parse color string '%s'.", str);
return false;
}
return true;
}
......@@ -120,4 +120,14 @@ double zathura_correct_scale_value(girara_session_t* session, const double
unsigned int find_first_page_column(const char* first_page_column_list,
const unsigned int pages_per_row);
/**
* Parse color string and print warning if color cannot be parsed.
*
* @param[out] color The color
* @param[in] str Color string
*
* @return True if color string can be parsed, false otherwise.
*/
bool parse_color(GdkRGBA* color, const char* str);
#endif // UTILS_H
......@@ -245,7 +245,7 @@ init_css(zathura_t* zathura)
GdkRGBA rgba = {0, 0, 0, 0};
girara_setting_get(zathura->ui.session, index_settings[s], &tmp_value);
if (tmp_value != NULL) {
gdk_rgba_parse(&rgba, tmp_value);
parse_color(&rgba, tmp_value);
g_free(tmp_value);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment