[libnma/lr/gtk-4.0: 12/33] private: add gtk_window_set_hide_on_close() compatibility wrapper




commit 1d6fab78ba52192b9473971981ec614c27acd673
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Thu Oct 14 09:10:47 2021 +0200

    private: add gtk_window_set_hide_on_close() compatibility wrapper
    
    When a dialog windows is deleted (by pressing the close button or a
    keyboard binding), the widget is destroyed in addition to emission of a
    normal response (which is the only thing that happens when the dialog
    button is pressed).
    
    This behavior is super-annoying for modal dialogs -- you can't tell
    whether the window is destroyed or when you get a response. Gtk3 allows
    suppressing this by returning TRUE from the ::delete signal, Gtk4 uses
    the hide-on-close property instead. Let's make this a bit more
    consistent for us.

 src/nma-private.h | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/src/nma-private.h b/src/nma-private.h
index 74d109a3..8b407af2 100644
--- a/src/nma-private.h
+++ b/src/nma-private.h
@@ -23,8 +23,16 @@
 #define gtk_init()                                     gtk_init(&argc, &argv)
 #define gtk_window_new()                               gtk_window_new(GTK_WINDOW_TOPLEVEL)
 #define gtk_widget_get_root(widget)                    gtk_widget_get_toplevel(widget)
+#define gtk_window_set_hide_on_close(window, hide)     g_signal_connect(dialog, "delete-event", G_CALLBACK 
(_nma_window_hide_on_close), NULL)
 
 typedef void GtkRoot;
+
+static inline int
+_nma_window_hide_on_close (GtkWindow *window, gpointer user_data)
+{
+       gtk_widget_hide (GTK_WIDGET (window));
+       return TRUE;
+}
 #endif
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]