Introduce rule_new
This commit is contained in:
parent
53ad430b48
commit
3828cca699
22
src/rules.c
22
src/rules.c
@ -63,32 +63,20 @@ void rule_apply_all(struct notification *n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
struct rule *rule_new(void)
|
||||||
* Initialize rule with default values.
|
|
||||||
*/
|
|
||||||
void rule_init(struct rule *r)
|
|
||||||
{
|
{
|
||||||
r->name = NULL;
|
struct rule *r = g_malloc0(sizeof(struct rule));
|
||||||
r->appname = NULL;
|
|
||||||
r->summary = NULL;
|
|
||||||
r->body = NULL;
|
|
||||||
r->icon = NULL;
|
|
||||||
r->category = NULL;
|
|
||||||
r->stack_tag = NULL;
|
|
||||||
r->msg_urgency = URG_NONE;
|
r->msg_urgency = URG_NONE;
|
||||||
r->timeout = -1;
|
r->timeout = -1;
|
||||||
r->urgency = URG_NONE;
|
r->urgency = URG_NONE;
|
||||||
r->fullscreen = FS_NULL;
|
r->fullscreen = FS_NULL;
|
||||||
r->markup = MARKUP_NULL;
|
r->markup = MARKUP_NULL;
|
||||||
r->new_icon = NULL;
|
|
||||||
r->history_ignore = false;
|
r->history_ignore = false;
|
||||||
r->match_transient = -1;
|
r->match_transient = -1;
|
||||||
r->set_transient = -1;
|
r->set_transient = -1;
|
||||||
r->fg = NULL;
|
|
||||||
r->bg = NULL;
|
return r;
|
||||||
r->fc = NULL;
|
|
||||||
r->format = NULL;
|
|
||||||
r->set_stack_tag = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool rule_field_matches_string(const char *value, const char *pattern)
|
static inline bool rule_field_matches_string(const char *value, const char *pattern)
|
||||||
|
@ -38,7 +38,13 @@ struct rule {
|
|||||||
|
|
||||||
extern GSList *rules;
|
extern GSList *rules;
|
||||||
|
|
||||||
void rule_init(struct rule *r);
|
/**
|
||||||
|
* Allocate a new rule. The rule is fully initialised.
|
||||||
|
*
|
||||||
|
* @returns A new initialised rule.
|
||||||
|
*/
|
||||||
|
struct rule *rule_new(void);
|
||||||
|
|
||||||
void rule_apply(struct rule *r, struct notification *n);
|
void rule_apply(struct rule *r, struct notification *n);
|
||||||
void rule_apply_all(struct notification *n);
|
void rule_apply_all(struct notification *n);
|
||||||
bool rule_matches_notification(struct rule *r, struct notification *n);
|
bool rule_matches_notification(struct rule *r, struct notification *n);
|
||||||
|
@ -688,8 +688,7 @@ void load_settings(char *cmdline_config_path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!r) {
|
if (!r) {
|
||||||
r = g_malloc(sizeof(struct rule));
|
r = rule_new();
|
||||||
rule_init(r);
|
|
||||||
rules = g_slist_insert(rules, r, -1);
|
rules = g_slist_insert(rules, r, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user