remove MwMessageBoxDestroy, introduce destroy_inject

This commit is contained in:
Nishi 2026-04-20 02:04:43 +09:00
commit a59154d5f1
Signed by: nishi
GPG key ID: 27EF69B208EB9343
9 changed files with 22 additions and 22 deletions

View file

@ -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]);

View file

@ -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) {

View file

@ -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);
}