config: i3: handle the 'spacing' attribute

This commit is contained in:
Daniel Eklöf 2018-12-30 20:39:45 +01:00
parent 500aebe9ef
commit c795718ad7

View file

@ -416,13 +416,20 @@ static struct module *
module_i3_from_config(const struct yml_node *node, const struct font *parent_font)
{
const struct yml_node *c = yml_get_value(node, "content");
const struct yml_node *spacing = yml_get_value(node, "spacing");
const struct yml_node *left_spacing = yml_get_value(node, "left_spacing");
const struct yml_node *right_spacing = yml_get_value(node, "right_spacing");
assert(yml_is_dict(c));
assert(spacing == NULL || yml_is_scalar(spacing));
assert(left_spacing == NULL || yml_is_scalar(left_spacing));
assert(right_spacing == NULL || yml_is_scalar(right_spacing));
int left = spacing != NULL ? yml_value_as_int(spacing) :
left_spacing != NULL ? yml_value_as_int(left_spacing) : 0;
int right = spacing != NULL ? yml_value_as_int(spacing) :
right_spacing != NULL ? yml_value_as_int(right_spacing) : 0;
struct i3_workspaces workspaces[yml_dict_length(c)];
size_t idx = 0;
@ -430,14 +437,12 @@ module_i3_from_config(const struct yml_node *node, const struct font *parent_fon
it.key != NULL;
yml_dict_next(&it), idx++)
{
assert(yml_is_scalar(it.key));
workspaces[idx].name = yml_value_as_string(it.key);
workspaces[idx].content = particle_from_config(it.value, parent_font);
}
return module_i3(
workspaces, yml_dict_length(c),
left_spacing != NULL ? yml_value_as_int(left_spacing) : 0,
right_spacing != NULL ? yml_value_as_int(right_spacing) : 0);
return module_i3(workspaces, yml_dict_length(c), left, right);
}
static struct module *