config: pass a struct with inheritable values

For now, font and foreground color
This commit is contained in:
Daniel Eklöf 2019-01-13 14:13:14 +01:00
parent 7776135454
commit 8dc278aaf2
20 changed files with 84 additions and 48 deletions

View file

@ -268,7 +268,7 @@ alsa_new(const char *card, const char *mixer, struct particle *label)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *card = yml_get_value(node, "card");
const struct yml_node *mixer = yml_get_value(node, "mixer");
@ -277,7 +277,7 @@ from_conf(const struct yml_node *node, const struct font *parent_font)
return alsa_new(
yml_value_as_string(card),
yml_value_as_string(mixer),
conf_to_particle(content, parent_font));
conf_to_particle(content, inherited));
}
static bool

View file

@ -215,13 +215,13 @@ backlight_new(const char *device, struct particle *label)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *name = yml_get_value(node, "name");
const struct yml_node *c = yml_get_value(node, "content");
return backlight_new(
yml_value_as_string(name), conf_to_particle(c, parent_font));
yml_value_as_string(name), conf_to_particle(c, inherited));
}
static bool

View file

@ -344,7 +344,7 @@ battery_new(const char *battery, struct particle *label, int poll_interval_secs)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *name = yml_get_value(node, "name");
@ -352,7 +352,7 @@ from_conf(const struct yml_node *node, const struct font *parent_font)
return battery_new(
yml_value_as_string(name),
conf_to_particle(c, parent_font),
conf_to_particle(c, inherited),
poll_interval != NULL ? yml_value_as_int(poll_interval) : 60);
}

View file

@ -95,14 +95,14 @@ clock_new(struct particle *label, const char *date_format, const char *time_form
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *date_format = yml_get_value(node, "date-format");
const struct yml_node *time_format = yml_get_value(node, "time-format");
return clock_new(
conf_to_particle(c, parent_font),
conf_to_particle(c, inherited),
date_format != NULL ? yml_value_as_string(date_format) : "%x",
time_format != NULL ? yml_value_as_string(time_format) : "%H:%M");
}

View file

@ -645,7 +645,7 @@ i3_new(struct i3_workspaces workspaces[], size_t workspace_count,
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *spacing = yml_get_value(node, "spacing");
@ -665,7 +665,7 @@ from_conf(const struct yml_node *node, const struct font *parent_font)
yml_dict_next(&it), idx++)
{
workspaces[idx].name = yml_value_as_string(it.key);
workspaces[idx].content = conf_to_particle(it.value, parent_font);
workspaces[idx].content = conf_to_particle(it.value, inherited);
}
return i3_new(workspaces, yml_dict_length(c), left, right);

View file

@ -4,6 +4,7 @@
#include <poll.h>
#include "../config.h"
#include "../module.h"
struct private {
struct particle *label;
@ -47,10 +48,10 @@ label_new(struct particle *label)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return label_new(conf_to_particle(c, parent_font));
return label_new(conf_to_particle(c, inherited));
}
static bool

View file

@ -479,7 +479,7 @@ mpd_new(const char *host, uint16_t port, struct particle *label)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *host = yml_get_value(node, "host");
const struct yml_node *port = yml_get_value(node, "port");
@ -488,7 +488,7 @@ from_conf(const struct yml_node *node, const struct font *parent_font)
return mpd_new(
yml_value_as_string(host),
port != NULL ? yml_value_as_int(port) : 0,
conf_to_particle(c, parent_font));
conf_to_particle(c, inherited));
}
static bool

View file

@ -534,13 +534,13 @@ network_new(const char *iface, struct particle *label)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *name = yml_get_value(node, "name");
const struct yml_node *content = yml_get_value(node, "content");
return network_new(
yml_value_as_string(name), conf_to_particle(content, parent_font));
yml_value_as_string(name), conf_to_particle(content, inherited));
}
static bool

View file

@ -561,7 +561,7 @@ removables_new(struct particle *label, int left_spacing, int right_spacing)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *content = yml_get_value(node, "content");
const struct yml_node *spacing = yml_get_value(node, "spacing");
@ -573,8 +573,7 @@ from_conf(const struct yml_node *node, const struct font *parent_font)
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);
return removables_new(conf_to_particle(content, inherited), left, right);
}
static bool

View file

@ -453,10 +453,10 @@ xkb_new(struct particle *label)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return xkb_new(conf_to_particle(c, parent_font));
return xkb_new(conf_to_particle(c, inherited));
}
static bool

View file

@ -315,10 +315,10 @@ xwindow_new(struct particle *label)
}
static struct module *
from_conf(const struct yml_node *node, const struct font *parent_font)
from_conf(const struct yml_node *node, struct conf_inherit inherited)
{
const struct yml_node *c = yml_get_value(node, "content");
return xwindow_new(conf_to_particle(c, parent_font));
return xwindow_new(conf_to_particle(c, inherited));
}
static bool