[gtk+/wip/baedert/gtk-widget-destroy: 140/149] window: Add gtk_window_destroy



commit 720356313e177a4f7abfa144463fa1503b5f3a21
Author: Timm Bäder <mail baedert org>
Date:   Tue Sep 26 07:53:51 2017 +0200

    window: Add gtk_window_destroy
    
    Instead of relying on the hacky g_object_run_dispose, simply do what
    gtk_window_destroy should be doing: Remove the window from the internal
    list of toplevels and unref it.
    
    To be used on windows instead of gtk_widget_destroy.

 docs/reference/gtk/gtk4-sections.txt |    1 +
 gtk/gtkwindow.c                      |   30 ++++++++++++++++++++----------
 gtk/gtkwindow.h                      |    3 +++
 3 files changed, 24 insertions(+), 10 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index c99c4f0..4fb980b 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4821,6 +4821,7 @@ gtk_window_set_has_user_ref_count
 gtk_window_set_titlebar
 gtk_window_get_titlebar
 gtk_window_set_interactive_debugging
+gtk_window_destroy
 
 <SUBSECTION Standard>
 GTK_WINDOW
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 91b637a..b2fe888 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -400,7 +400,7 @@ struct _GtkWindowGeometryInfo
 static void gtk_window_constructed        (GObject           *object);
 static void gtk_window_dispose            (GObject           *object);
 static void gtk_window_finalize           (GObject           *object);
-static void gtk_window_destroy            (GtkWidget         *widget);
+static void gtk_window_real_destroy       (GtkWidget         *widget);
 static void gtk_window_show               (GtkWidget         *widget);
 static void gtk_window_hide               (GtkWidget         *widget);
 static void gtk_window_map                (GtkWidget         *widget);
@@ -804,7 +804,7 @@ gtk_window_class_init (GtkWindowClass *klass)
   gobject_class->set_property = gtk_window_set_property;
   gobject_class->get_property = gtk_window_get_property;
 
-  widget_class->destroy = gtk_window_destroy;
+  widget_class->destroy = gtk_window_real_destroy;
   widget_class->show = gtk_window_show;
   widget_class->hide = gtk_window_hide;
   widget_class->map = gtk_window_map;
@@ -5793,14 +5793,13 @@ gtk_window_get_position (GtkWindow *window,
 }
 
 static void
-gtk_window_destroy (GtkWidget *widget)
+gtk_window_real_destroy (GtkWidget *widget)
 {
   GtkWindow *window = GTK_WINDOW (widget);
   GtkWindowPrivate *priv = window->priv;
 
   gtk_window_release_application (window);
 
-  toplevel_list = g_slist_remove (toplevel_list, window);
   gtk_window_update_debugging ();
 
   if (priv->transient_parent)
@@ -5811,12 +5810,6 @@ gtk_window_destroy (GtkWidget *widget)
   /* frees the icons */
   gtk_window_set_icon_list (window, NULL);
 
-  if (priv->has_user_ref_count)
-    {
-      priv->has_user_ref_count = FALSE;
-      g_object_unref (window);
-    }
-
   if (priv->group)
     gtk_window_group_remove_window (priv->group, window);
 
@@ -11441,3 +11434,20 @@ gtk_window_maybe_update_cursor (GtkWindow *window,
         break;
     }
 }
+
+/**
+ * gtk_window_destroy:
+ * @window: The window to destroy
+ *
+ * Drop the internal reference GTK+ holds on toplevel windows.
+ */
+void
+gtk_window_destroy (GtkWindow *window)
+{
+  g_return_if_fail (GTK_IS_WINDOW (window));
+
+  toplevel_list = g_slist_remove (toplevel_list, window);
+
+  gtk_widget_hide (GTK_WIDGET (window));
+  g_object_unref (window);
+}
diff --git a/gtk/gtkwindow.h b/gtk/gtkwindow.h
index 0f247e0..9ef5601 100644
--- a/gtk/gtkwindow.h
+++ b/gtk/gtkwindow.h
@@ -444,6 +444,9 @@ gboolean gtk_window_is_maximized           (GtkWindow    *window);
 GDK_AVAILABLE_IN_3_14
 void     gtk_window_set_interactive_debugging (gboolean enable);
 
+GDK_AVAILABLE_IN_3_92
+void     gtk_window_destroy                (GtkWindow *window);
+
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWindow, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWindowGroup, g_object_unref)
 


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