forked from external/yambar
particle/list: on_click handler
This commit is contained in:
parent
68606e49ed
commit
88bcf425bf
3 changed files with 12 additions and 5 deletions
5
config.c
5
config.c
|
@ -230,6 +230,8 @@ particle_list_from_config(const struct yml_node *node,
|
||||||
const struct yml_node *_left_spacing = yml_get_value(node, "left_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");
|
const struct yml_node *_right_spacing = yml_get_value(node, "right_spacing");
|
||||||
|
|
||||||
|
const struct yml_node *on_click = yml_get_value(node, "on_click");
|
||||||
|
|
||||||
int left_margin = margin != NULL ? yml_value_as_int(margin) :
|
int left_margin = margin != NULL ? yml_value_as_int(margin) :
|
||||||
_left_margin != NULL ? yml_value_as_int(_left_margin) : 0;
|
_left_margin != NULL ? yml_value_as_int(_left_margin) : 0;
|
||||||
int right_margin = margin != NULL ? yml_value_as_int(margin) :
|
int right_margin = margin != NULL ? yml_value_as_int(margin) :
|
||||||
|
@ -251,7 +253,8 @@ particle_list_from_config(const struct yml_node *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
return particle_list_new(
|
return particle_list_new(
|
||||||
parts, count, left_spacing, right_spacing, left_margin, right_margin);
|
parts, count, left_spacing, right_spacing, left_margin, right_margin,
|
||||||
|
on_click != NULL ? yml_value_as_string(on_click) : NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct particle *
|
static struct particle *
|
||||||
|
|
|
@ -118,7 +118,8 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
||||||
e->exposables[i] = pp->instantiate(pp, tags);
|
e->exposables[i] = pp->instantiate(pp, tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct exposable *exposable = exposable_common_new(particle, NULL);
|
struct exposable *exposable = exposable_common_new(
|
||||||
|
particle, particle->on_click_template);
|
||||||
exposable->private = e;
|
exposable->private = e;
|
||||||
exposable->destroy = &exposable_destroy;
|
exposable->destroy = &exposable_destroy;
|
||||||
exposable->begin_expose = &begin_expose;
|
exposable->begin_expose = &begin_expose;
|
||||||
|
@ -141,7 +142,8 @@ particle_destroy(struct particle *particle)
|
||||||
struct particle *
|
struct particle *
|
||||||
particle_list_new(
|
particle_list_new(
|
||||||
struct particle *particles[], size_t count,
|
struct particle *particles[], size_t count,
|
||||||
int left_spacing, int right_spacing, int left_margin, int right_margin)
|
int left_spacing, int right_spacing, int left_margin, int right_margin,
|
||||||
|
const char *on_click_template)
|
||||||
{
|
{
|
||||||
struct particle_private *p = malloc(sizeof(*p));
|
struct particle_private *p = malloc(sizeof(*p));
|
||||||
p->particles = malloc(count * sizeof(p->particles[0]));
|
p->particles = malloc(count * sizeof(p->particles[0]));
|
||||||
|
@ -152,7 +154,8 @@ particle_list_new(
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
p->particles[i] = particles[i];
|
p->particles[i] = particles[i];
|
||||||
|
|
||||||
struct particle *particle = particle_common_new(left_margin, right_margin, NULL);
|
struct particle *particle = particle_common_new(
|
||||||
|
left_margin, right_margin, on_click_template);
|
||||||
|
|
||||||
particle->private = p;
|
particle->private = p;
|
||||||
particle->destroy = &particle_destroy;
|
particle->destroy = &particle_destroy;
|
||||||
|
|
|
@ -3,4 +3,5 @@
|
||||||
|
|
||||||
struct particle *particle_list_new(
|
struct particle *particle_list_new(
|
||||||
struct particle *particles[], size_t count,
|
struct particle *particles[], size_t count,
|
||||||
int left_spacing, int right_spacing, int left_margin, int right_margin);
|
int left_spacing, int right_spacing, int left_margin, int right_margin,
|
||||||
|
const char *on_click_template);
|
||||||
|
|
Loading…
Add table
Reference in a new issue