Pack type rule_t into struct rule
This commit is contained in:
parent
de0f0bf3d9
commit
1fa1532d7f
2
config.h
2
config.h
@ -110,7 +110,7 @@ struct settings defaults = {
|
||||
|
||||
};
|
||||
|
||||
rule_t default_rules[] = {
|
||||
struct rule default_rules[] = {
|
||||
/* name can be any unique string. It is used to identify
|
||||
* the rule in dunstrc to override it there
|
||||
*/
|
||||
|
@ -10,7 +10,7 @@
|
||||
/*
|
||||
* Apply rule to notification.
|
||||
*/
|
||||
void rule_apply(rule_t *r, notification *n)
|
||||
void rule_apply(struct rule *r, notification *n)
|
||||
{
|
||||
if (r->timeout != -1)
|
||||
n->timeout = r->timeout;
|
||||
@ -53,7 +53,7 @@ void rule_apply(rule_t *r, notification *n)
|
||||
void rule_apply_all(notification *n)
|
||||
{
|
||||
for (GSList *iter = rules; iter; iter = iter->next) {
|
||||
rule_t *r = iter->data;
|
||||
struct rule *r = iter->data;
|
||||
if (rule_matches_notification(r, n)) {
|
||||
rule_apply(r, n);
|
||||
}
|
||||
@ -63,7 +63,7 @@ void rule_apply_all(notification *n)
|
||||
/*
|
||||
* Initialize rule with default values.
|
||||
*/
|
||||
void rule_init(rule_t *r)
|
||||
void rule_init(struct rule *r)
|
||||
{
|
||||
r->name = NULL;
|
||||
r->appname = NULL;
|
||||
@ -89,7 +89,7 @@ void rule_init(rule_t *r)
|
||||
/*
|
||||
* Check whether rule should be applied to n.
|
||||
*/
|
||||
bool rule_matches_notification(rule_t *r, notification *n)
|
||||
bool rule_matches_notification(struct rule *r, notification *n)
|
||||
{
|
||||
return ( (!r->appname || (n->appname && !fnmatch(r->appname, n->appname, 0)))
|
||||
&& (!r->summary || (n->summary && !fnmatch(r->summary, n->summary, 0)))
|
||||
|
10
src/rules.h
10
src/rules.h
@ -8,7 +8,7 @@
|
||||
#include "notification.h"
|
||||
#include "settings.h"
|
||||
|
||||
typedef struct _rule_t {
|
||||
struct rule {
|
||||
char *name;
|
||||
/* filters */
|
||||
char *appname;
|
||||
@ -32,14 +32,14 @@ typedef struct _rule_t {
|
||||
const char *format;
|
||||
const char *script;
|
||||
enum behavior_fullscreen fullscreen;
|
||||
} rule_t;
|
||||
};
|
||||
|
||||
extern GSList *rules;
|
||||
|
||||
void rule_init(rule_t *r);
|
||||
void rule_apply(rule_t *r, notification *n);
|
||||
void rule_init(struct rule *r);
|
||||
void rule_apply(struct rule *r, notification *n);
|
||||
void rule_apply_all(notification *n);
|
||||
bool rule_matches_notification(rule_t *r, notification *n);
|
||||
bool rule_matches_notification(struct rule *r, notification *n);
|
||||
|
||||
#endif
|
||||
/* vim: set tabstop=8 shiftwidth=8 expandtab textwidth=0: */
|
||||
|
@ -727,16 +727,16 @@ void load_settings(char *cmdline_config_path)
|
||||
continue;
|
||||
|
||||
/* check for existing rule with same name */
|
||||
rule_t *r = NULL;
|
||||
struct rule *r = NULL;
|
||||
for (GSList *iter = rules; iter; iter = iter->next) {
|
||||
rule_t *match = iter->data;
|
||||
struct rule *match = iter->data;
|
||||
if (match->name &&
|
||||
strcmp(match->name, cur_section) == 0)
|
||||
r = match;
|
||||
}
|
||||
|
||||
if (!r) {
|
||||
r = g_malloc(sizeof(rule_t));
|
||||
r = g_malloc(sizeof(struct rule));
|
||||
rule_init(r);
|
||||
rules = g_slist_insert(rules, r, -1);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user