aboutsummaryrefslogtreecommitdiff
path: root/src/config.c
diff options
context:
space:
mode:
authorFederico Angelilli <code@fedang.net>2024-09-11 22:20:04 +0200
committerFederico Angelilli <code@fedang.net>2024-09-11 22:20:04 +0200
commitb94e342ea59c9d13ef1e380834534c1c1c8a83ec (patch)
tree17e7fcb888710927c78fd14003a103dc7e52ae27 /src/config.c
parentee3ea3be13744f766af57e4ae4504b5942655184 (diff)
Add collapse option to groups
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/config.c b/src/config.c
index 99888da..84804bc 100644
--- a/src/config.c
+++ b/src/config.c
@@ -44,8 +44,9 @@ static const config_entry_t block_entries[] = {
};
static const config_entry_t block_group_entries[] = {
- { "spacing", CONFIG_UINT, NULL, offsetof(block_t, group.spacing) },
- { "blocks", CONFIG_LIST, NULL, offsetof(block_t, group.children) },
+ { "spacing", CONFIG_UINT, NULL, offsetof(block_t, group.spacing) },
+ { "blocks", CONFIG_LIST, NULL, offsetof(block_t, group.children) },
+ { "collapse", CONFIG_BOOL, NULL, offsetof(block_t, group.collapse) },
{ 0 },
};
@@ -363,7 +364,7 @@ void config_init(config_t *config)
config->font = strcopy(config_default.font);
config->n_blocks = 1;
- config->blocks = malloc(sizeof(block_t));
+ config->blocks = calloc(1, sizeof(block_t));
config->blocks->label = strcopy("bar");
config->blocks->type = BLOCK_GROUP;
config->blocks->group.spacing = 10;
@@ -560,7 +561,7 @@ static bool config_resolve_children(config_t *config, block_t *block)
return false;
}
- log_debug("Block '%s' is parent to '%s'", block->label, config->blocks[j].label);
+ log_debug("Block '%s' is parent of '%s'", block->label, config->blocks[j].label);
block->group.children[i] = &config->blocks[j];
if (!config_resolve_children(config, &config->blocks[j]))
@@ -584,6 +585,7 @@ block_t *config_resolve(config_t *config)
errors++;
log_error("Section '%s' requires at least one child", "bar");
} else {
+ // NOTE: The first item is the main block
config->blocks->min_width = config->blocks->max_width = config->width;
errors += !config_resolve_children(config, config->blocks);
}