diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2023-05-26 18:05:13 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2023-05-26 18:09:39 -0700 |
commit | eee1721010b37cccde8635796cb2a2553d19889f (patch) | |
tree | 8e719f93076288b706000cd4e5b7b32061d3a708 | |
parent | 8442b375a46cbf01812d534ecd6337112eb3e9f2 (diff) |
modules/compose: desc the layer and texture module name settings
Like modules/checkers required for fill_module, we need to do the
same for for compose.
It's a little more weird in compose since compose::layers is a
nested settings full of unnamed nested settings.
But compose::texture is analogous to checkers::fill_module.
-rw-r--r-- | src/modules/compose/compose.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index 60431f6..3e9ab2c 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -284,6 +284,7 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set const til_settings_t *layers_settings, *texture_settings; const char *layers; const char *texture; + til_setting_t *texture_module_setting; const char *texture_values[] = { "none", "blinds", @@ -362,12 +363,27 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set * baked setups yet. */ for (size_t i = 0; til_settings_get_value_by_idx(layers_settings, i, &layer_setting); i++) { - const char *layer = til_settings_get_value_by_idx(layer_setting->value_as_nested_settings, 0, NULL); + til_setting_t *layer_module_setting; + const char *layer = til_settings_get_value_by_idx(layer_setting->value_as_nested_settings, 0, &layer_module_setting); const til_module_t *layer_module = til_lookup_module(layer); - if (!layer_module) + if (!layer_module || !layer_module_setting) return -EINVAL; + if (!layer_module_setting->desc) { + r = til_setting_desc_new( layer_setting->value_as_nested_settings, + &(til_setting_spec_t){ + .name = "Layer module name", + .preferred = "none", + }, res_desc); + if (r < 0) + return r; + + *res_setting = layer_module_setting; + + return 1; + } + if (layer_module->setup) { r = layer_module->setup(layer_setting->value_as_nested_settings, res_setting, res_desc, NULL); if (r) @@ -395,8 +411,27 @@ static int compose_setup(const til_settings_t *settings, til_setting_t **res_set assert(res_setting && *res_setting && (*res_setting)->value_as_nested_settings); texture_settings = (*res_setting)->value_as_nested_settings; + texture = til_settings_get_value_by_idx(texture_settings, 0, &texture_module_setting); + if (!texture) + return -EINVAL; + + if (!texture_module_setting->desc) { + r = til_setting_desc_new(texture_settings, + &(til_setting_spec_t){ + /* this is basically just to get the .as_label */ + .name = "Texture module name", + .preferred = "none", + }, + res_desc); + if (r < 0) + return r; + + *res_setting = texture_module_setting; + + return 1; + } + if (strcasecmp(texture, "none")) { - const char *texture = til_settings_get_value_by_idx(texture_settings, 0, NULL); const til_module_t *texture_module = til_lookup_module(texture); if (!texture_module) |