forked from external/yambar
particle/string: constructor now takes an 'on_click_template'
This commit is contained in:
parent
5164d1d6ea
commit
9e5dbfe27d
3 changed files with 10 additions and 5 deletions
4
config.c
4
config.c
|
@ -193,6 +193,7 @@ particle_string_from_config(const struct yml_node *node,
|
|||
const struct yml_node *margin = yml_get_value(node, "margin");
|
||||
const struct yml_node *left_margin = yml_get_value(node, "left_margin");
|
||||
const struct yml_node *right_margin = yml_get_value(node, "right_margin");
|
||||
const struct yml_node *on_click = yml_get_value(node, "on_click");
|
||||
|
||||
assert(text != NULL && yml_is_scalar(text));
|
||||
|
||||
|
@ -208,7 +209,8 @@ particle_string_from_config(const struct yml_node *node,
|
|||
return particle_string_new(
|
||||
yml_value_as_string(text),
|
||||
font != NULL ? font_from_config(font) : font_clone(parent_font),
|
||||
fg_color, left, right);
|
||||
fg_color, left, right,
|
||||
on_click != NULL ? yml_value_as_string(on_click) : NULL);
|
||||
}
|
||||
|
||||
static struct particle * particle_from_config(
|
||||
|
|
|
@ -164,7 +164,8 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
|||
e->font = p->font;
|
||||
e->foreground = p->foreground;
|
||||
|
||||
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;
|
||||
|
@ -184,14 +185,16 @@ particle_destroy(struct particle *particle)
|
|||
|
||||
struct particle *
|
||||
particle_string_new(const char *text, struct font *font,
|
||||
struct rgba foreground, int left_margin, int right_margin)
|
||||
struct rgba foreground, int left_margin, int right_margin,
|
||||
const char *on_click_template)
|
||||
{
|
||||
struct private *p = malloc(sizeof(*p));
|
||||
p->text = strdup(text);
|
||||
p->font = font;
|
||||
p->foreground = foreground;
|
||||
|
||||
struct particle *particle = particle_common_new(left_margin, right_margin);
|
||||
struct particle *particle = particle_common_new(
|
||||
left_margin, right_margin, on_click_template);
|
||||
|
||||
particle->private = p;
|
||||
particle->destroy = &particle_destroy;
|
||||
|
|
|
@ -3,4 +3,4 @@
|
|||
|
||||
struct particle *particle_string_new(
|
||||
const char *text, struct font *font, struct rgba foreground,
|
||||
int left_margin, int right_margin);
|
||||
int left_margin, int right_margin, const char *on_click_template);
|
||||
|
|
Loading…
Add table
Reference in a new issue