diff options
author | QC <qball@gmpclient.org> | 2015-04-11 12:04:14 +0200 |
---|---|---|
committer | QC <qball@gmpclient.org> | 2015-04-11 12:04:14 +0200 |
commit | c1a8735e246db294f80e9ad51c4bfd43af64b5f4 (patch) | |
tree | 9816aa26b44d0d77ba589073bc4e471035c3e6a2 | |
parent | 27dfb8937d882b6a87bd1997a5dbce32ffbaf6d4 (diff) |
Re-enable background/foreground. Make theming method an option.
-rw-r--r-- | config/config.def.c | 42 | ||||
-rw-r--r-- | doc/rofi-manpage.markdown | 7 | ||||
-rw-r--r-- | doc/rofi.1 | 7 | ||||
-rw-r--r-- | include/rofi.h | 1 | ||||
-rw-r--r-- | source/textbox.c | 54 | ||||
-rw-r--r-- | source/x11-helper.c | 32 | ||||
-rw-r--r-- | source/xrmoptions.c | 5 |
7 files changed, 79 insertions, 69 deletions
diff --git a/config/config.def.c b/config/config.def.c index 5935d002..cfd1657c 100644 --- a/config/config.def.c +++ b/config/config.def.c @@ -47,34 +47,36 @@ Settings config = { /** Font */ .menu_font = "mono 12", - /** Background color */ - .menu_bg = NULL, - /** Border color. */ - .menu_bc = NULL, /** Row colors */ - .color_normal = "#fdf6e3,#002b36,#eee8d5,#586e75,#eee8d5", - .color_urgent = "#fdf6e3,#dc322f,#eee8d5,#dc322f,#fdf6e3", - .color_active = "#fdf6e3,#268bd2,#eee8d5,#268bd2,#fdf6e3", - .color_window = "#fdf6e3,#002b36", + // Enable new color + .color_enabled = FALSE, + .color_normal = "#fdf6e3,#002b36,#eee8d5,#586e75,#eee8d5", + .color_urgent = "#fdf6e3,#dc322f,#eee8d5,#dc322f,#fdf6e3", + .color_active = "#fdf6e3,#268bd2,#eee8d5,#268bd2,#fdf6e3", + .color_window = "#fdf6e3,#002b36", + /** Background color */ + .menu_bg = "#FDF6E3", + /** Border color. */ + .menu_bc = "#002B36", /** Foreground color */ - .menu_fg = NULL, + .menu_fg = "#002B36", /** Text color used for urgent windows */ - .menu_fg_urgent = NULL, + .menu_fg_urgent = "#DC322F", /** Text color used for active window */ - .menu_fg_active = NULL, - .menu_bg_urgent = NULL, - .menu_bg_active = NULL, + .menu_fg_active = "#268BD2", + .menu_bg_urgent = "#FDF6E3", + .menu_bg_active = "#FDF6E3", /** Background color alternate row */ - .menu_bg_alt = NULL, + .menu_bg_alt = "#EEE8D5", /** Foreground color (selected) */ - .menu_hlfg = NULL, - .menu_hlfg_urgent = NULL, - .menu_hlfg_active = NULL, + .menu_hlfg = "#EEE8D5", + .menu_hlfg_urgent = "#FDF6E3", + .menu_hlfg_active = "#FDF6E3", /** Background color (selected) */ - .menu_hlbg = NULL, - .menu_hlbg_urgent = NULL, - .menu_hlbg_active = NULL, + .menu_hlbg = "#586E75", + .menu_hlbg_urgent = "#DC322F", + .menu_hlbg_active = "#268BD2", /** Terminal to use. (for ssh and open in terminal) */ .terminal_emulator = "x-terminal-emulator", .ssh_client = "ssh", diff --git a/doc/rofi-manpage.markdown b/doc/rofi-manpage.markdown index 55247c86..f6dfd4d8 100644 --- a/doc/rofi-manpage.markdown +++ b/doc/rofi-manpage.markdown @@ -506,8 +506,9 @@ override xresources). ## Theming -With **rofi** 0.15.4 we have a new way of specifying colors, the old settings still apply (for now) -and override the new setup. The new setup allows you to specify colors per state, similar to **i3** +With **rofi** 0.15.4 we have a new way of specifying colors, the old settings still apply (for now). +To enable the new setup, set `rofi.color-enabled` to true. The new setup allows you to specify +colors per state, similar to **i3** Currently 3 states exists: * **normal** Normal row. @@ -527,7 +528,7 @@ a pair `background,border`. An example for `Xresources` file: ``` -! State: 'bg', 'fg', 'bgalt', 'hlfg', 'hlbg' +! State: 'bg', 'fg', 'bgalt', 'hlbg', 'hlfg' rofi.color-normal: #fdf6e3, #002b36, #eee8d5, #586e75, #eee8d5 rofi.color-urgent: #fdf6e3, #dc322f, #eee8d5, #dc322f, #fdf6e3 rofi.color-active: #fdf6e3, #268bd2, #eee8d5, #268bd2, #fdf6e3 @@ -633,8 +633,9 @@ If in daemon mode, reload the configuration from Xresources. (commandline argume override xresources). .SH Theming .PP -With \fBrofi\fP 0.15.4 we have a new way of specifying colors, the old settings still apply (for now) -and override the new setup. The new setup allows you to specify colors per state, similar to \fBi3\fP +With \fBrofi\fP 0.15.4 we have a new way of specifying colors, the old settings still apply (for now). +To enable the new setup, set \fB\fCrofi.color\-enabled\fR to true. The new setup allows you to specify +colors per state, similar to \fBi3\fP Currently 3 states exists: .RS .IP \(bu 2 @@ -666,7 +667,7 @@ An example for \fB\fCXresources\fR file: .PP .RS .nf -! State: 'bg', 'fg', 'bgalt', 'hlfg', 'hlbg' +! State: 'bg', 'fg', 'bgalt', 'hlbg', 'hlfg' rofi.color\-normal: #fdf6e3, #002b36, #eee8d5, #586e75, #eee8d5 rofi.color\-urgent: #fdf6e3, #dc322f, #eee8d5, #dc322f, #fdf6e3 rofi.color\-active: #fdf6e3, #268bd2, #eee8d5, #268bd2, #fdf6e3 diff --git a/include/rofi.h b/include/rofi.h index b3f46ff6..65698430 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -154,6 +154,7 @@ typedef struct _Settings char * menu_font; /** New row colors */ + unsigned int color_enabled; char * color_normal; char * color_active; char * color_urgent; diff --git a/source/textbox.c b/source/textbox.c index e328e19e..cb2477c7 100644 --- a/source/textbox.c +++ b/source/textbox.c @@ -621,7 +621,6 @@ static void parse_color ( Visual *visual, Colormap colormap, XftColorAllocName ( display, visual, colormap, bg, color ); } } -#if 1 static void textbox_parse_string ( XVisualInfo *visual, Colormap colormap, const char *str, RowColor *color ) { if ( str == NULL ) { @@ -654,37 +653,38 @@ static void textbox_parse_string ( XVisualInfo *visual, Colormap colormap, const } g_free ( cstr ); } -#endif void textbox_setup ( XVisualInfo *visual, Colormap colormap ) { visual_info = visual; target_colormap = colormap; - textbox_parse_string ( visual, target_colormap, - config.color_normal, &( colors[NORMAL] ) ); - textbox_parse_string ( visual, target_colormap, - config.color_urgent, &( colors[URGENT] ) ); - textbox_parse_string ( visual, target_colormap, - config.color_active, &( colors[ACTIVE] ) ); -#if 1 - parse_color ( visual_info->visual, target_colormap, config.menu_bg, &( colors[NORMAL].bg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_fg, &( colors[NORMAL].fg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_bg_alt, &( colors[NORMAL].bgalt ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_hlfg, &( colors[NORMAL].hlfg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_hlbg, &( colors[NORMAL].hlbg ) ); - - parse_color ( visual_info->visual, target_colormap, config.menu_bg_urgent, &( colors[URGENT].bg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_fg_urgent, &( colors[URGENT].fg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_bg_alt, &( colors[URGENT].bgalt ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_hlfg_urgent, &( colors[URGENT].hlfg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_hlbg_urgent, &( colors[URGENT].hlbg ) ); - - parse_color ( visual_info->visual, target_colormap, config.menu_bg_active, &( colors[ACTIVE].bg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_fg_active, &( colors[ACTIVE].fg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_bg_alt, &( colors[ACTIVE].bgalt ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_hlfg_active, &( colors[ACTIVE].hlfg ) ); - parse_color ( visual_info->visual, target_colormap, config.menu_hlbg_active, &( colors[ACTIVE].hlbg ) ); -#endif + if ( config.color_enabled ) { + textbox_parse_string ( visual, target_colormap, + config.color_normal, &( colors[NORMAL] ) ); + textbox_parse_string ( visual, target_colormap, + config.color_urgent, &( colors[URGENT] ) ); + textbox_parse_string ( visual, target_colormap, + config.color_active, &( colors[ACTIVE] ) ); + } + else { + parse_color ( visual_info->visual, target_colormap, config.menu_bg, &( colors[NORMAL].bg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_fg, &( colors[NORMAL].fg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_bg_alt, &( colors[NORMAL].bgalt ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_hlfg, &( colors[NORMAL].hlfg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_hlbg, &( colors[NORMAL].hlbg ) ); + + parse_color ( visual_info->visual, target_colormap, config.menu_bg_urgent, &( colors[URGENT].bg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_fg_urgent, &( colors[URGENT].fg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_bg_alt, &( colors[URGENT].bgalt ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_hlfg_urgent, &( colors[URGENT].hlfg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_hlbg_urgent, &( colors[URGENT].hlbg ) ); + + parse_color ( visual_info->visual, target_colormap, config.menu_bg_active, &( colors[ACTIVE].bg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_fg_active, &( colors[ACTIVE].fg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_bg_alt, &( colors[ACTIVE].bgalt ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_hlfg_active, &( colors[ACTIVE].hlfg ) ); + parse_color ( visual_info->visual, target_colormap, config.menu_hlbg_active, &( colors[ACTIVE].hlbg ) ); + } PangoFontMap *font_map = pango_xft_get_font_map ( display, DefaultScreen ( display ) ); p_context = pango_font_map_create_context ( font_map ); } diff --git a/source/x11-helper.c b/source/x11-helper.c index 7c4435ed..57cb55ce 100644 --- a/source/x11-helper.c +++ b/source/x11-helper.c @@ -447,30 +447,34 @@ unsigned int color_get ( Display *display, const char *const name ) unsigned int color_background ( Display *display ) { - if ( config.menu_bg ) { + if ( !config.color_enabled ) { return color_get ( display, config.menu_bg ); } - unsigned int retv = 0; + else { + unsigned int retv = 0; - gchar **vals = g_strsplit ( config.color_window, ",", 2 ); - if ( vals != NULL && vals[0] != NULL ) { - retv = color_get ( display, vals[0] ); + gchar **vals = g_strsplit ( config.color_window, ",", 2 ); + if ( vals != NULL && vals[0] != NULL ) { + retv = color_get ( display, vals[0] ); + } + g_strfreev ( vals ); + return retv; } - g_strfreev ( vals ); - return retv; } unsigned int color_border ( Display *display ) { - if ( config.menu_bc ) { + if ( !config.color_enabled ) { return color_get ( display, config.menu_bc ); } - unsigned int retv = 0; + else { + unsigned int retv = 0; - gchar **vals = g_strsplit ( config.color_window, ",", 2 ); - if ( vals != NULL && vals[0] != NULL && vals[1] != NULL ) { - retv = color_get ( display, vals[1] ); + gchar **vals = g_strsplit ( config.color_window, ",", 2 ); + if ( vals != NULL && vals[0] != NULL && vals[1] != NULL ) { + retv = color_get ( display, vals[1] ); + } + g_strfreev ( vals ); + return retv; } - g_strfreev ( vals ); - return retv; } diff --git a/source/xrmoptions.c b/source/xrmoptions.c index 41bd86ff..d9e03b52 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -64,11 +64,12 @@ static XrmOption xrmOptions[] = { { xrm_String, "font", { .str = &config.menu_font }, NULL }, /* Foreground color */ -/* { xrm_String, "foreground", { .str = &config.menu_fg }, NULL },*/ + { xrm_String, "foreground", { .str = &config.menu_fg }, NULL }, { xrm_String, "fg", { .str = &config.menu_fg }, NULL }, -/* { xrm_String, "background", { .str = &config.menu_bg }, NULL },*/ + { xrm_String, "background", { .str = &config.menu_bg }, NULL }, { xrm_String, "bg", { .str = &config.menu_bg }, NULL }, + { xrm_Boolean, "color-enabled", { .num = &config.color_enabled }, NULL }, { xrm_String, "color-normal", { .str = &config.color_normal }, NULL }, { xrm_String, "color-urgent", { .str = &config.color_urgent }, NULL }, { xrm_String, "color-active", { .str = &config.color_active }, NULL }, |