[gnome-builder/wip/chergert/layout: 37/118] layout: handle removal of stacks with views



commit 1435aaa7ed972ad7ce58cc2d9157fbadd49cc8c3
Author: Christian Hergert <chergert redhat com>
Date:   Thu Jun 29 23:18:15 2017 -0700

    layout: handle removal of stacks with views
    
    These should always have a size of 0 due to the current design, but we
    should also ensure the item is removed from the array.

 libide/layout/ide-layout-grid.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/libide/layout/ide-layout-grid.c b/libide/layout/ide-layout-grid.c
index a5f2e27..89a4626 100644
--- a/libide/layout/ide-layout-grid.c
+++ b/libide/layout/ide-layout-grid.c
@@ -875,10 +875,25 @@ void
 _ide_layout_grid_stack_removed (IdeLayoutGrid  *self,
                                 IdeLayoutStack *stack)
 {
+  IdeLayoutGridPrivate *priv = ide_layout_grid_get_instance_private (self);
+  guint position = 0;
+
   g_return_if_fail (IDE_IS_LAYOUT_GRID (self));
   g_return_if_fail (IDE_IS_LAYOUT_STACK (stack));
 
   g_signal_handlers_disconnect_by_func (stack,
                                         G_CALLBACK (ide_layout_grid_stack_items_changed),
                                         self);
+
+  for (guint i = 0; i < priv->stack_info->len; i++)
+    {
+      const StackInfo info = g_array_index (priv->stack_info, StackInfo, i);
+
+      if (info.stack == stack)
+        {
+          g_array_remove_index (priv->stack_info, i);
+          g_list_model_items_changed (G_LIST_MODEL (self), position, info.len, 0);
+          break;
+        }
+    }
 }


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