yambar/particles/empty.c
Daniel Eklöf 07b1615a41 particles: get rid of struct particle_info
Since this struct only contained function pointers, make all particles
export those functions directly.

The plugin manager now defines a particle interface struct, and fills
it it by dlsym:ing the functions that used to be in particle_info.
2019-01-13 17:03:35 +01:00

55 lines
1.3 KiB
C

#include <stdlib.h>
#include "../config.h"
#include "../particle.h"
static int
begin_expose(struct exposable *exposable)
{
exposable->width = exposable->particle->left_margin +
exposable->particle->right_margin;
return exposable->width;
}
static void
expose(const struct exposable *exposable, cairo_t *cr, int x, int y, int height)
{
exposable_render_deco(exposable, cr, x, y, height);
}
static struct exposable *
instantiate(const struct particle *particle, const struct tag_set *tags)
{
char *on_click = tags_expand_template(particle->on_click_template, tags);
struct exposable *exposable = exposable_common_new(particle, on_click);
exposable->begin_expose = &begin_expose;
exposable->expose = &expose;
free(on_click);
return exposable;
}
static struct particle *
empty_new(struct particle *common)
{
common->destroy = &particle_default_destroy;
common->instantiate = &instantiate;
return common;
}
struct particle *
from_conf(const struct yml_node *node, struct particle *common)
{
return empty_new(common);
}
bool
verify_conf(keychain_t *chain, const struct yml_node *node)
{
static const struct attr_info attrs[] = {
PARTICLE_COMMON_ATTRS,
};
return conf_verify_dict(chain, node, attrs);
}