module/removables: export module info through the new module_info struct type

This commit is contained in:
Daniel Eklöf 2019-01-12 12:59:21 +01:00
parent 697e613b2e
commit 87640339e1
4 changed files with 39 additions and 36 deletions

View file

@ -18,8 +18,9 @@
#define LOG_ENABLE_DBG 0
#include "../../log.h"
#include "../../bar.h"
#include "../../tllist.h"
#include "../../config.h"
#include "../../particles/dynlist.h"
#include "../../tllist.h"
typedef tll(char *) mount_point_list_t;
@ -544,8 +545,8 @@ run(struct module_run_context *ctx)
return 0;
}
struct module *
module_removables(struct particle *label, int left_spacing, int right_spacing)
static struct module *
removables_new(struct particle *label, int left_spacing, int right_spacing)
{
struct private *priv = malloc(sizeof(*priv));
priv->label = label;
@ -560,3 +561,33 @@ module_removables(struct particle *label, int left_spacing, int right_spacing)
mod->content = &content;
return mod;
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
{
const struct yml_node *content = yml_get_value(node, "content");
const struct yml_node *spacing = yml_get_value(node, "spacing");
const struct yml_node *left_spacing = yml_get_value(node, "left_spacing");
const struct yml_node *right_spacing = yml_get_value(node, "right_spacing");
int left = spacing != NULL ? yml_value_as_int(spacing) :
left_spacing != NULL ? yml_value_as_int(left_spacing) : 0;
int right = spacing != NULL ? yml_value_as_int(spacing) :
right_spacing != NULL ? yml_value_as_int(right_spacing) : 0;
return removables_new(
conf_to_particle(content, parent_font), left, right);
}
const struct module_info module_removables = {
.from_conf = &from_conf,
.attr_count = 5,
.attrs = {
{"spacing", false, &conf_verify_int},
{"left-spacing", false, &conf_verify_int},
{"right-spacing", false, &conf_verify_int},
{"content", true, &conf_verify_particle},
{"anchors", false, NULL},
{NULL, false, NULL},
},
};