forked from external/yambar
particle: add an 'on_click_template' to base constructor.
This is intended to be a format-like string, with the possibility to use tag formatters. The expanded string will later be passed to the system() call.
This commit is contained in:
parent
6019129acc
commit
5164d1d6ea
7 changed files with 14 additions and 7 deletions
|
@ -8,15 +8,18 @@ particle_default_destroy(struct particle *particle)
|
|||
{
|
||||
if (particle->deco != NULL)
|
||||
particle->deco->destroy(particle->deco);
|
||||
free(particle->on_click_template);
|
||||
free(particle);
|
||||
}
|
||||
|
||||
struct particle *
|
||||
particle_common_new(int left_margin, int right_margin)
|
||||
particle_common_new(int left_margin, int right_margin,
|
||||
const char *on_click_template)
|
||||
{
|
||||
struct particle *p = malloc(sizeof(*p));
|
||||
p->left_margin = left_margin;
|
||||
p->right_margin = right_margin;
|
||||
p->on_click_template = on_click_template != NULL ? strdup(on_click_template) : NULL;
|
||||
p->deco = NULL;
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "font.h"
|
||||
#include "tag.h"
|
||||
|
||||
struct bar;
|
||||
struct exposable;
|
||||
|
||||
struct particle {
|
||||
|
@ -14,6 +15,7 @@ struct particle {
|
|||
|
||||
int left_margin, right_margin;
|
||||
struct deco *deco;
|
||||
char *on_click_template;
|
||||
|
||||
void (*destroy)(struct particle *particle);
|
||||
struct exposable *(*instantiate)(const struct particle *particle,
|
||||
|
@ -30,6 +32,7 @@ struct exposable {
|
|||
void *private;
|
||||
|
||||
int width; /* Should be set by begin_expose(), at latest */
|
||||
char *on_click;
|
||||
|
||||
void (*destroy)(struct exposable *exposable);
|
||||
int (*begin_expose)(struct exposable *exposable, cairo_t *cr);
|
||||
|
@ -40,7 +43,8 @@ struct exposable {
|
|||
enum mouse_event event, int x, int y);
|
||||
};
|
||||
|
||||
struct particle *particle_common_new(int left_margin, int right_margin);
|
||||
struct particle *particle_common_new(int left_margin, int right_margin,
|
||||
const char *on_click_template);
|
||||
void particle_default_destroy(struct particle *particle);
|
||||
|
||||
struct exposable *exposable_common_new(
|
||||
|
|
|
@ -30,7 +30,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
|||
struct particle *
|
||||
particle_empty_new(int left_margin, int right_margin)
|
||||
{
|
||||
struct particle *particle = particle_common_new(left_margin, right_margin);
|
||||
struct particle *particle = particle_common_new(left_margin, right_margin, NULL);
|
||||
particle->destroy = &particle_default_destroy;
|
||||
particle->instantiate = &instantiate;
|
||||
return particle;
|
||||
|
|
|
@ -123,7 +123,7 @@ 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);
|
||||
struct particle *particle = particle_common_new(left_margin, right_margin, NULL);
|
||||
|
||||
particle->private = p;
|
||||
particle->destroy = &particle_destroy;
|
||||
|
|
|
@ -60,7 +60,7 @@ struct particle *
|
|||
particle_map_new(const char *tag, const struct particle_map *particle_map,
|
||||
size_t count, struct particle *default_particle)
|
||||
{
|
||||
struct particle *particle = particle_common_new(0, 0);
|
||||
struct particle *particle = particle_common_new(0, 0, NULL);
|
||||
particle->destroy = &particle_destroy;
|
||||
particle->instantiate = &instantiate;
|
||||
|
||||
|
|
|
@ -175,7 +175,7 @@ particle_progress_bar_new(const char *tag, int width,
|
|||
priv->empty = empty;
|
||||
priv->indicator = indicator;
|
||||
|
||||
struct particle *particle = particle_common_new(left_margin, right_margin);
|
||||
struct particle *particle = particle_common_new(left_margin, right_margin, NULL);
|
||||
particle->private = priv;
|
||||
particle->destroy = &particle_destroy;
|
||||
particle->instantiate = &instantiate;
|
||||
|
|
|
@ -61,7 +61,7 @@ instantiate(const struct particle *particle, const struct tag_set *tags)
|
|||
struct particle *
|
||||
particle_ramp_new(const char *tag, struct particle *particles[], size_t count)
|
||||
{
|
||||
struct particle *particle = particle_common_new(0, 0);
|
||||
struct particle *particle = particle_common_new(0, 0, NULL);
|
||||
particle->destroy = &particle_destroy;
|
||||
particle->instantiate = &instantiate;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue