mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-06-16 00:05:40 +02:00
particle/map: expose info through the new struct particle_info struct
This commit is contained in:
parent
6379b1939f
commit
73b8bf1346
4 changed files with 88 additions and 84 deletions
36
config.c
36
config.c
|
@ -161,36 +161,6 @@ particle_string_from_config(const struct yml_node *node,
|
|||
}
|
||||
|
||||
|
||||
static struct particle *
|
||||
particle_map_from_config(const struct yml_node *node,
|
||||
const struct font *parent_font,
|
||||
int left_margin, int right_margin,
|
||||
const char *on_click_template)
|
||||
{
|
||||
const struct yml_node *tag = yml_get_value(node, "tag");
|
||||
const struct yml_node *values = yml_get_value(node, "values");
|
||||
const struct yml_node *def = yml_get_value(node, "default");
|
||||
|
||||
struct particle_map particle_map[yml_dict_length(values)];
|
||||
|
||||
size_t idx = 0;
|
||||
for (struct yml_dict_iter it = yml_dict_iter(values);
|
||||
it.key != NULL;
|
||||
yml_dict_next(&it), idx++)
|
||||
{
|
||||
particle_map[idx].tag_value = yml_value_as_string(it.key);
|
||||
particle_map[idx].particle = conf_to_particle(it.value, parent_font);
|
||||
}
|
||||
|
||||
struct particle *default_particle = def != NULL
|
||||
? conf_to_particle(def, parent_font)
|
||||
: NULL;
|
||||
|
||||
return particle_map_new(
|
||||
yml_value_as_string(tag), particle_map, yml_dict_length(values),
|
||||
default_particle, left_margin, right_margin, on_click_template);
|
||||
}
|
||||
|
||||
static struct particle *
|
||||
particle_ramp_from_config(const struct yml_node *node,
|
||||
const struct font *parent_font,
|
||||
|
@ -288,13 +258,13 @@ conf_to_particle(const struct yml_node *node, const struct font *parent_font)
|
|||
else if (strcmp(type, "list") == 0)
|
||||
ret = particle_list.from_conf(
|
||||
pair.value, parent_font, left, right, on_click_template);
|
||||
else if (strcmp(type, "map") == 0)
|
||||
ret = particle_map.from_conf(
|
||||
pair.value, parent_font, left, right, on_click_template);
|
||||
|
||||
else if (strcmp(type, "string") == 0)
|
||||
ret = particle_string_from_config(
|
||||
pair.value, parent_font, left, right, on_click_template);
|
||||
else if (strcmp(type, "map") == 0)
|
||||
ret = particle_map_from_config(
|
||||
pair.value, parent_font, left, right, on_click_template);
|
||||
else if (strcmp(type, "ramp") == 0)
|
||||
ret = particle_ramp_from_config(
|
||||
pair.value, parent_font, left, right, on_click_template);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue