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

This commit is contained in:
Daniel Eklöf 2019-01-12 13:03:41 +01:00
parent 905f289659
commit 6f9e48698e
4 changed files with 24 additions and 21 deletions

View file

@ -19,6 +19,7 @@
#include "modules/network/network.h" #include "modules/network/network.h"
#include "modules/removables/removables.h" #include "modules/removables/removables.h"
#include "modules/xkb/xkb.h" #include "modules/xkb/xkb.h"
#include "modules/xwindow/xwindow.h"
const char * const char *
conf_err_prefix(const keychain_t *chain, const struct yml_node *node) conf_err_prefix(const keychain_t *chain, const struct yml_node *node)
@ -440,11 +441,6 @@ verify_module(keychain_t *chain, const struct yml_node *node)
return false; return false;
} }
static const struct attr_info xwindow[] = {
{"content", true, &conf_verify_particle},
{"anchors", false, NULL},
};
/* TODO: this will dlopened later */ /* TODO: this will dlopened later */
static const struct { static const struct {
const char *name; const char *name;
@ -460,6 +456,7 @@ verify_module(keychain_t *chain, const struct yml_node *node)
{"network", &module_network}, {"network", &module_network},
{"removables", &module_removables}, {"removables", &module_removables},
{"xkb", &module_xkb}, {"xkb", &module_xkb},
{"xwindow", &module_xwindow},
}; };
static const struct { static const struct {
@ -467,7 +464,6 @@ verify_module(keychain_t *chain, const struct yml_node *node)
const struct attr_info *attrs; const struct attr_info *attrs;
size_t count; size_t count;
} modules[] = { } modules[] = {
{"xwindow", xwindow, sizeof(xwindow) / sizeof(xwindow[0])},
}; };
for (size_t i = 0; i < sizeof(modules_v2) / sizeof(modules_v2[0]); i++) { for (size_t i = 0; i < sizeof(modules_v2) / sizeof(modules_v2[0]); i++) {

View file

@ -362,13 +362,6 @@ conf_to_particle(const struct yml_node *node, const struct font *parent_font)
return ret; return ret;
} }
static struct module *
module_xwindow_from_config(const struct yml_node *node, const struct font *parent_font)
{
const struct yml_node *c = yml_get_value(node, "content");
return module_xwindow(conf_to_particle(c, parent_font));
}
struct bar * struct bar *
conf_to_bar(const struct yml_node *bar) conf_to_bar(const struct yml_node *bar)
{ {
@ -479,10 +472,8 @@ conf_to_bar(const struct yml_node *bar)
mods[idx] = module_removables.from_conf(m.value, font); mods[idx] = module_removables.from_conf(m.value, font);
else if (strcmp(mod_name, "xkb") == 0) else if (strcmp(mod_name, "xkb") == 0)
mods[idx] = module_xkb.from_conf(m.value, font); mods[idx] = module_xkb.from_conf(m.value, font);
else if (strcmp(mod_name, "xwindow") == 0) else if (strcmp(mod_name, "xwindow") == 0)
mods[idx] = module_xwindow_from_config(m.value, font); mods[idx] = module_xwindow.from_conf(m.value, font);
else else
assert(false); assert(false);
} }

View file

@ -17,6 +17,7 @@
#define LOG_MODULE "xkb" #define LOG_MODULE "xkb"
#include "../../log.h" #include "../../log.h"
#include "../../bar.h" #include "../../bar.h"
#include "../../config.h"
#include "../../xcb.h" #include "../../xcb.h"
struct private { struct private {
@ -301,8 +302,8 @@ destroy(struct module *mod)
module_default_destroy(mod); module_default_destroy(mod);
} }
struct module * static struct module *
module_xwindow(struct particle *label) xwindow_new(struct particle *label)
{ {
struct private *m = calloc(1, sizeof(*m)); struct private *m = calloc(1, sizeof(*m));
m->label = label; m->label = label;
@ -314,3 +315,20 @@ module_xwindow(struct particle *label)
mod->content = &content; mod->content = &content;
return mod; 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 xwindow_new(conf_to_particle(c, parent_font));
}
const struct module_info module_xwindow = {
.from_conf = &from_conf,
.attr_count = 2,
.attrs = {
{"content", true, &conf_verify_particle},
{"anchors", false, NULL},
{NULL, false, NULL},
},
};

View file

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