From f9f6830c7165ca82b1a2fb110c8a1936a2829d93 Mon Sep 17 00:00:00 2001 From: fhost Date: Sun, 24 Sep 2017 16:53:58 +0200 Subject: [PATCH] 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). --- config.def.h | 1 + src/settings.c | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config.def.h b/config.def.h index 76763b9..0444522 100644 --- a/config.def.h +++ b/config.def.h @@ -27,6 +27,7 @@ int sticky_history = true; int history_length = 20; /* max amount of notifications kept in history */ int show_indicators = true; int word_wrap = false; +enum ellipsize ellipsize = middle; int ignore_newline = false; 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 */ diff --git a/src/settings.c b/src/settings.c index 66c897f..3f4b88a 100644 --- a/src/settings.c +++ b/src/settings.c @@ -172,24 +172,23 @@ void load_settings(char *cmdline_config_path) { char *c = option_get_string( "global", - "ellipsize", "-ellipsize", "middle", + "ellipsize", "-ellipsize", "", "Ellipsize truncated lines on the start/middle/end" ); - if (strlen(c) > 0) { - if (strcmp(c, "start") == 0) - settings.ellipsize = start; - else if (strcmp(c, "middle") == 0) - settings.ellipsize = middle; - else if (strcmp(c, "end") == 0) - settings.ellipsize = end; - else { - fprintf(stderr, - "Warning: unknown value for ellipsize\n"); - settings.ellipsize = middle; - } - g_free(c); + if (strlen(c) == 0) { + settings.ellipsize = ellipsize; + } else if (strcmp(c, "start") == 0) { + settings.ellipsize = start; + } else if (strcmp(c, "middle") == 0) { + settings.ellipsize = middle; + } else if (strcmp(c, "end") == 0) { + settings.ellipsize = end; + } else { + fprintf(stderr, "Warning: unknown ellipsize value: \"%s\"\n", c); + settings.ellipsize = ellipsize; } + g_free(c); } settings.ignore_newline = option_get_bool(