From 3e205ff15993f71f9c4cfbed14348e8f2ceec8d9 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Fri, 12 Jan 2018 19:10:50 +0100 Subject: [PATCH] Use notification_colors struct in settings --- config.h | 12 ++++++------ src/markup.h | 7 ++++++- src/notification.h | 2 +- src/settings.c | 32 ++++++++++++++++---------------- src/settings.h | 15 +++++---------- src/x11/x.c | 24 ++++++++++++------------ 6 files changed, 46 insertions(+), 46 deletions(-) diff --git a/config.h b/config.h index 42de31d..25f35b8 100644 --- a/config.h +++ b/config.h @@ -4,12 +4,12 @@ struct settings defaults = { .font = "-*-terminus-medium-r-*-*-16-*-*-*-*-*-*-*", .markup = MARKUP_NO, -.normbgcolor = "#1793D1", -.normfgcolor = "#DDDDDD", -.critbgcolor = "#ffaaaa", -.critfgcolor = "#000000", -.lowbgcolor = "#aaaaff", -.lowfgcolor = "#000000", +.colors_norm.bg = "#1793D1", +.colors_norm.fg = "#DDDDDD", +.colors_crit.bg = "#ffaaaa", +.colors_crit.fg = "#000000", +.colors_low.bg = "#aaaaff", +.colors_low.fg = "#000000", .format = "%s %b", /* default format */ .timeouts = { S2US(10), S2US(10), S2US(0) }, /* low, normal, critical */ diff --git a/src/markup.h b/src/markup.h index aea4f0f..41b0e9a 100644 --- a/src/markup.h +++ b/src/markup.h @@ -2,7 +2,12 @@ #ifndef DUNST_MARKUP_H #define DUNST_MARKUP_H -#include "settings.h" +enum markup_mode { + MARKUP_NULL, + MARKUP_NO, + MARKUP_STRIP, + MARKUP_FULL +}; /** * Strip any markup from text; turn it in to plain text. diff --git a/src/notification.h b/src/notification.h index de18926..cc1e26e 100644 --- a/src/notification.h +++ b/src/notification.h @@ -5,7 +5,7 @@ #include #include -#include "settings.h" +#include "markup.h" #define DUNST_NOTIF_MAX_CHARS 5000 diff --git a/src/settings.c b/src/settings.c index bdd299f..fb04d85 100644 --- a/src/settings.c +++ b/src/settings.c @@ -621,19 +621,19 @@ void load_settings(char *cmdline_config_path) g_free(c); } - settings.lowbgcolor = option_get_string( + settings.colors_low.bg = option_get_string( "urgency_low", - "background", "-lb", defaults.lowbgcolor, + "background", "-lb", defaults.colors_low.bg, "Background color for notifications with low urgency" ); - settings.lowfgcolor = option_get_string( + settings.colors_low.fg = option_get_string( "urgency_low", - "foreground", "-lf", defaults.lowfgcolor, + "foreground", "-lf", defaults.colors_low.fg, "Foreground color for notifications with low urgency" ); - settings.lowframecolor = option_get_string( + settings.colors_low.frame = option_get_string( "urgency_low", "frame_color", "-lfr", NULL, "Frame color for notifications with low urgency" @@ -651,19 +651,19 @@ void load_settings(char *cmdline_config_path) "Icon for notifications with low urgency" ); - settings.normbgcolor = option_get_string( + settings.colors_norm.bg = option_get_string( "urgency_normal", - "background", "-nb", defaults.normbgcolor, + "background", "-nb", defaults.colors_norm.bg, "Background color for notifications with normal urgency" ); - settings.normfgcolor = option_get_string( + settings.colors_norm.fg = option_get_string( "urgency_normal", - "foreground", "-nf", defaults.normfgcolor, + "foreground", "-nf", defaults.colors_norm.fg, "Foreground color for notifications with normal urgency" ); - settings.normframecolor = option_get_string( + settings.colors_norm.frame = option_get_string( "urgency_normal", "frame_color", "-nfr", NULL, "Frame color for notifications with normal urgency" @@ -681,19 +681,19 @@ void load_settings(char *cmdline_config_path) "Icon for notifications with normal urgency" ); - settings.critbgcolor = option_get_string( + settings.colors_crit.bg = option_get_string( "urgency_critical", - "background", "-cb", defaults.critbgcolor, + "background", "-cb", defaults.colors_crit.bg, "Background color for notifications with critical urgency" ); - settings.critfgcolor = option_get_string( + settings.colors_crit.fg = option_get_string( "urgency_critical", - "foreground", "-cf", defaults.critfgcolor, - "Foreground color for notifications with critical urgency" + "foreground", "-cf", defaults.colors_crit.fg, + "Foreground color for notifications with ciritical urgency" ); - settings.critframecolor = option_get_string( + settings.colors_crit.frame = option_get_string( "urgency_critical", "frame_color", "-cfr", NULL, "Frame color for notifications with critical urgency" diff --git a/src/settings.h b/src/settings.h index 21419e0..8e64507 100644 --- a/src/settings.h +++ b/src/settings.h @@ -4,6 +4,8 @@ #include +#include "markup.h" +#include "notification.h" #include "x11/x.h" enum alignment { ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT }; @@ -11,7 +13,6 @@ enum ellipsize { ELLIPSE_START, ELLIPSE_MIDDLE, ELLIPSE_END }; enum icon_position { ICON_LEFT, ICON_RIGHT, ICON_OFF }; enum separator_color { SEP_FOREGROUND, SEP_AUTO, SEP_FRAME, SEP_CUSTOM }; enum follow_mode { FOLLOW_NONE, FOLLOW_MOUSE, FOLLOW_KEYBOARD }; -enum markup_mode { MARKUP_NULL, MARKUP_NO, MARKUP_STRIP, MARKUP_FULL }; enum mouse_action { MOUSE_NONE, MOUSE_DO_ACTION, MOUSE_CLOSE_CURRENT, MOUSE_CLOSE_ALL }; struct geometry { @@ -33,15 +34,9 @@ struct settings { bool stack_duplicates; bool hide_duplicate_count; char *font; - char *normbgcolor; - char *normfgcolor; - char *normframecolor; - char *critbgcolor; - char *critfgcolor; - char *critframecolor; - char *lowbgcolor; - char *lowfgcolor; - char *lowframecolor; + struct notification_colors colors_low; + struct notification_colors colors_norm; + struct notification_colors colors_crit; char *format; gint64 timeouts[3]; char *icons[3]; diff --git a/src/x11/x.c b/src/x11/x.c index ca613a6..6007fc1 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -464,24 +464,24 @@ void x_setup(void) x_shortcut_grab(&settings.context_ks); x_shortcut_ungrab(&settings.context_ks); - xctx.colors[ColFG][URG_LOW] = settings.lowfgcolor; - xctx.colors[ColFG][URG_NORM] = settings.normfgcolor; - xctx.colors[ColFG][URG_CRIT] = settings.critfgcolor; + xctx.colors[ColFG][URG_LOW] = settings.colors_low.fg; + xctx.colors[ColFG][URG_NORM] = settings.colors_norm.fg; + xctx.colors[ColFG][URG_CRIT] = settings.colors_crit.fg; - xctx.colors[ColBG][URG_LOW] = settings.lowbgcolor; - xctx.colors[ColBG][URG_NORM] = settings.normbgcolor; - xctx.colors[ColBG][URG_CRIT] = settings.critbgcolor; + xctx.colors[ColBG][URG_LOW] = settings.colors_low.bg; + xctx.colors[ColBG][URG_NORM] = settings.colors_norm.bg; + xctx.colors[ColBG][URG_CRIT] = settings.colors_crit.bg; - if (settings.lowframecolor) - xctx.colors[ColFrame][URG_LOW] = settings.lowframecolor; + if (settings.colors_low.frame) + xctx.colors[ColFrame][URG_LOW] = settings.colors_low.frame; else xctx.colors[ColFrame][URG_LOW] = settings.frame_color; - if (settings.normframecolor) - xctx.colors[ColFrame][URG_NORM] = settings.normframecolor; + if (settings.colors_norm.frame) + xctx.colors[ColFrame][URG_NORM] = settings.colors_norm.frame; else xctx.colors[ColFrame][URG_NORM] = settings.frame_color; - if (settings.critframecolor) - xctx.colors[ColFrame][URG_CRIT] = settings.critframecolor; + if (settings.colors_crit.frame) + xctx.colors[ColFrame][URG_CRIT] = settings.colors_crit.frame; else xctx.colors[ColFrame][URG_CRIT] = settings.frame_color;