[epiphany] embed: don't attempt to parent notification container twice



commit 6cad7438f6f44e12869305a58b3827cff33fe33a
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sat Oct 8 20:18:20 2016 -0500

    embed: don't attempt to parent notification container twice
    
    If the EphyNotificationContainer is already contained by another embed
    (including, in particular, another embed in another window) then don't
    try to parent it again. Similarly, don't attempt to unparent an
    EphyNotificationContainer unless it's really contained by this embed.
    
    This should probably be cleaned up better, but it's not simple to reason
    about what should happen to the EphyNotificationContainer when there
    are multiple windows.

 embed/ephy-embed.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c
index d6b6b25..679cd91 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -958,7 +958,8 @@ ephy_embed_attach_notification_container (EphyEmbed *embed)
   g_return_if_fail (EPHY_IS_EMBED (embed));
 
   container = ephy_notification_container_get_default ();
-  gtk_overlay_add_overlay (GTK_OVERLAY (embed->overlay), GTK_WIDGET (container));
+  if (gtk_widget_get_parent (GTK_WIDGET (container)) == NULL)
+    gtk_overlay_add_overlay (GTK_OVERLAY (embed->overlay), GTK_WIDGET (container));
 }
 
 void
@@ -969,9 +970,11 @@ ephy_embed_detach_notification_container (EphyEmbed *embed)
   g_return_if_fail (EPHY_IS_EMBED (embed));
 
   container = ephy_notification_container_get_default ();
-  /* Since the overlay container will own the one and only reference to the
-   * notification widget, removing it from the container will destroy the
-   * singleton. To prevent this, add a reference to it before removing it
-   * from the container. */
-  gtk_container_remove (GTK_CONTAINER (embed->overlay), g_object_ref (container));
+  if (gtk_widget_get_parent (GTK_WIDGET (container)) == embed->overlay) {
+    /* Since the overlay container will own the one and only reference to the
+     * notification widget, removing it from the container will destroy the
+     * singleton. To prevent this, add a reference to it before removing it
+     * from the container. */
+    gtk_container_remove (GTK_CONTAINER (embed->overlay), g_object_ref (container));
+  }
 }


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