fix ui_close (GTK) default tip

Sun, 24 May 2026 08:53:45 +0200

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 24 May 2026 08:53:45 +0200
changeset 1137
db9c3838fd4d
parent 1136
e6fc42b4248d

fix ui_close (GTK)

application/main.c file | annotate | diff | comparison | revisions
ui/gtk/window.c file | annotate | diff | comparison | revisions
--- a/application/main.c	Sat May 23 21:38:30 2026 +0200
+++ b/application/main.c	Sun May 24 08:53:45 2026 +0200
@@ -642,6 +642,21 @@
     printf("global save\n");
 }
 
+static void action_test_dialog_onclick(UiEvent *event, void *userdata) {
+    ui_close(event->obj);
+}
+
+static void action_test_dialog(UiEvent *event, void *userdata) {
+    UiObject *obj = ui_dialog_window(event->obj, .title = "Test Dialog", .lbutton1 = "OK", .rbutton4 = "Cancel", .onclick = action_test_dialog_onclick);
+    ui_vbox(obj, .margin = 10, .spacing = 10) {
+        ui_button(obj, .label = "Test 1");
+        ui_button(obj, .label = "Test 2");
+        ui_button(obj, .label = "Test 3");
+        ui_button(obj, .label = "Test 4");
+    }
+    ui_show(obj);
+}
+
 void application_startup(UiEvent *event, void *data) {
     // test window destruction
     UiObject *testobj = ui_window("testwindow");
@@ -759,6 +774,7 @@
             ui_button(obj, .label = "Obj Unref", .onclick=action_button_unref, .onclickdata = obj);
             ui_button(obj, .label = "Button 5", .onclick=action_tab2_button);
             ui_button(obj, .label = "Button 6", .onclick=action_tab2_button);
+            ui_button(obj, .label = "Test Dialog", .onclick=action_test_dialog);
         }
         ui_tab(obj, "Tab 3") {
             UiTabViewArgs args = {.fill = TRUE};
--- a/ui/gtk/window.c	Sat May 23 21:38:30 2026 +0200
+++ b/ui/gtk/window.c	Sun May 24 08:53:45 2026 +0200
@@ -126,7 +126,9 @@
 #endif
         return TRUE;
     } else {
+        // this cleans up any widget references from the context
         uic_context_prepare_close(obj->ctx);
+        ui_window_widget_destroy(obj);
         return FALSE;
     }
 }

mercurial