mirror of
https://codeberg.org/dnkl/yambar.git
synced 2025-06-16 08:15:40 +02:00
exposable: add a "common" constructor and default destructor
This commit is contained in:
parent
acda1a4b21
commit
e8d8bf70d3
6 changed files with 59 additions and 33 deletions
24
particle.c
24
particle.c
|
@ -1,5 +1,7 @@
|
|||
#include "particle.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
void
|
||||
particle_default_destroy(struct particle *particle)
|
||||
|
@ -18,3 +20,25 @@ particle_common_new(int left_margin, int right_margin)
|
|||
p->deco = NULL;
|
||||
return p;
|
||||
}
|
||||
|
||||
struct exposable *
|
||||
exposable_common_new(const struct particle *particle, const char *on_click)
|
||||
{
|
||||
struct exposable *exposable = malloc(sizeof(*exposable));
|
||||
exposable->particle = particle;
|
||||
exposable->private = NULL;
|
||||
exposable->width = 0;
|
||||
exposable->on_click = on_click != NULL ? strdup(on_click) : NULL;
|
||||
exposable->destroy = &exposable_default_destroy;
|
||||
exposable->on_mouse = &exposable_default_on_mouse;
|
||||
exposable->begin_expose = NULL;
|
||||
exposable->expose = NULL;
|
||||
return exposable;
|
||||
}
|
||||
|
||||
void
|
||||
exposable_default_destroy(struct exposable *exposable)
|
||||
{
|
||||
free(exposable->on_click);
|
||||
free(exposable);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue