Commit 8f61583a authored by Sebastian Ramacher's avatar Sebastian Ramacher

Style index mode with CSS

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 9a0ff4b7
......@@ -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 $@
......
......@@ -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;
......
......@@ -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
/* Index mode colors */
#@session@ .indexmode {
color: @index-fg@;
background-color: @index-bg@;
......
......@@ -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();
......
......@@ -14,6 +14,7 @@
#include <girara/statusbar.h>
#include <girara/settings.h>
#include <girara/shortcuts.h>
#include <girara/template.h>
#include <glib/gstdio.h>
#include <glib/gi18n.h>
......@@ -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);
......
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