[gnome-builder] simplify repositioning code
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] simplify repositioning code
- Date: Tue, 24 Mar 2015 00:26:30 +0000 (UTC)
commit 199016c29c1aa1037ace767e6ad6a71c57ee0c24
Author: Christian Hergert <christian hergert me>
Date: Thu Mar 19 13:40:08 2015 -0700
simplify repositioning code
src/views/gb-view-grid.c | 40 +++++++++++++---------------------------
1 files changed, 13 insertions(+), 27 deletions(-)
---
diff --git a/src/views/gb-view-grid.c b/src/views/gb-view-grid.c
index ece7abb..5416654 100644
--- a/src/views/gb-view-grid.c
+++ b/src/views/gb-view-grid.c
@@ -366,43 +366,29 @@ static void
gb_view_grid_reposition (GbViewGrid *self)
{
GtkAllocation alloc;
- GtkWidget *paned;
- GtkWidget *stack;
- guint count = 0;
+ GList *stacks;
+ GList *iter;
+ guint count;
guint position;
g_return_if_fail (GB_IS_VIEW_GRID (self));
gtk_widget_get_allocation (GTK_WIDGET (self), &alloc);
+ stacks = gb_view_grid_get_stacks (self);
+ count = MAX (1, g_list_length (stacks));
+ position = alloc.width / count;
- paned = gtk_bin_get_child (GTK_BIN (self));
-
- if (!GTK_IS_PANED (paned))
- return;
-
- stack = gtk_paned_get_child1 (GTK_PANED (paned));
- g_assert (GB_IS_VIEW_STACK (stack));
-
- do
+ for (iter = stacks; iter; iter = iter->next)
{
- count++;
- stack = gb_view_grid_get_stack_after (self, GB_VIEW_STACK (stack));
- g_assert (!stack || GB_IS_VIEW_STACK (stack));
- }
- while (stack);
+ GtkWidget *parent;
- position = alloc.width / count;
+ parent = gtk_widget_get_parent (iter->data);
+ g_assert (GTK_IS_PANED (parent));
- stack = gtk_paned_get_child1 (GTK_PANED (paned));
- g_assert (GB_IS_VIEW_STACK (stack));
- do
- {
- paned = gtk_widget_get_parent (stack);
- gtk_paned_set_position (GTK_PANED (paned), position);
- stack = gb_view_grid_get_stack_after (self, GB_VIEW_STACK (stack));
- g_assert (!stack|| GB_IS_VIEW_STACK (stack));
+ gtk_paned_set_position (GTK_PANED (parent), position);
}
- while (stack);
+
+ g_list_free (stacks);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]