mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-11-14 07:53:45 +01:00
Warn if color cannot be parsed
Signed-off-by: Sebastian Ramacher <sebastian+dev@ramacher.at>
This commit is contained in:
parent
a6e419d724
commit
ba113fd21c
@ -56,9 +56,9 @@ cb_color_change(girara_session_t* session, const char* name,
|
|||||||
|
|
||||||
const char* string_value = (const char*) value;
|
const char* string_value = (const char*) value;
|
||||||
if (g_strcmp0(name, "highlight-color") == 0) {
|
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) {
|
} 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) {
|
} else if (g_strcmp0(name, "recolor-darkcolor") == 0) {
|
||||||
if (zathura->sync.render_thread != NULL) {
|
if (zathura->sync.render_thread != NULL) {
|
||||||
zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, NULL, string_value);
|
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);
|
zathura_renderer_set_recolor_colors_str(zathura->sync.render_thread, string_value, NULL);
|
||||||
}
|
}
|
||||||
} else if (g_strcmp0(name, "render-loading-bg") == 0) {
|
} 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) {
|
} 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);
|
render_all(zathura);
|
||||||
|
@ -375,15 +375,17 @@ zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
|
|||||||
|
|
||||||
if (dark != NULL) {
|
if (dark != NULL) {
|
||||||
GdkRGBA color;
|
GdkRGBA color;
|
||||||
gdk_rgba_parse(&color, dark);
|
if (parse_color(&color, dark) == true) {
|
||||||
zathura_renderer_set_recolor_colors(renderer, NULL, &color);
|
zathura_renderer_set_recolor_colors(renderer, NULL, &color);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (light != NULL) {
|
if (light != NULL) {
|
||||||
GdkRGBA color;
|
GdkRGBA color;
|
||||||
gdk_rgba_parse(&color, light);
|
if (parse_color(&color, light) == true) {
|
||||||
zathura_renderer_set_recolor_colors(renderer, &color, NULL);
|
zathura_renderer_set_recolor_colors(renderer, &color, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
|
zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
|
||||||
|
@ -280,3 +280,13 @@ find_first_page_column(const char* first_page_column_list,
|
|||||||
|
|
||||||
return first_page_column;
|
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,
|
unsigned int find_first_page_column(const char* first_page_column_list,
|
||||||
const unsigned int pages_per_row);
|
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
|
#endif // UTILS_H
|
||||||
|
@ -245,7 +245,7 @@ init_css(zathura_t* zathura)
|
|||||||
GdkRGBA rgba = {0, 0, 0, 0};
|
GdkRGBA rgba = {0, 0, 0, 0};
|
||||||
girara_setting_get(zathura->ui.session, index_settings[s], &tmp_value);
|
girara_setting_get(zathura->ui.session, index_settings[s], &tmp_value);
|
||||||
if (tmp_value != NULL) {
|
if (tmp_value != NULL) {
|
||||||
gdk_rgba_parse(&rgba, tmp_value);
|
parse_color(&rgba, tmp_value);
|
||||||
g_free(tmp_value);
|
g_free(tmp_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user