[gnome-builder/editor-layout] stack: add short circuit for move right



commit c973db172cc23592df8be6f6c47895c403c7af3f
Author: Christian Hergert <christian hergert me>
Date:   Tue Nov 25 20:10:34 2014 -0800

    stack: add short circuit for move right

 src/tabs/gb-tab-grid.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/src/tabs/gb-tab-grid.c b/src/tabs/gb-tab-grid.c
index 26ba62e..36677bf 100644
--- a/src/tabs/gb-tab-grid.c
+++ b/src/tabs/gb-tab-grid.c
@@ -378,6 +378,7 @@ gb_tab_grid_move_tab_right (GbTabGrid *self,
   GbTabStack *stack;
   GList *iter;
   GList *stacks;
+  GList *children;
 
   ENTRY;
 
@@ -390,6 +391,21 @@ gb_tab_grid_move_tab_right (GbTabGrid *self,
     {
       if (gb_tab_stack_contains_tab (iter->data, tab))
         {
+          /* if we are the last stack and this is the last item,
+           * we can short circuit and do nothing.
+           */
+          if (!iter->next)
+            {
+              guint length;
+
+              children = gb_tab_stack_get_tabs (iter->data);
+              length = g_list_length (children);
+              g_list_free (children);
+
+              if (length == 1)
+                break;
+            }
+
           g_object_ref (tab);
           gb_tab_stack_remove_tab (iter->data, tab);
           if (!iter->next)


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