Use config.h for default ellipsize value

Get the default value for ellipsize from config.h, instead of
setting it in two different places (in case it is not set, and in
case its value is invalid).
This commit is contained in:
fhost 2017-09-24 16:53:58 +02:00
parent 4316c85e18
commit f9f6830c71
2 changed files with 14 additions and 14 deletions

View File

@ -27,6 +27,7 @@ int sticky_history = true;
int history_length = 20; /* max amount of notifications kept in history */ int history_length = 20; /* max amount of notifications kept in history */
int show_indicators = true; int show_indicators = true;
int word_wrap = false; int word_wrap = false;
enum ellipsize ellipsize = middle;
int ignore_newline = false; int ignore_newline = false;
int line_height = 0; /* if line height < font height, it will be raised to font height */ int line_height = 0; /* if line height < font height, it will be raised to font height */
int notification_height = 0; /* if notification height < font height and padding, it will be raised */ int notification_height = 0; /* if notification height < font height and padding, it will be raised */

View File

@ -172,25 +172,24 @@ void load_settings(char *cmdline_config_path)
{ {
char *c = option_get_string( char *c = option_get_string(
"global", "global",
"ellipsize", "-ellipsize", "middle", "ellipsize", "-ellipsize", "",
"Ellipsize truncated lines on the start/middle/end" "Ellipsize truncated lines on the start/middle/end"
); );
if (strlen(c) > 0) { if (strlen(c) == 0) {
if (strcmp(c, "start") == 0) settings.ellipsize = ellipsize;
} else if (strcmp(c, "start") == 0) {
settings.ellipsize = start; settings.ellipsize = start;
else if (strcmp(c, "middle") == 0) } else if (strcmp(c, "middle") == 0) {
settings.ellipsize = middle; settings.ellipsize = middle;
else if (strcmp(c, "end") == 0) } else if (strcmp(c, "end") == 0) {
settings.ellipsize = end; settings.ellipsize = end;
else { } else {
fprintf(stderr, fprintf(stderr, "Warning: unknown ellipsize value: \"%s\"\n", c);
"Warning: unknown value for ellipsize\n"); settings.ellipsize = ellipsize;
settings.ellipsize = middle;
} }
g_free(c); g_free(c);
} }
}
settings.ignore_newline = option_get_bool( settings.ignore_newline = option_get_bool(
"global", "global",