mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-29 12:05:59 +01:00
make highlight colors configurable during runtime
This commit is contained in:
parent
fd4429716f
commit
9d04a7bfcf
4 changed files with 29 additions and 11 deletions
27
config.c
27
config.c
|
@ -14,6 +14,26 @@
|
||||||
#include <girara/commands.h>
|
#include <girara/commands.h>
|
||||||
#include <girara/gtk2-compat.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
|
void
|
||||||
config_load_default(zathura_t* zathura)
|
config_load_default(zathura_t* zathura)
|
||||||
{
|
{
|
||||||
|
@ -59,8 +79,11 @@ config_load_default(zathura_t* zathura)
|
||||||
string_value = "#000000";
|
string_value = "#000000";
|
||||||
girara_setting_add(gsession, "recolor-lightcolor", string_value, STRING, false, "Recoloring (light color)", NULL, NULL);
|
girara_setting_add(gsession, "recolor-lightcolor", string_value, STRING, false, "Recoloring (light color)", NULL, NULL);
|
||||||
|
|
||||||
string_value = "#9FBC00";
|
girara_setting_add(gsession, "highlight-color", NULL, STRING, false, "Color for highlighting", cb_color_change, NULL);
|
||||||
girara_setting_add(gsession, "highlight-color", string_value, STRING, false, "Color for highlighting", NULL, 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;
|
float_value = 0.5;
|
||||||
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL);
|
girara_setting_add(gsession, "highlight-transparency", &float_value, FLOAT, false, "Transparency for highlighting", NULL, NULL);
|
||||||
bool_value = true;
|
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);
|
zathura_rectangle_t rectangle = recalc_rectangle(priv->page, *rect);
|
||||||
|
|
||||||
/* draw position */
|
/* draw position */
|
||||||
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
|
||||||
if (idx == priv->search_current) {
|
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 {
|
} else {
|
||||||
|
GdkColor color = priv->zathura->ui.colors.highlight_color;
|
||||||
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
cairo_set_source_rgba(cairo, color.red, color.green, color.blue, transparency);
|
||||||
}
|
}
|
||||||
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
cairo_rectangle(cairo, rectangle.x1, rectangle.y1,
|
||||||
|
|
|
@ -244,13 +244,6 @@ zathura_init(int argc, char* argv[])
|
||||||
g_free(string_value);
|
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 */
|
/* database */
|
||||||
zathura->database = zathura_db_init(zathura->config.data_dir);
|
zathura->database = zathura_db_init(zathura->config.data_dir);
|
||||||
if (zathura->database == NULL) {
|
if (zathura->database == NULL) {
|
||||||
|
|
|
@ -50,6 +50,7 @@ typedef struct zathura_s
|
||||||
GdkColor recolor_dark_color; /**< Dark color for recoloring */
|
GdkColor recolor_dark_color; /**< Dark color for recoloring */
|
||||||
GdkColor recolor_light_color; /**< Light color for recoloring */
|
GdkColor recolor_light_color; /**< Light color for recoloring */
|
||||||
GdkColor highlight_color; /**< Color for highlighting */
|
GdkColor highlight_color; /**< Color for highlighting */
|
||||||
|
GdkColor highlight_color_active; /** Color for highlighting */
|
||||||
} colors;
|
} colors;
|
||||||
|
|
||||||
GtkWidget *page_widget_alignment;
|
GtkWidget *page_widget_alignment;
|
||||||
|
|
Loading…
Reference in a new issue