[gedit] Fix info_bar revealer on retry



commit 3fdd0ee31848cb648bd2f221f8ee1cc9e36baa7c
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Mar 3 18:15:26 2013 +0100

    Fix info_bar revealer on retry
    
    If another error occurs when pressing "retry", we need to destroy and
    replace the current info bar without waiting for the revealer to hide
    itself.

 gedit/gedit-tab.c |   48 +++++++++++++++++++++++++++++-------------------
 1 files changed, 29 insertions(+), 19 deletions(-)
---
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index b31d9b5..adeb7a3 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -58,6 +58,7 @@ struct _GeditTabPrivate
 
        GeditViewFrame         *frame;
 
+       GtkWidget              *info_bar_revealer;
        GtkWidget              *info_bar;
        GtkWidget              *print_preview;
 
@@ -529,33 +530,42 @@ static void
 set_info_bar (GeditTab  *tab,
              GtkWidget *info_bar)
 {
-       GtkWidget *revealer;
-
        if (tab->priv->info_bar == info_bar)
                return;
 
-       if (tab->priv->info_bar != NULL)
-       {
-               revealer = gtk_widget_get_parent (tab->priv->info_bar);
-               g_signal_connect (revealer, "notify::child-revealed",
-                                 G_CALLBACK(gtk_widget_destroy), NULL);
-               gd_revealer_set_reveal_child (GD_REVEALER (revealer), FALSE);
-       }
-
        tab->priv->info_bar = info_bar;
 
        if (info_bar == NULL)
-               return;
+       {
+               gd_revealer_set_reveal_child (GD_REVEALER (tab->priv->info_bar_revealer), FALSE);
+               tab->priv->info_bar = NULL;
+       }
+       else
+       {
+               /* lazy init the reveler */
+               if (tab->priv->info_bar_revealer == NULL)
+               {
+                       tab->priv->info_bar_revealer = gd_revealer_new ();
+                       gtk_widget_show (tab->priv->info_bar_revealer);
+                       gtk_box_pack_start (GTK_BOX (tab), tab->priv->info_bar_revealer, FALSE, FALSE, 0);
+               }
+               else
+               {
+                       GtkWidget *old;
 
-       revealer = gd_revealer_new ();
-       gtk_widget_show (revealer);
-       gtk_box_pack_start (GTK_BOX (tab), revealer, FALSE, FALSE, 0);
-       gtk_container_add (GTK_CONTAINER (revealer), tab->priv->info_bar);
+                       old = gtk_bin_get_child (GTK_BIN (tab->priv->info_bar_revealer));
+                       if (old != NULL)
+                       {
+                               gtk_container_remove (GTK_CONTAINER (tab->priv->info_bar_revealer), old);     
                          
+                       }
+               }
 
-       gd_revealer_set_reveal_child (GD_REVEALER (revealer), TRUE);
+               gtk_container_add (GTK_CONTAINER (tab->priv->info_bar_revealer), info_bar);
+               gd_revealer_set_reveal_child (GD_REVEALER (tab->priv->info_bar_revealer), TRUE);
 
-       g_object_add_weak_pointer (G_OBJECT (tab->priv->info_bar),
-                                  (gpointer *)&tab->priv->info_bar);
+               g_object_add_weak_pointer (G_OBJECT (info_bar),
+                                          (gpointer *)&tab->priv->info_bar);
+       }
 }
 
 static void


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