1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Fix #258: Set fallback alternative color before trying to allocate it.

This commit is contained in:
Qball Cow 2015-11-04 12:03:59 +01:00
parent 4c8404f87d
commit aedd26aef4
4 changed files with 154 additions and 82 deletions

View file

@ -539,6 +539,11 @@ void remove_pid_file ( int fd )
*/
void config_sanity_check ( Display *display )
{
// If alternative row is not set, copy the normal background color.
// Do this at the beginning as we might use it in the error dialog.
if ( config.menu_bg_alt == NULL ) {
config.menu_bg_alt = config.menu_bg;
}
int found_error = FALSE;
GString *msg = g_string_new (
"<big><b>The configuration failed to validate:</b></big>\n" );
@ -612,10 +617,6 @@ void config_sanity_check ( Display *display )
}
g_string_free ( msg, TRUE );
// If alternative row is not set, copy the normal background color.
if ( config.menu_bg_alt == NULL ) {
config.menu_bg_alt = config.menu_bg;
}
}
int is_not_ascii ( const char * str )

View file

@ -906,9 +906,11 @@ static void menu_update ( MenuState *state )
}
if ( config.sidebar_mode == TRUE ) {
for ( unsigned int j = 0; j < num_switchers; j++ ) {
if ( switchers[j].tb != NULL ) {
textbox_draw ( switchers[j].tb, d );
}
}
}
state->update = FALSE;
// Draw to actual window.
@ -1711,7 +1713,8 @@ static void print_main_application_options ( void )
"\t"color_bold "-dump-xresources"color_reset
" Dump the current configuration in Xresources format and exit.\n" );
printf (
"\t"color_bold "-e [string]"color_reset " Show a dialog displaying the passed message and exit.\n" );
"\t"color_bold "-e [string]"color_reset
" Show a dialog displaying the passed message and exit.\n" );
printf ( "\t"color_bold "-markup"color_reset " Enable pango markup where possible.\n" );
printf (
"\t"color_bold "-normal-window"color_reset

View file

@ -55,88 +55,156 @@ typedef struct
* Currently supports string, boolean and number (signed and unsigned).
*/
static XrmOption xrmOptions[] = {
{ xrm_String, "switchers", { .str = &config.switchers }, NULL, "" },
{ xrm_String, "modi", { .str = &config.switchers }, NULL, "Enabled modi" },
{ xrm_Number, "opacity", { .num = &config.window_opacity }, NULL, "Window opacity" },
{ xrm_SNumber, "width", { .snum = &config.menu_width }, NULL, "Window width" },
{ xrm_Number, "lines", { .num = &config.menu_lines }, NULL, "Number of lines" },
{ xrm_Number, "columns", { .num = &config.menu_columns }, NULL, "Number of columns" },
{ xrm_String, "switchers", { .str = &config.switchers }, NULL,
"" },
{ xrm_String, "modi", { .str = &config.switchers }, NULL,
"Enabled modi" },
{ xrm_Number, "opacity", { .num = &config.window_opacity }, NULL,
"Window opacity" },
{ xrm_SNumber, "width", { .snum = &config.menu_width }, NULL,
"Window width" },
{ xrm_Number, "lines", { .num = &config.menu_lines }, NULL,
"Number of lines" },
{ xrm_Number, "columns", { .num = &config.menu_columns }, NULL,
"Number of columns" },
{ xrm_String, "font", { .str = &config.menu_font }, NULL, "Font to use" },
{ xrm_String, "font", { .str = &config.menu_font }, NULL,
"Font to use" },
/* Foreground color */
{ xrm_String, "foreground", { .str = &config.menu_fg }, NULL, "" },
{ xrm_String, "fg", { .str = &config.menu_fg }, NULL, "Foreground color" },
{ xrm_String, "background", { .str = &config.menu_bg }, NULL, "" },
{ xrm_String, "bg", { .str = &config.menu_bg }, NULL, "Background color" },
{ xrm_String, "foreground", { .str = &config.menu_fg }, NULL,
"" },
{ xrm_String, "fg", { .str = &config.menu_fg }, NULL,
"Foreground color" },
{ xrm_String, "background", { .str = &config.menu_bg }, NULL,
"" },
{ xrm_String, "bg", { .str = &config.menu_bg }, NULL,
"Background color" },
{ xrm_String, "fg-active", { .str = &config.menu_fg_active }, NULL, "Foreground color for active row" },
{ xrm_String, "fg-urgent", { .str = &config.menu_fg_urgent }, NULL, "Foreground color for urgent row" },
{ xrm_String, "hlfg-active", { .str = &config.menu_hlfg_active }, NULL, "Foreground color for highlighted active row" },
{ xrm_String, "hlfg-urgent", { .str = &config.menu_hlfg_urgent }, NULL, "Foreground color for highlighted urgent row" },
{ xrm_String, "fg-active", { .str = &config.menu_fg_active }, NULL,
"Foreground color for active row" },
{ xrm_String, "fg-urgent", { .str = &config.menu_fg_urgent }, NULL,
"Foreground color for urgent row" },
{ xrm_String, "hlfg-active", { .str = &config.menu_hlfg_active }, NULL,
"Foreground color for highlighted active row" },
{ xrm_String, "hlfg-urgent", { .str = &config.menu_hlfg_urgent }, NULL,
"Foreground color for highlighted urgent row" },
{ xrm_String, "bg-active", { .str = &config.menu_bg_active }, NULL, "Background color for active row" },
{ xrm_String, "bg-urgent", { .str = &config.menu_bg_urgent }, NULL, "Background color for urgent row" },
{ xrm_String, "hlbg-active", { .str = &config.menu_hlbg_active }, NULL, "Background color for highlighted active row" },
{ xrm_String, "hlbg-urgent", { .str = &config.menu_hlbg_urgent }, NULL, "Background color for highlighted urgent row" },
{ xrm_String, "bg-active", { .str = &config.menu_bg_active }, NULL,
"Background color for active row" },
{ xrm_String, "bg-urgent", { .str = &config.menu_bg_urgent }, NULL,
"Background color for urgent row" },
{ xrm_String, "hlbg-active", { .str = &config.menu_hlbg_active }, NULL,
"Background color for highlighted active row" },
{ xrm_String, "hlbg-urgent", { .str = &config.menu_hlbg_urgent }, NULL,
"Background color for highlighted urgent row" },
{ xrm_String, "background-alternate", { .str = &config.menu_bg_alt }, NULL, "" },
{ xrm_String, "bgalt", { .str = &config.menu_bg_alt }, NULL, "Background color for alternating row" },
{ xrm_String, "background-alternate", { .str = &config.menu_bg_alt }, NULL,
"" },
{ xrm_String, "bgalt", { .str = &config.menu_bg_alt }, NULL,
"Background color for alternating row" },
{ xrm_String, "highlightfg", { .str = &config.menu_hlfg }, NULL, "" },
{ xrm_String, "hlfg", { .str = &config.menu_hlfg }, NULL, "Foreground color for highlighted row" },
{ xrm_String, "highlightfg", { .str = &config.menu_hlfg }, NULL,
"" },
{ xrm_String, "hlfg", { .str = &config.menu_hlfg }, NULL,
"Foreground color for highlighted row" },
{ xrm_String, "highlightbg", { .str = &config.menu_hlbg }, NULL, "" },
{ xrm_String, "hlbg", { .str = &config.menu_hlbg }, NULL, "Background color for highlighted row" },
{ xrm_String, "highlightbg", { .str = &config.menu_hlbg }, NULL,
"" },
{ xrm_String, "hlbg", { .str = &config.menu_hlbg }, NULL,
"Background color for highlighted row" },
{ xrm_String, "bordercolor", { .str = &config.menu_bc }, NULL, "" },
{ xrm_String, "bc", { .str = &config.menu_bc }, NULL, "Border color" },
{ xrm_Boolean, "color-enabled", { .num = &config.color_enabled }, NULL, "Use extended color scheme" },
{ xrm_String, "color-normal", { .str = &config.color_normal }, NULL, "Color scheme for normal row" },
{ xrm_String, "color-urgent", { .str = &config.color_urgent }, NULL, "Color scheme for urgent row" },
{ xrm_String, "color-active", { .str = &config.color_active }, NULL, "Color scheme for active row" },
{ xrm_String, "color-window", { .str = &config.color_window }, NULL, "Color scheme window" },
{ xrm_String, "bordercolor", { .str = &config.menu_bc }, NULL,
"" },
{ xrm_String, "bc", { .str = &config.menu_bc }, NULL,
"Border color" },
{ xrm_Boolean, "color-enabled", { .num = &config.color_enabled }, NULL,
"Use extended color scheme" },
{ xrm_String, "color-normal", { .str = &config.color_normal }, NULL,
"Color scheme for normal row" },
{ xrm_String, "color-urgent", { .str = &config.color_urgent }, NULL,
"Color scheme for urgent row" },
{ xrm_String, "color-active", { .str = &config.color_active }, NULL,
"Color scheme for active row" },
{ xrm_String, "color-window", { .str = &config.color_window }, NULL,
"Color scheme window" },
{ xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL, "" },
{ xrm_Number, "bw", { .num = &config.menu_bw }, NULL, "Border width" },
{ xrm_Number, "borderwidth", { .num = &config.menu_bw }, NULL,
"" },
{ xrm_Number, "bw", { .num = &config.menu_bw }, NULL,
"Border width" },
{ xrm_Number, "location", { .num = &config.location }, NULL, "Location on screen" },
{ xrm_Number, "location", { .num = &config.location }, NULL,
"Location on screen" },
{ xrm_Number, "padding", { .num = &config.padding }, NULL, "Padding" },
{ xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL, "Y-offset relative to location" },
{ xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL, "X-offset relative to location" },
{ xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL, "Always show number of lines" },
{ xrm_Number, "padding", { .num = &config.padding }, NULL,
"Padding" },
{ xrm_SNumber, "yoffset", { .snum = &config.y_offset }, NULL,
"Y-offset relative to location" },
{ xrm_SNumber, "xoffset", { .snum = &config.x_offset }, NULL,
"X-offset relative to location" },
{ xrm_Boolean, "fixed-num-lines", { .num = &config.fixed_num_lines }, NULL,
"Always show number of lines" },
{ xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL, "Terminal to use" },
{ xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL, "Ssh client to use" },
{ xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL, "Ssh command to execute" },
{ xrm_String, "run-command", { .str = &config.run_command }, NULL, "Run command to execute" },
{ xrm_String, "run-list-command", { .str = &config.run_list_command }, NULL, "Command to get extra run targets" },
{ xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL, "Run command to execute that runs in shell" },
{ xrm_String, "terminal", { .str = &config.terminal_emulator }, NULL,
"Terminal to use" },
{ xrm_String, "ssh-client", { .str = &config.ssh_client }, NULL,
"Ssh client to use" },
{ xrm_String, "ssh-command", { .str = &config.ssh_command }, NULL,
"Ssh command to execute" },
{ xrm_String, "run-command", { .str = &config.run_command }, NULL,
"Run command to execute" },
{ xrm_String, "run-list-command", { .str = &config.run_list_command }, NULL,
"Command to get extra run targets" },
{ xrm_String, "run-shell-command", { .str = &config.run_shell_command }, NULL,
"Run command to execute that runs in shell" },
{ xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL, "Disable history in run/ssh" },
{ xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort }, NULL, "Use levenshtein sorting" },
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL, "Set case-sensitivity" },
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL, "Enable sidebar-mode" },
{ xrm_Number, "lazy-filter-limit", { .num = &config.lazy_filter_limit }, NULL, "Set lazy filter limit" },
{ xrm_SNumber, "eh", { .snum = &config.element_height }, NULL, "Row height (in chars)" },
{ xrm_Boolean, "auto-select", { .num = &config.auto_select }, NULL, "Enable auto select mode" },
{ xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts }, NULL, "Parse hosts file for ssh mode" },
{ xrm_Boolean, "parse-known-hosts", { .num = &config.parse_known_hosts }, NULL, "Parse known_hosts file for ssh mode" },
{ xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL, "Set the modi to combine in combi mode" },
{ xrm_Boolean, "fuzzy", { .num = &config.fuzzy }, NULL, "Do a more fuzzy matching" },
{ xrm_Boolean, "glob", { .num = &config.glob }, NULL, "Use glob matching" },
{ xrm_Boolean, "tokenize", { .num = &config.tokenize }, NULL, "Tokenize input string" },
{ xrm_Number, "monitor", { .snum = &config.monitor }, NULL, "" },
{ xrm_Boolean, "disable-history", { .num = &config.disable_history }, NULL,
"Disable history in run/ssh" },
{ xrm_Boolean, "levenshtein-sort", { .num = &config.levenshtein_sort }, NULL,
"Use levenshtein sorting" },
{ xrm_Boolean, "case-sensitive", { .num = &config.case_sensitive }, NULL,
"Set case-sensitivity" },
{ xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL,
"Enable sidebar-mode" },
{ xrm_Number, "lazy-filter-limit", { .num = &config.lazy_filter_limit }, NULL,
"Set lazy filter limit" },
{ xrm_SNumber, "eh", { .snum = &config.element_height }, NULL,
"Row height (in chars)" },
{ xrm_Boolean, "auto-select", { .num = &config.auto_select }, NULL,
"Enable auto select mode" },
{ xrm_Boolean, "parse-hosts", { .num = &config.parse_hosts }, NULL,
"Parse hosts file for ssh mode" },
{ xrm_Boolean, "parse-known-hosts", { .num = &config.parse_known_hosts }, NULL,
"Parse known_hosts file for ssh mode" },
{ xrm_String, "combi-modi", { .str = &config.combi_modi }, NULL,
"Set the modi to combine in combi mode" },
{ xrm_Boolean, "fuzzy", { .num = &config.fuzzy }, NULL,
"Do a more fuzzy matching" },
{ xrm_Boolean, "glob", { .num = &config.glob }, NULL,
"Use glob matching" },
{ xrm_Boolean, "tokenize", { .num = &config.tokenize }, NULL,
"Tokenize input string" },
{ xrm_Number, "monitor", { .snum = &config.monitor }, NULL,
"" },
/* Alias for dmenu compatibility. */
{ xrm_SNumber, "m", { .snum = &config.monitor }, NULL, "Monitor id to show on" },
{ xrm_Number, "line-margin", { .num = &config.line_margin }, NULL, "Margin between rows" },
{ xrm_String, "filter", { .str = &config.filter }, NULL, "Pre-set filter" },
{ xrm_String, "separator-style", { .str = &config.separator_style }, NULL, "Separator style (none, dash, solid)" },
{ xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar }, NULL, "Hide scroll-bar" },
{ xrm_Boolean, "markup-rows", { .num = &config.markup_rows }, NULL, "Show markup" },
{ xrm_Boolean, "fullscreen", { .num = &config.fullscreen }, NULL, "Fullscreen" },
{ xrm_Boolean, "fake-transparency", { .num = &config.fake_transparency }, NULL, "Fake transparency" },
{ xrm_SNumber, "dpi", { .snum = &config.dpi }, NULL, "DPI" }
{ xrm_SNumber, "m", { .snum = &config.monitor }, NULL,
"Monitor id to show on" },
{ xrm_Number, "line-margin", { .num = &config.line_margin }, NULL,
"Margin between rows" },
{ xrm_String, "filter", { .str = &config.filter }, NULL,
"Pre-set filter" },
{ xrm_String, "separator-style", { .str = &config.separator_style }, NULL,
"Separator style (none, dash, solid)" },
{ xrm_Boolean, "hide-scrollbar", { .num = &config.hide_scrollbar }, NULL,
"Hide scroll-bar" },
{ xrm_Boolean, "markup-rows", { .num = &config.markup_rows }, NULL,
"Show markup" },
{ xrm_Boolean, "fullscreen", { .num = &config.fullscreen }, NULL,
"Fullscreen" },
{ xrm_Boolean, "fake-transparency", { .num = &config.fake_transparency }, NULL,
"Fake transparency" },
{ xrm_SNumber, "dpi", { .snum = &config.dpi }, NULL,
"DPI" }
};
// Dynamic options.