--- a/ui/common/context.h Sun Apr 06 13:54:28 2025 +0200 +++ b/ui/common/context.h Sun Apr 06 14:10:04 2025 +0200 @@ -40,10 +40,11 @@ extern "C" { #endif -typedef struct UiVar UiVar; -typedef struct UiListPtr UiListPtr; -typedef struct UiListVar UiListVar; -typedef struct UiGroupWidget UiGroupWidget; +typedef struct UiVar UiVar; +typedef struct UiListPtr UiListPtr; +typedef struct UiListVar UiListVar; +typedef struct UiGroupWidget UiGroupWidget; +typedef struct UiDestroyHandler UiDestroyHandler; typedef enum UiVarType { UI_VAR_SPECIAL = 0, @@ -61,6 +62,7 @@ UiObject *obj; CxMempool *mp; const CxAllocator *allocator; + CxList *destroy_handler; void *document; CxList *documents; @@ -106,11 +108,17 @@ int numgroups; }; +struct UiDestroyHandler { + cx_destructor_func destructor; + void *data; +}; + void uic_init_global_context(void); UiContext* uic_context(UiObject *toplevel, CxMempool *mp); UiContext* uic_root_context(UiContext *ctx); +void uic_context_add_destructor(UiContext *ctx, cx_destructor_func func, void *data); void uic_context_set_document(UiContext *ctx, void *document); // deprecated void uic_context_detach_document(UiContext *ctx); // deprecated