forked from external/yambar
module/xwindow: export module info through the new module_info struct type
This commit is contained in:
parent
905f289659
commit
6f9e48698e
4 changed files with 24 additions and 21 deletions
|
@ -19,6 +19,7 @@
|
|||
#include "modules/network/network.h"
|
||||
#include "modules/removables/removables.h"
|
||||
#include "modules/xkb/xkb.h"
|
||||
#include "modules/xwindow/xwindow.h"
|
||||
|
||||
const char *
|
||||
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;
|
||||
}
|
||||
|
||||
static const struct attr_info xwindow[] = {
|
||||
{"content", true, &conf_verify_particle},
|
||||
{"anchors", false, NULL},
|
||||
};
|
||||
|
||||
/* TODO: this will dlopened later */
|
||||
static const struct {
|
||||
const char *name;
|
||||
|
@ -460,6 +456,7 @@ verify_module(keychain_t *chain, const struct yml_node *node)
|
|||
{"network", &module_network},
|
||||
{"removables", &module_removables},
|
||||
{"xkb", &module_xkb},
|
||||
{"xwindow", &module_xwindow},
|
||||
};
|
||||
|
||||
static const struct {
|
||||
|
@ -467,7 +464,6 @@ verify_module(keychain_t *chain, const struct yml_node *node)
|
|||
const struct attr_info *attrs;
|
||||
size_t count;
|
||||
} modules[] = {
|
||||
{"xwindow", xwindow, sizeof(xwindow) / sizeof(xwindow[0])},
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(modules_v2) / sizeof(modules_v2[0]); i++) {
|
||||
|
|
11
config.c
11
config.c
|
@ -362,13 +362,6 @@ conf_to_particle(const struct yml_node *node, const struct font *parent_font)
|
|||
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 *
|
||||
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);
|
||||
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);
|
||||
mods[idx] = module_xwindow.from_conf(m.value, font);
|
||||
else
|
||||
assert(false);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#define LOG_MODULE "xkb"
|
||||
#include "../../log.h"
|
||||
#include "../../bar.h"
|
||||
#include "../../config.h"
|
||||
#include "../../xcb.h"
|
||||
|
||||
struct private {
|
||||
|
@ -301,8 +302,8 @@ destroy(struct module *mod)
|
|||
module_default_destroy(mod);
|
||||
}
|
||||
|
||||
struct module *
|
||||
module_xwindow(struct particle *label)
|
||||
static struct module *
|
||||
xwindow_new(struct particle *label)
|
||||
{
|
||||
struct private *m = calloc(1, sizeof(*m));
|
||||
m->label = label;
|
||||
|
@ -314,3 +315,20 @@ module_xwindow(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 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},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include "../../module.h"
|
||||
#include "../../particle.h"
|
||||
|
||||
struct module *module_xwindow(struct particle *label);
|
||||
extern const struct module_info module_xwindow;
|
||||
|
|
Loading…
Add table
Reference in a new issue