From b94e342ea59c9d13ef1e380834534c1c1c8a83ec Mon Sep 17 00:00:00 2001 From: Federico Angelilli Date: Wed, 11 Sep 2024 22:20:04 +0200 Subject: Add collapse option to groups --- src/config.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/config.c') 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); } -- cgit v1.2.3