[gdl] Allow to display widget not present in the saved layout



commit 9e24d9f7cb3a7aac33f8d4059fcbd8681ae26491
Author: SÃbastien Granjoux <seb sfo free fr>
Date:   Fri Jul 27 08:24:11 2012 +0200

    Allow to display widget not present in the saved layout
    
    When you load a new layout, widgets present in the old layout and not in the
    new one are hidden but it was not possible to re display them later because
    their parents have been replaced by widgets from the saved layout.
    
    Now, all widgets are removed from the layout and when you try to display
    a widget not already present in the widget hierarchy, it is not just shown but
    it is docked again as it was done before.

 gdl/gdl-dock-item.c   |   23 +++++++++++++++++++++++
 gdl/gdl-dock-layout.c |   19 +++++++++++--------
 2 files changed, 34 insertions(+), 8 deletions(-)
---
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index 8ae6b86..918d477 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -2222,6 +2222,29 @@ gdl_dock_item_show_item (GdlDockItem *item)
 {
     g_return_if_fail (item != NULL);
 
+    /* Check if we need to dock the window */
+    if (gtk_widget_get_parent (GTK_WIDGET (item)) == NULL) {
+        if (gdl_dock_object_is_bound (GDL_DOCK_OBJECT (item))) {
+            GdlDockObject *toplevel;
+        
+            toplevel = gdl_dock_master_get_controller
+                            (GDL_DOCK_OBJECT_GET_MASTER (item));
+            if (toplevel == item) return;
+        
+            if (item->behavior & GDL_DOCK_ITEM_BEH_NEVER_FLOATING) {
+                g_warning("Object %s has no default position and flag GDL_DOCK_ITEM_BEH_NEVER_FLOATING is set.\n",
+                          GDL_DOCK_OBJECT(item)->name);
+            } else if (toplevel) {
+                gdl_dock_object_dock (toplevel, GDL_DOCK_OBJECT (item),
+                                      GDL_DOCK_FLOATING, NULL);
+            } else
+                g_warning("There is no toplevel window. GdlDockItem %s cannot be shown.\n", GDL_DOCK_OBJECT(item)->name);
+        
+        } else
+            g_warning("GdlDockItem %s is not bound. It cannot be shown.\n",
+                      GDL_DOCK_OBJECT(item)->name);
+    }
+
     GDL_DOCK_OBJECT_UNSET_FLAGS (item, GDL_DOCK_ICONIFIED);
     GDL_DOCK_OBJECT_SET_FLAGS (item, GDL_DOCK_ATTACHED);
     gtk_widget_show (GTK_WIDGET (item));
diff --git a/gdl/gdl-dock-layout.c b/gdl/gdl-dock-layout.c
index 9017c78..85f983c 100644
--- a/gdl/gdl-dock-layout.c
+++ b/gdl/gdl-dock-layout.c
@@ -382,10 +382,6 @@ gdl_dock_layout_setup_object (GdlDockMaster *master,
     /* finally unref object class */
     g_type_class_unref (object_class);
 
-    if (GDL_IS_DOCK_ITEM (object) && 
-        !gdl_dock_item_is_placeholder (GDL_DOCK_ITEM (object)) &&
-        !GDL_DOCK_ITEM_ICONIFIED (object)) gdl_dock_item_show_item(GDL_DOCK_ITEM (object));
-
         
     return object;
 }
@@ -412,6 +408,13 @@ gdl_dock_layout_recursive_build (GdlDockMaster *master,
         if (object) {
             gdl_dock_object_freeze (object);
 
+            /* detach children */
+            if (gdl_dock_object_is_compound (object)) {
+                gtk_container_foreach (GTK_CONTAINER (object),
+                               (GtkCallback) gdl_dock_object_detach,
+                               GINT_TO_POINTER (TRUE));
+            }
+            
             /* recurse here to catch placeholders */
             gdl_dock_layout_recursive_build (master, node, object);
 
@@ -432,10 +435,10 @@ gdl_dock_layout_recursive_build (GdlDockMaster *master,
                 }
             }
 
-            /* call reduce just in case any child is missing */
-            if (gdl_dock_object_is_compound (object))
-                gdl_dock_object_reduce (object);
-
+            if (GDL_IS_DOCK_ITEM (object) && 
+                !gdl_dock_item_is_placeholder (GDL_DOCK_ITEM (object)) &&
+                !GDL_DOCK_ITEM_ICONIFIED (object)) gdl_dock_item_show_item(GDL_DOCK_ITEM (object));
+            
             gdl_dock_object_thaw (object);
         }
     }



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