decorations: are now plugins

This commit is contained in:
Daniel Eklöf 2019-01-13 17:43:25 +01:00
parent 4eee71eaf4
commit 7754ef3661
11 changed files with 160 additions and 124 deletions

View file

@ -2,6 +2,9 @@
#include <stdlib.h>
#include "../config.h"
#include "../config-verify.h"
struct private {
int size;
struct rgba color;
@ -25,8 +28,8 @@ expose(const struct deco *deco, cairo_t *cr, int x, int y, int width, int height
cairo_fill(cr);
}
struct deco *
deco_underline(int size, struct rgba color)
static struct deco *
underline_new(int size, struct rgba color)
{
struct private *priv = malloc(sizeof(*priv));
priv->size = size;
@ -39,3 +42,23 @@ deco_underline(int size, struct rgba color)
return deco;
}
struct deco *
from_conf(const struct yml_node *node)
{
const struct yml_node *size = yml_get_value(node, "size");
const struct yml_node *color = yml_get_value(node, "color");
return underline_new(yml_value_as_int(size), conf_to_color(color));
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
{"size", true, &conf_verify_int},
{"color", true, &conf_verify_color},
DECORATION_COMMON_ATTRS,
};
return conf_verify_dict(chain, node, attrs);
}