fix replace close_request signal on gtk3 newapi

Tue, 29 Oct 2024 10:43:59 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Tue, 29 Oct 2024 10:43:59 +0100
branch
newapi
changeset 366
799c8f60b9f1
parent 365
004b5dd01f6a
child 367
1c3af8e31d8e

fix replace close_request signal on gtk3

ui/gtk/window.c file | annotate | diff | comparison | revisions
--- a/ui/gtk/window.c	Tue Oct 29 10:37:14 2024 +0100
+++ b/ui/gtk/window.c	Tue Oct 29 10:43:59 2024 +0100
@@ -71,10 +71,17 @@
 #endif
 }
 
+#if GTK_MAJOR_VERSION >= 4
 static gboolean close_request(GtkWindow* self, UiContext *ctx) {
     uic_context_prepare_close(ctx);
     return FALSE;
 }
+#else
+static gboolean close_request(GtkWidget* self, GdkEvent* event, UiContext *ctx) {
+    uic_context_prepare_close(ctx);
+    return FALSE;
+}
+#endif
 
 static UiObject* create_window(const char *title, void *window_data, UiBool simple) {
     CxMempool *mp = cxBasicMempoolCreate(256);
@@ -119,11 +126,19 @@
             "destroy",
             G_CALLBACK(ui_exit_event),
             obj);
+#if GTK_MAJOR_VERSION >= 4
     g_signal_connect(
             obj->widget,
             "close-request",
             G_CALLBACK(close_request),
             obj->ctx);
+#else
+    g_signal_connect(
+            obj->widget,
+            "delete-event",
+            G_CALLBACK(close_request),
+            obj->ctx);
+#endif
     
     GtkWidget *vbox = ui_gtk_vbox_new(0);
 #ifdef UI_LIBADWAITA

mercurial