From f169c4d8d9bd4dbe89006554c03d188081f1f98f Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Sat, 14 Jun 2008 22:38:40 +0200 Subject: [PATCH] widget: add support for destructor Signed-off-by: Julien Danjou --- structs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/structs.h b/structs.h index e495abd83..ea508064e 100644 --- a/structs.h +++ b/structs.h @@ -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);