diff --git a/Makefile b/Makefile index 73af442..cb42d1f 100644 --- a/Makefile +++ b/Makefile @@ -77,7 +77,7 @@ dbus-interface-definitions.c: data/org.pwmt.zathura.xml css-definitions.c: data/zathura.css_t $(QUIET)echo '#include "css-definitions.h"' > $@.tmp - $(QUIET)echo 'const char* CSS_TEMPLATE =' >> $@.tmp + $(QUIET)echo 'const char* CSS_TEMPLATE_INDEX =' >> $@.tmp $(QUIET)sed 's/^\(.*\)$$/"\1\\n"/' $< >> $@.tmp $(QUIET)echo ';' >> $@.tmp $(QUIET)mv $@.tmp $@ diff --git a/config.c b/config.c index 728bf28..0d36f47 100644 --- a/config.c +++ b/config.c @@ -174,6 +174,11 @@ config_load_default(zathura_t* zathura) girara_setting_add(gsession, "render-loading-fg", NULL, STRING, false, _("'Loading ...' foreground color"), cb_color_change, NULL); girara_setting_set(gsession, "render-loading-fg", "#000000"); + girara_setting_add(gsession, "index-fg", "#DDDDDD", STRING, true, _("Index mode foreground color"), NULL, NULL); + girara_setting_add(gsession, "index-bg", "#232323", STRING, true, _("Index mode background color"), NULL, NULL); + girara_setting_add(gsession, "index-active-fg", "#232323", STRING, true, _("Index mode foreground color (active element)"), NULL, NULL); + girara_setting_add(gsession, "index-active-bg", "#9FBC00", STRING, true, _("Index mode background color (active element)"), NULL, NULL); + bool_value = false; girara_setting_add(gsession, "recolor", &bool_value, BOOLEAN, false, _("Recolor pages"), cb_setting_recolor_change, NULL); bool_value = false; diff --git a/css-definitions.h b/css-definitions.h index d487378..5e31db3 100644 --- a/css-definitions.h +++ b/css-definitions.h @@ -3,6 +3,6 @@ #ifndef GIRARA_CSS_DEFINITIONS_H #define GIRARA_CSS_DEFINITIONS_H -extern const char* CSS_TEMPLATE; +extern const char* CSS_TEMPLATE_INDEX; #endif diff --git a/data/zathura.css_t b/data/zathura.css_t index 788f5a8..05cbe3a 100644 --- a/data/zathura.css_t +++ b/data/zathura.css_t @@ -1,3 +1,5 @@ +/* Index mode colors */ + #@session@ .indexmode { color: @index-fg@; background-color: @index-bg@; diff --git a/shortcuts.c b/shortcuts.c index 0705afb..b8352d0 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -1128,6 +1128,9 @@ sc_toggle_index(girara_session_t* session, girara_argument_t* UNUSED(argument), goto error_free; } + gtk_style_context_add_class(gtk_widget_get_style_context(treeview), + "indexmode"); + g_object_unref(model); renderer = gtk_cell_renderer_text_new(); diff --git a/zathura.c b/zathura.c index fb4ce5b..d75a551 100644 --- a/zathura.c +++ b/zathura.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -39,6 +40,7 @@ #include "plugin.h" #include "adjustment.h" #include "dbus-interface.h" +#include "css-definitions.h" typedef struct zathura_document_info_s { zathura_t* zathura; @@ -245,6 +247,37 @@ zathura_init(zathura_t* zathura) zathura->jumplist.size = 0; zathura->jumplist.cur = NULL; + /* CSS for index mode */ + GiraraTemplate* csstemplate = girara_session_get_template(zathura->ui.session); + + static const char* index_settings[] = { + "index-fg", + "index-bg", + "index-active-fg", + "index-active-bg" + }; + + for (size_t s = 0; s < LENGTH(index_settings); ++s) { + girara_template_add_variable(csstemplate, index_settings[s]); + + char* tmp_value = NULL; + 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); + g_free(tmp_value); + } + + char* color = gdk_rgba_to_string(&rgba); + girara_template_set_variable_value(csstemplate, + index_settings[s], color); + g_free(color); + } + + char* css = g_strdup_printf("%s\n%s", girara_template_get_base(csstemplate), CSS_TEMPLATE_INDEX); + girara_template_set_base(csstemplate, css); + g_free(css); + /* Start D-Bus service */ bool dbus = true; girara_setting_get(zathura->ui.session, "dbus-service", &dbus);