Commit 9d04a7bf authored by Sebastian Ramacher's avatar Sebastian Ramacher

make highlight colors configurable during runtime

parent fd442971
......@@ -14,6 +14,26 @@
#include <girara/commands.h>
#include <girara/gtk2-compat.h>
static void
cb_color_change(girara_session_t* session, const char* name, girara_setting_type_t UNUSED(type), void* value, void* UNUSED(data))
{
g_return_if_fail(value != NULL);
g_return_if_fail(session != NULL);
g_return_if_fail(session->global.data != NULL);
g_return_if_fail(name != NULL);
zathura_t* zathura = session->global.data;
char* string_value = (char*) value;
if (g_strcmp0(name, "highlight-color") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color));
} else if (g_strcmp0(name, "highlight-active-active") == 0) {
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color_active));
}
/* TODO: cause a redraw here? */
}
void
config_load_default(zathura_t* zathura)
{
......@@ -59,8 +79,11 @@ config_load_default(zathura_t* zathura)
string_value = "#000000";
girara_setting_add(gsession, "recolor-lightcolor", string_value, STRING, false, "Recoloring (light color)", NULL, NULL);
string_value = "#9FBC00";
girara_setting_add(gsession, "highlight-color", string_value, STRING, false, "Color for highlighting", NULL, NULL);
girara_setting_add(gsession, "highlight-color", NULL, STRING, false, "Color for highlighting", cb_color_change, NULL);
girara_setting_set(gsession, "highlight-color", "#9FBC00");
girara_setting_add(gsession, "highlight-active-color", NULL, STRING, false, "Color for highlighting (active)", cb_color_change, NULL);
girara_setting_set(gsession, "highlight-active-color", "#00BC00");
float_value = 0.5;
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL);
bool_value = true;
......
......@@ -325,10 +325,11 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
/* draw position */
GdkColor color = priv->zathura->ui.colors.highlight_color;
if (idx == priv->search_current) {
cairo_set_source_rgba(cairo, 0, color.green, color.blue, transparency);
GdkColor color = priv->zathura->ui.colors.highlight_color_active;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
} else {
GdkColor color = priv->zathura->ui.colors.highlight_color;
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
}
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
......
......@@ -244,13 +244,6 @@ zathura_init(int argc, char* argv[])
g_free(string_value);
}
string_value = NULL;
girara_setting_get(zathura->ui.session, "highlight-color", &string_value);
if (string_value != NULL) {
gdk_color_parse(string_value, &(zathura->ui.colors.highlight_color));
g_free(string_value);
}
/* database */
zathura->database = zathura_db_init(zathura->config.data_dir);
if (zathura->database == NULL) {
......
......@@ -50,6 +50,7 @@ typedef struct zathura_s
GdkColor recolor_dark_color; /**< Dark color for recoloring */
GdkColor recolor_light_color; /**< Light color for recoloring */
GdkColor highlight_color; /**< Color for highlighting */
GdkColor highlight_color_active; /** Color for highlighting */
} colors;
GtkWidget *page_widget_alignment;
......
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