Prefix urgency enum with URG_

This commit is contained in:
Benedikt Heine 2017-11-16 16:20:50 +01:00
parent d91053c85e
commit 5f51147263
7 changed files with 46 additions and 46 deletions

View File

@ -157,7 +157,7 @@ int dunst_main(int argc, char *argv[])
n->progress = -1; n->progress = -1;
n->timeout = 10 * G_USEC_PER_SEC; n->timeout = 10 * G_USEC_PER_SEC;
n->markup = MARKUP_NO; n->markup = MARKUP_NO;
n->urgency = LOW; n->urgency = URG_LOW;
notification_init(n); notification_init(n);
queues_notification_insert(n, 0); queues_notification_insert(n, 0);
// we do not call wakeup now, wake_up does not work here yet // we do not call wakeup now, wake_up does not work here yet

View File

@ -113,13 +113,13 @@ void notification_run_script(notification *n)
const char *notification_urgency_to_string(enum urgency urgency) const char *notification_urgency_to_string(enum urgency urgency)
{ {
switch (urgency) { switch (urgency) {
case NONE: case URG_NONE:
return "NONE"; return "NONE";
case LOW: case URG_LOW:
return "LOW"; return "LOW";
case NORM: case URG_NORM:
return "NORMAL"; return "NORMAL";
case CRIT: case URG_CRIT:
return "CRITICAL"; return "CRITICAL";
default: default:
return "UNDEF"; return "UNDEF";
@ -437,8 +437,8 @@ void notification_init(notification *n)
n->dup_count = 0; n->dup_count = 0;
/* urgency > CRIT -> array out of range */ /* urgency > URG_CRIT -> array out of range */
n->urgency = n->urgency > CRIT ? CRIT : n->urgency; n->urgency = n->urgency > URG_CRIT ? URG_CRIT : n->urgency;
if (!n->color_strings[ColFG]) { if (!n->color_strings[ColFG]) {
n->color_strings[ColFG] = xctx.color_strings[ColFG][n->urgency]; n->color_strings[ColFG] = xctx.color_strings[ColFG][n->urgency];

View File

@ -10,10 +10,10 @@
#define DUNST_NOTIF_MAX_CHARS 5000 #define DUNST_NOTIF_MAX_CHARS 5000
enum urgency { enum urgency {
NONE = -1, URG_NONE = -1,
LOW = 0, URG_LOW = 0,
NORM = 1, URG_NORM = 1,
CRIT = 2, URG_CRIT = 2,
}; };
typedef struct _raw_image { typedef struct _raw_image {

View File

@ -14,7 +14,7 @@ void rule_apply(rule_t *r, notification *n)
{ {
if (r->timeout != -1) if (r->timeout != -1)
n->timeout = r->timeout; n->timeout = r->timeout;
if (r->urgency != NONE) if (r->urgency != URG_NONE)
n->urgency = r->urgency; n->urgency = r->urgency;
if (r->history_ignore != -1) if (r->history_ignore != -1)
n->history_ignore = r->history_ignore; n->history_ignore = r->history_ignore;
@ -62,9 +62,9 @@ void rule_init(rule_t *r)
r->body = NULL; r->body = NULL;
r->icon = NULL; r->icon = NULL;
r->category = NULL; r->category = NULL;
r->msg_urgency = NONE; r->msg_urgency = URG_NONE;
r->timeout = -1; r->timeout = -1;
r->urgency = NONE; r->urgency = URG_NONE;
r->markup = MARKUP_NULL; r->markup = MARKUP_NULL;
r->new_icon = NULL; r->new_icon = NULL;
r->history_ignore = false; r->history_ignore = false;
@ -86,6 +86,6 @@ bool rule_matches_notification(rule_t *r, notification *n)
&& (!r->icon || !fnmatch(r->icon, n->icon, 0)) && (!r->icon || !fnmatch(r->icon, n->icon, 0))
&& (!r->category || !fnmatch(r->category, n->category, 0)) && (!r->category || !fnmatch(r->category, n->category, 0))
&& (r->match_transient == -1 || (r->match_transient == n->transient)) && (r->match_transient == -1 || (r->match_transient == n->transient))
&& (r->msg_urgency == NONE || r->msg_urgency == n->urgency)); && (r->msg_urgency == URG_NONE || r->msg_urgency == n->urgency));
} }
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */ /* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */

View File

@ -54,11 +54,11 @@ static enum urgency ini_get_urgency(const char *section, const char *key, const
if (strlen(urg) > 0) { if (strlen(urg) > 0) {
if (strcmp(urg, "low") == 0) if (strcmp(urg, "low") == 0)
ret = LOW; ret = URG_LOW;
else if (strcmp(urg, "normal") == 0) else if (strcmp(urg, "normal") == 0)
ret = NORM; ret = URG_NORM;
else if (strcmp(urg, "critical") == 0) else if (strcmp(urg, "critical") == 0)
ret = CRIT; ret = URG_CRIT;
else else
fprintf(stderr, fprintf(stderr,
"unknown urgency: %s, ignoring\n", "unknown urgency: %s, ignoring\n",
@ -492,15 +492,15 @@ void load_settings(char *cmdline_config_path)
"Frame color for notifications with low urgency" "Frame color for notifications with low urgency"
); );
settings.timeouts[LOW] = option_get_time( settings.timeouts[URG_LOW] = option_get_time(
"urgency_low", "urgency_low",
"timeout", "-lto", defaults.timeouts[LOW], "timeout", "-lto", defaults.timeouts[URG_LOW],
"Timeout for notifications with low urgency" "Timeout for notifications with low urgency"
); );
settings.icons[LOW] = option_get_string( settings.icons[URG_LOW] = option_get_string(
"urgency_low", "urgency_low",
"icon", "-li", defaults.icons[LOW], "icon", "-li", defaults.icons[URG_LOW],
"Icon for notifications with low urgency" "Icon for notifications with low urgency"
); );
@ -522,15 +522,15 @@ void load_settings(char *cmdline_config_path)
"Frame color for notifications with normal urgency" "Frame color for notifications with normal urgency"
); );
settings.timeouts[NORM] = option_get_time( settings.timeouts[URG_NORM] = option_get_time(
"urgency_normal", "urgency_normal",
"timeout", "-nto", defaults.timeouts[NORM], "timeout", "-nto", defaults.timeouts[URG_NORM],
"Timeout for notifications with normal urgency" "Timeout for notifications with normal urgency"
); );
settings.icons[NORM] = option_get_string( settings.icons[URG_NORM] = option_get_string(
"urgency_normal", "urgency_normal",
"icon", "-ni", defaults.icons[NORM], "icon", "-ni", defaults.icons[URG_NORM],
"Icon for notifications with normal urgency" "Icon for notifications with normal urgency"
); );
@ -552,15 +552,15 @@ void load_settings(char *cmdline_config_path)
"Frame color for notifications with critical urgency" "Frame color for notifications with critical urgency"
); );
settings.timeouts[CRIT] = option_get_time( settings.timeouts[URG_CRIT] = option_get_time(
"urgency_critical", "urgency_critical",
"timeout", "-cto", defaults.timeouts[CRIT], "timeout", "-cto", defaults.timeouts[URG_CRIT],
"Timeout for notifications with critical urgency" "Timeout for notifications with critical urgency"
); );
settings.icons[CRIT] = option_get_string( settings.icons[URG_CRIT] = option_get_string(
"urgency_critical", "urgency_critical",
"icon", "-ci", defaults.icons[CRIT], "icon", "-ci", defaults.icons[URG_CRIT],
"Icon for notifications with critical urgency" "Icon for notifications with critical urgency"
); );

View File

@ -980,26 +980,26 @@ void x_setup(void)
x_shortcut_grab(&settings.context_ks); x_shortcut_grab(&settings.context_ks);
x_shortcut_ungrab(&settings.context_ks); x_shortcut_ungrab(&settings.context_ks);
xctx.color_strings[ColFG][LOW] = settings.lowfgcolor; xctx.color_strings[ColFG][URG_LOW] = settings.lowfgcolor;
xctx.color_strings[ColFG][NORM] = settings.normfgcolor; xctx.color_strings[ColFG][URG_NORM] = settings.normfgcolor;
xctx.color_strings[ColFG][CRIT] = settings.critfgcolor; xctx.color_strings[ColFG][URG_CRIT] = settings.critfgcolor;
xctx.color_strings[ColBG][LOW] = settings.lowbgcolor; xctx.color_strings[ColBG][URG_LOW] = settings.lowbgcolor;
xctx.color_strings[ColBG][NORM] = settings.normbgcolor; xctx.color_strings[ColBG][URG_NORM] = settings.normbgcolor;
xctx.color_strings[ColBG][CRIT] = settings.critbgcolor; xctx.color_strings[ColBG][URG_CRIT] = settings.critbgcolor;
if (settings.lowframecolor) if (settings.lowframecolor)
xctx.color_strings[ColFrame][LOW] = settings.lowframecolor; xctx.color_strings[ColFrame][URG_LOW] = settings.lowframecolor;
else else
xctx.color_strings[ColFrame][LOW] = settings.frame_color; xctx.color_strings[ColFrame][URG_LOW] = settings.frame_color;
if (settings.normframecolor) if (settings.normframecolor)
xctx.color_strings[ColFrame][NORM] = settings.normframecolor; xctx.color_strings[ColFrame][URG_NORM] = settings.normframecolor;
else else
xctx.color_strings[ColFrame][NORM] = settings.frame_color; xctx.color_strings[ColFrame][URG_NORM] = settings.frame_color;
if (settings.critframecolor) if (settings.critframecolor)
xctx.color_strings[ColFrame][CRIT] = settings.critframecolor; xctx.color_strings[ColFrame][URG_CRIT] = settings.critframecolor;
else else
xctx.color_strings[ColFrame][CRIT] = settings.frame_color; xctx.color_strings[ColFrame][URG_CRIT] = settings.frame_color;
/* parse and set xctx.geometry and monitor position */ /* parse and set xctx.geometry and monitor position */
if (settings.geom[0] == '-') { if (settings.geom[0] == '-') {

View File

@ -60,11 +60,11 @@ TEST test_notification_is_duplicate(void *notifications)
ASSERT(notification_is_duplicate(a, b)); ASSERT(notification_is_duplicate(a, b));
b->urgency = LOW; b->urgency = URG_LOW;
ASSERT_FALSE(notification_is_duplicate(a, b)); ASSERT_FALSE(notification_is_duplicate(a, b));
b->urgency = NORM; b->urgency = URG_NORM;
ASSERT(notification_is_duplicate(a, b)); ASSERT(notification_is_duplicate(a, b));
b->urgency = CRIT; b->urgency = URG_CRIT;
ASSERT_FALSE(notification_is_duplicate(a, b)); ASSERT_FALSE(notification_is_duplicate(a, b));
PASS(); PASS();
@ -107,7 +107,7 @@ SUITE(suite_notification)
a->summary = "Summary"; a->summary = "Summary";
a->body = "Body"; a->body = "Body";
a->icon = "Icon"; a->icon = "Icon";
a->urgency = NORM; a->urgency = URG_NORM;
notification *b = notification_create(); notification *b = notification_create();
memcpy(b, a, sizeof(*b)); memcpy(b, a, sizeof(*b));