diff --git a/examples/basic/listbox.c b/examples/basic/listbox.c index 8f6ca5a..3120d01 100644 --- a/examples/basic/listbox.c +++ b/examples/basic/listbox.c @@ -7,7 +7,7 @@ MwWidget wmain; void destroy(MwWidget handle, void* user, void* call) { (void)handle; (void)call; - MwMessageBoxDestroy(user); + MwDestroyWidget(user); } void activate(MwWidget handle, void* user, void* call) { diff --git a/examples/basic/messagebox.c b/examples/basic/messagebox.c index e95f55a..343042f 100644 --- a/examples/basic/messagebox.c +++ b/examples/basic/messagebox.c @@ -3,7 +3,7 @@ void ok(MwWidget handle, void* user, void* call) { (void)handle; (void)call; - MwMessageBoxDestroy(user); + MwDestroyWidget(user); } void spawn(MwWidget handle, void* user, void* call) { diff --git a/examples/basic/treeview.c b/examples/basic/treeview.c index e08db39..3be61cd 100644 --- a/examples/basic/treeview.c +++ b/examples/basic/treeview.c @@ -5,7 +5,7 @@ MwWidget wmain; void destroy(MwWidget handle, void* user, void* call) { (void)handle; (void)call; - MwMessageBoxDestroy(user); + MwDestroyWidget(user); } void activate(MwWidget handle, void* user, void* call) { diff --git a/include/Mw/Dialog/MessageBox.h b/include/Mw/Dialog/MessageBox.h index 8a5e9cb..c0e76ed 100644 --- a/include/Mw/Dialog/MessageBox.h +++ b/include/Mw/Dialog/MessageBox.h @@ -29,12 +29,6 @@ MWDECL MwWidget MwMessageBox(MwWidget handle, const char* text, const char* titl */ MWDECL MwWidget MwMessageBoxGetChild(MwWidget handle, int child); -/*! - * @brief Destroys the message box - * @param handle Widget - */ -MWDECL void MwMessageBoxDestroy(MwWidget handle); - #ifdef __cplusplus } #endif diff --git a/include/Mw/TypeDefs.h b/include/Mw/TypeDefs.h index 21def05..5e62dbf 100644 --- a/include/Mw/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -91,6 +91,7 @@ struct _MwWidget { void* internal; void* opaque; void (*draw_inject)(MwWidget handle); + void (*destroy_inject)(MwWidget handle); MwIntegerKeyValue* integer; MwTextKeyValue* text; diff --git a/milsko.xml b/milsko.xml index 5e93f30..fadaadc 100644 --- a/milsko.xml +++ b/milsko.xml @@ -554,11 +554,6 @@ - - - - - diff --git a/src/core.c b/src/core.c index 6476ccb..758e86a 100644 --- a/src/core.c +++ b/src/core.c @@ -200,6 +200,7 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, h->destroy_queue = NULL; h->prop_event = 1; h->draw_inject = NULL; + h->destroy_inject = NULL; h->tick_list = NULL; h->destroyed = 0; h->bgcolor = NULL; @@ -317,6 +318,7 @@ static void MwFreeWidget(MwWidget handle) { handle->destroyed = 0; MwDispatch(handle, destroy); + if(handle->destroy_inject != NULL) handle->destroy_inject(handle); for(i = 0; i < arrlen(handle->children); i++) { MwFreeWidget(handle->children[i]); diff --git a/src/dialog/filechooser.c b/src/dialog/filechooser.c index f155f07..b65346b 100644 --- a/src/dialog/filechooser.c +++ b/src/dialog/filechooser.c @@ -78,7 +78,7 @@ static void msgbox_okay(MwWidget handle, void* user, void* call) { (void)user; (void)call; - MwMessageBoxDestroy(handle->parent); + MwDestroyWidget(handle->parent); } static void files_activate(MwWidget handle, void* user, void* call) { diff --git a/src/dialog/messagebox.c b/src/dialog/messagebox.c index 43e837a..c634b5d 100644 --- a/src/dialog/messagebox.c +++ b/src/dialog/messagebox.c @@ -18,6 +18,18 @@ static void spawn_button(MwWidget handle, int x, int y, int id, const char* text handle->opaque = mb; } +static void messagebox_destroy_inject(MwWidget handle) { + void* px; + + if((px = MwGetVoid(handle, MwNpixmap)) != NULL) MwLLDestroyPixmap(px); +} + +static void messagebox_close(MwWidget handle, void* user, void* call) { + (void)user; + (void)call; + MwDestroyWidget(handle); +} + MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsigned int flag) { MwWidget window; int w, h; @@ -106,6 +118,9 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi MwLLMakePopup(window->lowlevel, handle == NULL ? NULL : handle->lowlevel); MwLLEndStateChange(window->lowlevel); + MwAddUserHandler(window, MwNcloseHandler, messagebox_close, NULL); + window->destroy_inject = messagebox_destroy_inject; + return window; } @@ -114,10 +129,3 @@ MwWidget MwMessageBoxGetChild(MwWidget handle, int child) { return hmget(mb, child); } - -void MwMessageBoxDestroy(MwWidget handle) { - void* px; - - if((px = MwGetVoid(handle, MwNpixmap)) != NULL) MwLLDestroyPixmap(px); - MwDestroyWidget(handle); -}