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

This commit is contained in:
Daniel Eklöf 2019-01-12 13:01:24 +01:00
parent 87640339e1
commit 905f289659
4 changed files with 25 additions and 20 deletions

View file

@ -18,6 +18,7 @@
#include "modules/mpd/mpd.h"
#include "modules/network/network.h"
#include "modules/removables/removables.h"
#include "modules/xkb/xkb.h"
const char *
conf_err_prefix(const keychain_t *chain, const struct yml_node *node)
@ -439,11 +440,6 @@ verify_module(keychain_t *chain, const struct yml_node *node)
return false;
}
static const struct attr_info xkb[] = {
{"content", true, &conf_verify_particle},
{"anchors", false, NULL},
};
static const struct attr_info xwindow[] = {
{"content", true, &conf_verify_particle},
{"anchors", false, NULL},
@ -463,6 +459,7 @@ verify_module(keychain_t *chain, const struct yml_node *node)
{"mpd", &module_mpd},
{"network", &module_network},
{"removables", &module_removables},
{"xkb", &module_xkb},
};
static const struct {
@ -470,7 +467,6 @@ verify_module(keychain_t *chain, const struct yml_node *node)
const struct attr_info *attrs;
size_t count;
} modules[] = {
{"xkb", xkb, sizeof(xkb) / sizeof(xkb[0])},
{"xwindow", xwindow, sizeof(xwindow) / sizeof(xwindow[0])},
};

View file

@ -369,14 +369,6 @@ module_xwindow_from_config(const struct yml_node *node, const struct font *paren
return module_xwindow(conf_to_particle(c, parent_font));
}
static struct module *
module_xkb_from_config(const struct yml_node *node,
const struct font *parent_font)
{
const struct yml_node *c = yml_get_value(node, "content");
return module_xkb(conf_to_particle(c, parent_font));
}
struct bar *
conf_to_bar(const struct yml_node *bar)
{
@ -485,12 +477,12 @@ conf_to_bar(const struct yml_node *bar)
mods[idx] = module_network.from_conf(m.value, font);
else if (strcmp(mod_name, "removables") == 0)
mods[idx] = module_removables.from_conf(m.value, font);
else if (strcmp(mod_name, "xkb") == 0)
mods[idx] = module_xkb.from_conf(m.value, font);
else if (strcmp(mod_name, "xwindow") == 0)
mods[idx] = module_xwindow_from_config(m.value, font);
else if (strcmp(mod_name, "xkb") == 0)
mods[idx] = module_xkb_from_config(m.value, font);
else
assert(false);
}

View file

@ -13,6 +13,7 @@
#define LOG_MODULE "xkb"
#include "../../log.h"
#include "../../bar.h"
#include "../../config.h"
#include "../../xcb.h"
struct layout {
@ -436,8 +437,8 @@ run(struct module_run_context *ctx)
return ret;
}
struct module *
module_xkb(struct particle *label)
static struct module *
xkb_new(struct particle *label)
{
struct private *m = malloc(sizeof(*m));
m->label = label;
@ -452,3 +453,20 @@ module_xkb(struct particle *label)
mod->content = &content;
return mod;
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
{
const struct yml_node *c = yml_get_value(node, "content");
return xkb_new(conf_to_particle(c, parent_font));
}
const struct module_info module_xkb = {
.from_conf = &from_conf,
.attr_count = 2,
.attrs = {
{"content", true, &conf_verify_particle},
{"anchors", false, NULL},
{NULL, false, NULL},
},
};

View file

@ -1,5 +1,4 @@
#pragma once
#include "../../module.h"
#include "../../particle.h"
struct module *module_xkb(struct particle *label);
extern const struct module_info module_xkb;