mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-04-19 19:25:41 +02:00
module/label: export module info through the new module_info struct type
This commit is contained in:
parent
f3721d9d80
commit
fb9f07dcad
4 changed files with 26 additions and 20 deletions
|
@ -13,6 +13,7 @@
|
|||
#include "modules/battery/battery.h"
|
||||
#include "modules/clock/clock.h"
|
||||
#include "modules/i3/i3.h"
|
||||
#include "modules/label/label.h"
|
||||
|
||||
const char *
|
||||
conf_err_prefix(const keychain_t *chain, const struct yml_node *node)
|
||||
|
@ -434,11 +435,6 @@ verify_module(keychain_t *chain, const struct yml_node *node)
|
|||
return false;
|
||||
}
|
||||
|
||||
static const struct attr_info label[] = {
|
||||
{"content", true, &conf_verify_particle},
|
||||
{"anchors", false, NULL},
|
||||
};
|
||||
|
||||
static const struct attr_info mpd[] = {
|
||||
{"host", true, &conf_verify_string},
|
||||
{"port", false, &conf_verify_int},
|
||||
|
@ -480,6 +476,7 @@ verify_module(keychain_t *chain, const struct yml_node *node)
|
|||
{"battery", &module_battery},
|
||||
{"clock", &module_clock},
|
||||
{"i3", &module_i3},
|
||||
{"label", &module_label},
|
||||
};
|
||||
|
||||
static const struct {
|
||||
|
@ -487,7 +484,6 @@ verify_module(keychain_t *chain, const struct yml_node *node)
|
|||
const struct attr_info *attrs;
|
||||
size_t count;
|
||||
} modules[] = {
|
||||
{"label", label, sizeof(label) / sizeof(label[0])},
|
||||
{"mpd", mpd, sizeof(mpd) / sizeof(mpd[0])},
|
||||
{"network", network, sizeof(network) / sizeof(network[0])},
|
||||
{"removables", removables, sizeof(removables) / sizeof(removables[0])},
|
||||
|
|
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_label_from_config(const struct yml_node *node, const struct font *parent_font)
|
||||
{
|
||||
const struct yml_node *c = yml_get_value(node, "content");
|
||||
return module_label(conf_to_particle(c, parent_font));
|
||||
}
|
||||
|
||||
static struct module *
|
||||
module_xwindow_from_config(const struct yml_node *node, const struct font *parent_font)
|
||||
{
|
||||
|
@ -527,9 +520,9 @@ conf_to_bar(const struct yml_node *bar)
|
|||
mods[idx] = module_clock.from_conf(m.value, font);
|
||||
else if (strcmp(mod_name, "i3") == 0)
|
||||
mods[idx] = module_i3.from_conf(m.value, font);
|
||||
|
||||
else if (strcmp(mod_name, "label") == 0)
|
||||
mods[idx] = module_label_from_config(m.value, font);
|
||||
mods[idx] = module_label.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)
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
|
||||
#include <poll.h>
|
||||
|
||||
#include "../../config.h"
|
||||
|
||||
struct private {
|
||||
struct particle *label;
|
||||
};
|
||||
|
@ -32,8 +34,8 @@ run(struct module_run_context *ctx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
struct module *
|
||||
module_label(struct particle *label)
|
||||
static struct module *
|
||||
label_new(struct particle *label)
|
||||
{
|
||||
struct private *m = malloc(sizeof(*m));
|
||||
m->label = label;
|
||||
|
@ -45,3 +47,20 @@ module_label(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 label_new(conf_to_particle(c, parent_font));
|
||||
}
|
||||
|
||||
const struct module_info module_label = {
|
||||
.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_label(struct particle *label);
|
||||
extern const struct module_info module_label;
|
||||
|
|
Loading…
Add table
Reference in a new issue