From 88bcf425bfd3dafba8734cc373187eaa85aa2e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 29 Dec 2018 16:15:37 +0100 Subject: [PATCH] particle/list: on_click handler --- config.c | 5 ++++- particles/list.c | 9 ++++++--- particles/list.h | 3 ++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/config.c b/config.c index 9cc5d10..7ebe106 100644 --- a/config.c +++ b/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 *_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) : _left_margin != NULL ? yml_value_as_int(_left_margin) : 0; 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( - 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 * diff --git a/particles/list.c b/particles/list.c index b35e7a6..bbb4d4f 100644 --- a/particles/list.c +++ b/particles/list.c @@ -118,7 +118,8 @@ instantiate(const struct particle *particle, const struct tag_set *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->destroy = &exposable_destroy; exposable->begin_expose = &begin_expose; @@ -141,7 +142,8 @@ particle_destroy(struct particle *particle) struct particle * particle_list_new( 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)); p->particles = malloc(count * sizeof(p->particles[0])); @@ -152,7 +154,8 @@ particle_list_new( for (size_t i = 0; i < count; 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->destroy = &particle_destroy; diff --git a/particles/list.h b/particles/list.h index 5139ba3..f6d1d42 100644 --- a/particles/list.h +++ b/particles/list.h @@ -3,4 +3,5 @@ struct particle *particle_list_new( 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);