mirror of
https://git.pwmt.org/pwmt/zathura.git
synced 2024-12-26 22:36:02 +01:00
Define colors and fonts with the set function
With this changes it is possible to set the colors with the :set function.
This commit is contained in:
parent
f9f5e1b667
commit
0a20bb6218
2 changed files with 114 additions and 66 deletions
69
config.def.h
69
config.def.h
|
@ -20,28 +20,28 @@ static const char BM_PAGE_ENTRY[] = "page";
|
|||
static const char BM_PAGE_OFFSET[] = "offset";
|
||||
|
||||
/* look */
|
||||
static const char font[] = "monospace normal 9";
|
||||
static const char default_bgcolor[] = "#000000";
|
||||
static const char default_fgcolor[] = "#DDDDDD";
|
||||
static const char inputbar_bgcolor[] = "#141414";
|
||||
static const char inputbar_fgcolor[] = "#9FBC00";
|
||||
static const char statusbar_bgcolor[] = "#000000";
|
||||
static const char statusbar_fgcolor[] = "#FFFFFF";
|
||||
static const char completion_fgcolor[] = "#DDDDDD";
|
||||
static const char completion_bgcolor[] = "#232323";
|
||||
static const char completion_g_fgcolor[] = "#DEDEDE";
|
||||
static const char completion_g_bgcolor[] = "#FF00FF";
|
||||
static const char completion_hl_fgcolor[] = "#232323";
|
||||
static const char completion_hl_bgcolor[] = "#9FBC00";
|
||||
static const char notification_e_bgcolor[] = "#FF1212";
|
||||
static const char notification_e_fgcolor[] = "#FFFFFF";
|
||||
static const char notification_w_bgcolor[] = "#FFF712";
|
||||
static const char notification_w_fgcolor[] = "#000000";
|
||||
static const char recolor_darkcolor[] = "#353535";
|
||||
static const char recolor_lightcolor[] = "#DBDBDB";
|
||||
char* font = "monospace normal 9";
|
||||
char* default_bgcolor = "#000000";
|
||||
char* default_fgcolor = "#DDDDDD";
|
||||
char* inputbar_bgcolor = "#141414";
|
||||
char* inputbar_fgcolor = "#9FBC00";
|
||||
char* statusbar_bgcolor = "#000000";
|
||||
char* statusbar_fgcolor = "#FFFFFF";
|
||||
char* completion_fgcolor = "#DDDDDD";
|
||||
char* completion_bgcolor = "#232323";
|
||||
char* completion_g_fgcolor = "#DEDEDE";
|
||||
char* completion_g_bgcolor = "#FF00FF";
|
||||
char* completion_hl_fgcolor = "#232323";
|
||||
char* completion_hl_bgcolor = "#9FBC00";
|
||||
char* notification_e_bgcolor = "#FF1212";
|
||||
char* notification_e_fgcolor = "#FFFFFF";
|
||||
char* notification_w_bgcolor = "#FFF712";
|
||||
char* notification_w_fgcolor = "#000000";
|
||||
char* recolor_darkcolor = "#353535";
|
||||
char* recolor_lightcolor = "#DBDBDB";
|
||||
|
||||
static const char search_highlight[] = "#9FBC00";
|
||||
static const char select_text[] = "#000000";
|
||||
char* search_highlight = "#9FBC00";
|
||||
char* select_text = "#000000";
|
||||
|
||||
/* statusbar */
|
||||
static const char DEFAULT_TEXT[] = "[No Name]";
|
||||
|
@ -183,7 +183,28 @@ SpecialCommand special_commands[] = {
|
|||
|
||||
/* settings */
|
||||
Setting settings[] = {
|
||||
/* name, variable, type, render, description */
|
||||
{"recolor", &(Zathura.Global.recolor), 'b', TRUE, "Invert the image"},
|
||||
{"offset", &(Zathura.PDF.page_offset), 'i', FALSE, "Optional page offset"},
|
||||
/* name, variable, type, render, re-init, description */
|
||||
{"recolor", &(Zathura.Global.recolor), 'b', TRUE, FALSE, "Invert the image" },
|
||||
{"offset", &(Zathura.PDF.page_offset), 'i', FALSE, FALSE, "Optional page offset" },
|
||||
{"font", &(font), 's', FALSE, TRUE, "The used font" },
|
||||
{"default_bgcolor", &(default_bgcolor), 's', FALSE, TRUE, "Default background color"},
|
||||
{"default_fgcolor", &(default_fgcolor), 's', FALSE, TRUE, "Default foreground color"},
|
||||
{"inputbar_bgcolor", &(inputbar_bgcolor), 's', FALSE, TRUE, "Inputbar background color"},
|
||||
{"inputbar_fgcolor", &(inputbar_fgcolor), 's', FALSE, TRUE, "Inputbar foreground color"},
|
||||
{"statusbar_bgcolor", &(statusbar_bgcolor), 's', FALSE, TRUE, "Statusbar background color"},
|
||||
{"statusbar_fgcolor", &(statusbar_fgcolor), 's', FALSE, TRUE, "Statusbar foreground color"},
|
||||
{"completion_bgcolor", &(completion_bgcolor), 's', FALSE, TRUE, "Completion background color"},
|
||||
{"completion_fgcolor", &(completion_fgcolor), 's', FALSE, TRUE, "Completion foreground color"},
|
||||
{"completion_g_bgcolor", &(completion_g_bgcolor), 's', FALSE, TRUE, "Completion (group) background color"},
|
||||
{"completion_g_fgcolor", &(completion_g_fgcolor), 's', FALSE, TRUE, "Completion (group) foreground color"},
|
||||
{"completion_hl_bgcolor", &(completion_hl_bgcolor), 's', FALSE, TRUE, "Completion (highlight) background color"},
|
||||
{"completion_hl_fgcolor", &(completion_hl_fgcolor), 's', FALSE, TRUE, "Completion (highlight) foreground color"},
|
||||
{"notification_e_bgcolor", &(notification_e_bgcolor), 's', FALSE, TRUE, "Notification (error) background color"},
|
||||
{"notification_e_fgcolor", &(notification_e_fgcolor), 's', FALSE, TRUE, "Notification (error) foreground color"},
|
||||
{"notification_w_bgcolor", &(notification_w_bgcolor), 's', FALSE, TRUE, "Notification (warning) background color"},
|
||||
{"notification_w_fgcolor", &(notification_w_fgcolor), 's', FALSE, TRUE, "Notification (warning) foreground color"},
|
||||
{"recolor_darkcolor", &(recolor_darkcolor), 's', FALSE, TRUE, "Recoloring (dark color)"},
|
||||
{"recolor_lightcolor", &(recolor_lightcolor), 's', FALSE, TRUE, "Recoloring (light color)"},
|
||||
{"search_highlight", &(search_highlight), 's', FALSE, TRUE, "Highlighted results"},
|
||||
{"select_text", &(select_text), 's', FALSE, TRUE, "Rectangle of the selected text"},
|
||||
};
|
||||
|
|
111
zathura.c
111
zathura.c
|
@ -130,6 +130,7 @@ typedef struct
|
|||
void* variable;
|
||||
char type;
|
||||
gboolean render;
|
||||
gboolean reinit;
|
||||
char* description;
|
||||
} Setting;
|
||||
|
||||
|
@ -284,6 +285,7 @@ struct
|
|||
} Zathura;
|
||||
|
||||
/* function declarations */
|
||||
void init_colors();
|
||||
void init_directories();
|
||||
void init_zathura();
|
||||
void add_marker(int);
|
||||
|
@ -386,6 +388,54 @@ gboolean cb_watch_file(GFileMonitor*, GFile*, GFile*, GFileMonitorEvent, gpointe
|
|||
#include "config.h"
|
||||
|
||||
/* function implementation */
|
||||
void
|
||||
init_colors()
|
||||
{
|
||||
/* parse */
|
||||
gdk_color_parse(default_fgcolor, &(Zathura.Style.default_fg));
|
||||
gdk_color_parse(default_bgcolor, &(Zathura.Style.default_bg));
|
||||
gdk_color_parse(inputbar_fgcolor, &(Zathura.Style.inputbar_fg));
|
||||
gdk_color_parse(inputbar_bgcolor, &(Zathura.Style.inputbar_bg));
|
||||
gdk_color_parse(statusbar_fgcolor, &(Zathura.Style.statusbar_fg));
|
||||
gdk_color_parse(statusbar_bgcolor, &(Zathura.Style.statusbar_bg));
|
||||
gdk_color_parse(completion_fgcolor, &(Zathura.Style.completion_fg));
|
||||
gdk_color_parse(completion_bgcolor, &(Zathura.Style.completion_bg));
|
||||
gdk_color_parse(completion_g_fgcolor, &(Zathura.Style.completion_g_fg));
|
||||
gdk_color_parse(completion_g_fgcolor, &(Zathura.Style.completion_g_fg));
|
||||
gdk_color_parse(completion_hl_fgcolor, &(Zathura.Style.completion_hl_fg));
|
||||
gdk_color_parse(completion_hl_bgcolor, &(Zathura.Style.completion_hl_bg));
|
||||
gdk_color_parse(notification_e_fgcolor, &(Zathura.Style.notification_e_fg));
|
||||
gdk_color_parse(notification_e_bgcolor, &(Zathura.Style.notification_e_bg));
|
||||
gdk_color_parse(notification_w_fgcolor, &(Zathura.Style.notification_w_fg));
|
||||
gdk_color_parse(notification_w_bgcolor, &(Zathura.Style.notification_w_bg));
|
||||
gdk_color_parse(recolor_darkcolor, &(Zathura.Style.recolor_darkcolor));
|
||||
gdk_color_parse(recolor_lightcolor, &(Zathura.Style.recolor_lightcolor));
|
||||
gdk_color_parse(search_highlight, &(Zathura.Style.search_highlight));
|
||||
gdk_color_parse(select_text, &(Zathura.Style.select_text));
|
||||
Zathura.Style.font = pango_font_description_from_string(font);
|
||||
|
||||
/* drawing area */
|
||||
gtk_widget_modify_bg(GTK_WIDGET(Zathura.UI.drawing_area), GTK_STATE_NORMAL, &(Zathura.Style.default_bg));
|
||||
|
||||
/* statusbar */
|
||||
gtk_widget_modify_bg(GTK_WIDGET(Zathura.UI.statusbar), GTK_STATE_NORMAL, &(Zathura.Style.statusbar_bg));
|
||||
|
||||
gtk_widget_modify_fg(GTK_WIDGET(Zathura.Global.status_text), GTK_STATE_NORMAL, &(Zathura.Style.statusbar_fg));
|
||||
gtk_widget_modify_fg(GTK_WIDGET(Zathura.Global.status_state), GTK_STATE_NORMAL, &(Zathura.Style.statusbar_fg));
|
||||
gtk_widget_modify_fg(GTK_WIDGET(Zathura.Global.status_buffer), GTK_STATE_NORMAL, &(Zathura.Style.statusbar_fg));
|
||||
|
||||
gtk_widget_modify_font(GTK_WIDGET(Zathura.Global.status_text), Zathura.Style.font);
|
||||
gtk_widget_modify_font(GTK_WIDGET(Zathura.Global.status_state), Zathura.Style.font);
|
||||
gtk_widget_modify_font(GTK_WIDGET(Zathura.Global.status_buffer), Zathura.Style.font);
|
||||
|
||||
/* inputbar */
|
||||
gtk_widget_modify_base(GTK_WIDGET(Zathura.UI.inputbar), GTK_STATE_NORMAL, &(Zathura.Style.inputbar_bg));
|
||||
gtk_widget_modify_text(GTK_WIDGET(Zathura.UI.inputbar), GTK_STATE_NORMAL, &(Zathura.Style.inputbar_fg));
|
||||
gtk_widget_modify_font(GTK_WIDGET(Zathura.UI.inputbar), Zathura.Style.font);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
init_directories()
|
||||
{
|
||||
|
@ -427,29 +477,6 @@ init_zathura()
|
|||
g_static_mutex_init(&(Zathura.Lock.select_lock));
|
||||
g_static_mutex_init(&(Zathura.Lock.select_lock));
|
||||
|
||||
/* look */
|
||||
gdk_color_parse(default_fgcolor, &(Zathura.Style.default_fg));
|
||||
gdk_color_parse(default_bgcolor, &(Zathura.Style.default_bg));
|
||||
gdk_color_parse(inputbar_fgcolor, &(Zathura.Style.inputbar_fg));
|
||||
gdk_color_parse(inputbar_bgcolor, &(Zathura.Style.inputbar_bg));
|
||||
gdk_color_parse(statusbar_fgcolor, &(Zathura.Style.statusbar_fg));
|
||||
gdk_color_parse(statusbar_bgcolor, &(Zathura.Style.statusbar_bg));
|
||||
gdk_color_parse(completion_fgcolor, &(Zathura.Style.completion_fg));
|
||||
gdk_color_parse(completion_bgcolor, &(Zathura.Style.completion_bg));
|
||||
gdk_color_parse(completion_g_fgcolor, &(Zathura.Style.completion_g_fg));
|
||||
gdk_color_parse(completion_g_fgcolor, &(Zathura.Style.completion_g_fg));
|
||||
gdk_color_parse(completion_hl_fgcolor, &(Zathura.Style.completion_hl_fg));
|
||||
gdk_color_parse(completion_hl_bgcolor, &(Zathura.Style.completion_hl_bg));
|
||||
gdk_color_parse(notification_e_fgcolor, &(Zathura.Style.notification_e_fg));
|
||||
gdk_color_parse(notification_e_bgcolor, &(Zathura.Style.notification_e_bg));
|
||||
gdk_color_parse(notification_w_fgcolor, &(Zathura.Style.notification_w_fg));
|
||||
gdk_color_parse(notification_w_bgcolor, &(Zathura.Style.notification_w_bg));
|
||||
gdk_color_parse(recolor_darkcolor, &(Zathura.Style.recolor_darkcolor));
|
||||
gdk_color_parse(recolor_lightcolor, &(Zathura.Style.recolor_lightcolor));
|
||||
gdk_color_parse(search_highlight, &(Zathura.Style.search_highlight));
|
||||
gdk_color_parse(select_text, &(Zathura.Style.select_text));
|
||||
Zathura.Style.font = pango_font_description_from_string(font);
|
||||
|
||||
/* other */
|
||||
Zathura.Global.mode = NORMAL;
|
||||
Zathura.Global.viewing_mode = NORMAL;
|
||||
|
@ -523,25 +550,14 @@ init_zathura()
|
|||
#endif
|
||||
|
||||
/* drawing area */
|
||||
gtk_widget_modify_bg(GTK_WIDGET(Zathura.UI.drawing_area), GTK_STATE_NORMAL, &(Zathura.Style.default_bg));
|
||||
gtk_widget_show(Zathura.UI.drawing_area);
|
||||
g_signal_connect(G_OBJECT(Zathura.UI.drawing_area), "expose-event", G_CALLBACK(cb_draw), NULL);
|
||||
|
||||
/* statusbar */
|
||||
gtk_widget_modify_bg(GTK_WIDGET(Zathura.UI.statusbar), GTK_STATE_NORMAL, &(Zathura.Style.statusbar_bg));
|
||||
|
||||
Zathura.Global.status_text = GTK_LABEL(gtk_label_new(NULL));
|
||||
Zathura.Global.status_state = GTK_LABEL(gtk_label_new(NULL));
|
||||
Zathura.Global.status_buffer = GTK_LABEL(gtk_label_new(NULL));
|
||||
|
||||
gtk_widget_modify_fg(GTK_WIDGET(Zathura.Global.status_text), GTK_STATE_NORMAL, &(Zathura.Style.statusbar_fg));
|
||||
gtk_widget_modify_fg(GTK_WIDGET(Zathura.Global.status_state), GTK_STATE_NORMAL, &(Zathura.Style.statusbar_fg));
|
||||
gtk_widget_modify_fg(GTK_WIDGET(Zathura.Global.status_buffer), GTK_STATE_NORMAL, &(Zathura.Style.statusbar_fg));
|
||||
|
||||
gtk_widget_modify_font(GTK_WIDGET(Zathura.Global.status_text), Zathura.Style.font);
|
||||
gtk_widget_modify_font(GTK_WIDGET(Zathura.Global.status_state), Zathura.Style.font);
|
||||
gtk_widget_modify_font(GTK_WIDGET(Zathura.Global.status_buffer), Zathura.Style.font);
|
||||
|
||||
gtk_misc_set_alignment(GTK_MISC(Zathura.Global.status_text), 0.0, 0.0);
|
||||
gtk_misc_set_alignment(GTK_MISC(Zathura.Global.status_state), 1.0, 0.0);
|
||||
gtk_misc_set_alignment(GTK_MISC(Zathura.Global.status_buffer), 1.0, 0.0);
|
||||
|
@ -565,10 +581,6 @@ init_zathura()
|
|||
gtk_entry_set_has_frame( Zathura.UI.inputbar, FALSE);
|
||||
gtk_editable_set_editable( GTK_EDITABLE(Zathura.UI.inputbar), TRUE);
|
||||
|
||||
gtk_widget_modify_base(GTK_WIDGET(Zathura.UI.inputbar), GTK_STATE_NORMAL, &(Zathura.Style.inputbar_bg));
|
||||
gtk_widget_modify_text(GTK_WIDGET(Zathura.UI.inputbar), GTK_STATE_NORMAL, &(Zathura.Style.inputbar_fg));
|
||||
gtk_widget_modify_font(GTK_WIDGET(Zathura.UI.inputbar), Zathura.Style.font);
|
||||
|
||||
Zathura.Handler.inputbar_key_press_event =
|
||||
g_signal_connect(G_OBJECT(Zathura.UI.inputbar), "key-press-event", G_CALLBACK(cb_inputbar_kb_pressed), NULL);
|
||||
Zathura.Handler.inputbar_activate =
|
||||
|
@ -2682,7 +2694,7 @@ cmd_rotate(int argc, char** argv)
|
|||
gboolean
|
||||
cmd_set(int argc, char** argv)
|
||||
{
|
||||
if(argc <= 0 || argc >= 3)
|
||||
if(argc <= 0)
|
||||
return FALSE;
|
||||
|
||||
int i;
|
||||
|
@ -2715,12 +2727,22 @@ cmd_set(int argc, char** argv)
|
|||
}
|
||||
else if(settings[i].type == 's')
|
||||
{
|
||||
if(argc != 2)
|
||||
if(argc < 2)
|
||||
return FALSE;
|
||||
|
||||
/* assembly the arguments back to one string */
|
||||
int i;
|
||||
GString *s = g_string_new("");
|
||||
for(i = 1; i < argc; i++)
|
||||
{
|
||||
if(i != 0)
|
||||
s = g_string_append_c(s, ' ');
|
||||
|
||||
s = g_string_append(s, argv[i]);
|
||||
}
|
||||
|
||||
char **x = (char**) settings[i].variable;
|
||||
if(argv[1])
|
||||
*x = argv[1];
|
||||
*x = s->str;
|
||||
}
|
||||
else if(settings[i].type == 'c')
|
||||
{
|
||||
|
@ -2732,6 +2754,10 @@ cmd_set(int argc, char** argv)
|
|||
*x = argv[1][0];
|
||||
}
|
||||
|
||||
/* re-init */
|
||||
if(settings[i].reinit)
|
||||
init_colors();
|
||||
|
||||
/* render */
|
||||
if(settings[i].render)
|
||||
{
|
||||
|
@ -3675,6 +3701,7 @@ int main(int argc, char* argv[])
|
|||
gtk_init(&argc, &argv);
|
||||
|
||||
init_zathura();
|
||||
init_colors();
|
||||
init_directories();
|
||||
|
||||
if(argc >= 2)
|
||||
|
|
Loading…
Reference in a new issue