widget: add support for destructor
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
e5e379656a
commit
f169c4d8d9
|
@ -65,6 +65,7 @@ typedef struct _tag_t tag_t;
|
|||
typedef struct tag_client_node_t tag_client_node_t;
|
||||
typedef area_t (FloatingPlacement)(client_t *);
|
||||
typedef widget_t *(widget_constructor_t)(alignment_t);
|
||||
typedef void (widget_destructor_t)(widget_t *);
|
||||
typedef struct awesome_t awesome_t;
|
||||
|
||||
/** Widget tell status code */
|
||||
|
@ -106,6 +107,8 @@ struct widget_t
|
|||
char *name;
|
||||
/** Widget type is constructor */
|
||||
widget_constructor_t *type;
|
||||
/** Widget destructor */
|
||||
widget_destructor_t *destructor;
|
||||
/** Draw function */
|
||||
int (*draw)(draw_context_t *, int, widget_node_t *, int, int, void *);
|
||||
/** Update function */
|
||||
|
@ -130,6 +133,8 @@ struct widget_t
|
|||
static inline void
|
||||
widget_delete(widget_t **widget)
|
||||
{
|
||||
if((*widget)->destructor)
|
||||
(*widget)->destructor(*widget);
|
||||
button_list_wipe(&(*widget)->buttons);
|
||||
p_delete(&(*widget)->data);
|
||||
p_delete(&(*widget)->name);
|
||||
|
|
Loading…
Reference in New Issue