]> Pileus Git - ~andy/gtk/commitdiff
Keep GtkPlug in sync with the global list of toplevels.
authorMatthias Clasen <matthiasc@src.gnome.org>
Fri, 23 Jan 2009 05:57:36 +0000 (05:57 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Fri, 23 Jan 2009 05:57:36 +0000 (05:57 +0000)
        Patch by Federico Mena Quintero

        * gtk/gtkwindow.h:
        * gtk/gtkwindow.c (_gtk_window_set_is_toplevel): New internal
        function used when a GtkPlug parents/unparents itself by an
        in-process GtkSocket.  This keeps the plug's GTK_TOPLEVEL flag in
        sync with the global toplevel_list.

        * gtk/gtkplug.c (gtk_plug_set_is_child): Call
        _gtk_window_set_is_toplevel() to keep the toplevel list updated,
        instead of just setting/unsetting the GTK_TOPLEVEL flag.

svn path=/trunk/; revision=22191

ChangeLog
gtk/gtkplug.c
gtk/gtkwindow.c
gtk/gtkwindow.h

index 9cce823706a4952ca34da6722513bd6d56bb25d1..54422d1add5526a67ed1f36144fc460f5fb7ae2a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-01-23  Matthias Clasen  <mclasen@redhat.com>
+
+       Bug 536965 – GtkPlug: crash on theme change
+
+       Keep GtkPlug in sync with the global list of toplevels.
+       Patch by Federico Mena Quintero
+
+       * gtk/gtkwindow.h:
+       * gtk/gtkwindow.c (_gtk_window_set_is_toplevel): New internal
+       function used when a GtkPlug parents/unparents itself by an
+       in-process GtkSocket.  This keeps the plug's GTK_TOPLEVEL flag in
+       sync with the global toplevel_list.
+
+       * gtk/gtkplug.c (gtk_plug_set_is_child): Call
+       _gtk_window_set_is_toplevel() to keep the toplevel list updated,
+       instead of just setting/unsetting the GTK_TOPLEVEL flag.
+
 2009-01-23  Matthias Clasen  <mclasen@redhat.com>
 
        Bug 568744 – Spellfixes in GtkTreeView's documentation
index a692de8be34a0536d6ffe1b88c2b9d567a173a70..4c31ea70d600573b482a0674ebd5805ed5cff25a 100644 (file)
@@ -220,7 +220,7 @@ gtk_plug_set_is_child (GtkPlug  *plug,
       if (GTK_WIDGET_MAPPED (plug))
        gtk_widget_unmap (GTK_WIDGET (plug));
       
-      GTK_WIDGET_UNSET_FLAGS (plug, GTK_TOPLEVEL);
+      _gtk_window_set_is_toplevel (GTK_WINDOW (plug), FALSE);
       gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_PARENT);
 
       _gtk_widget_propagate_hierarchy_changed (GTK_WIDGET (plug), GTK_WIDGET (plug));
@@ -235,7 +235,7 @@ gtk_plug_set_is_child (GtkPlug  *plug,
       plug->modality_group = gtk_window_group_new ();
       gtk_window_group_add_window (plug->modality_group, GTK_WINDOW (plug));
       
-      GTK_WIDGET_SET_FLAGS (plug, GTK_TOPLEVEL);
+      _gtk_window_set_is_toplevel (GTK_WINDOW (plug), TRUE);
       gtk_container_set_resize_mode (GTK_CONTAINER (plug), GTK_RESIZE_QUEUE);
 
       _gtk_widget_propagate_hierarchy_changed (GTK_WIDGET (plug), NULL);
index 095a11a796ea5c84f28a2442d72429f02c25bd8a..90153ad5bf80d97655c054d7bfdef11e4babc29a 100644 (file)
@@ -8295,6 +8295,41 @@ _gtk_window_set_is_active (GtkWindow *window,
     }
 }
 
+/**
+ * _gtk_windwo_set_is_toplevel:
+ * @window: a #GtkWindow
+ * @is_toplevel: %TRUE if the window is still a real toplevel (nominally a
+ * parent of the root window); %FALSE if it is not (for example, for an
+ * in-process, parented GtkPlug)
+ *
+ * Internal function used by #GtkPlug when it gets parented/unparented by a
+ * #GtkSocket.  This keeps the @window's #GTK_TOPLEVEL flag in sync with the
+ * global list of toplevel windows.
+ */
+void
+_gtk_window_set_is_toplevel (GtkWindow *window,
+                            gboolean   is_toplevel)
+{
+  if (GTK_WIDGET_TOPLEVEL (window))
+    g_assert (g_list_find (toplevel_list, window) != NULL);
+  else
+    g_assert (g_list_find (toplevel_list, window) == NULL);
+
+  if (is_toplevel == GTK_WIDGET_TOPLEVEL (window))
+    return;
+
+  if (is_toplevel)
+    {
+      GTK_WIDGET_SET_FLAGS (window, GTK_TOPLEVEL);
+      toplevel_list = g_slist_prepend (toplevel_list, window);
+    }
+  else
+    {
+      GTK_WIDGET_UNSET_FLAGS (window, GTK_TOPLEVEL);
+      toplevel_list = g_slist_remove (toplevel_list, window);
+    }
+}
+
 /**
  * _gtk_window_set_has_toplevel_focus:
  * @window: a #GtkWindow
index e166befc898754f34f1e1ff7098693f556d659e6..243dbdc6bd8af8e2e9dd81f241d7f182fd2adabe 100644 (file)
@@ -420,6 +420,9 @@ void            _gtk_window_unset_focus_and_default (GtkWindow *window,
 void            _gtk_window_set_is_active          (GtkWindow *window,
                                                    gboolean   is_active);
 
+void            _gtk_window_set_is_toplevel        (GtkWindow *window,
+                                                   gboolean   is_toplevel);
+
 typedef void (*GtkWindowKeysForeachFunc) (GtkWindow      *window,
                                          guint           keyval,
                                          GdkModifierType modifiers,