[gtk+/extended-layout-jhs: 44/64] Avoid rounding errors in size allocation by adopting the algorithm used by
- From: Johannes Schmid <jhs src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtk+/extended-layout-jhs: 44/64] Avoid rounding errors in size allocation by adopting the algorithm used by
- Date: Wed, 25 Nov 2009 11:22:36 +0000 (UTC)
commit 2792ff352a6b090ffa59de75025aa08afa933ae9
Author: Mathias Hasselmann <mathias hasselmann gmx de>
Date: Wed Aug 1 11:19:44 2007 +0000
Avoid rounding errors in size allocation by adopting the algorithm used by
2007-07-29 Mathias Hasselmann <mathias hasselmann gmx de>
* gtk/gtkcellview.c: Avoid rounding errors in size
allocation by adopting the algorithm used by GtkHBox.
svn path=/branches/extended-layout/; revision=18562
ChangeLog.gtk-extended-layout | 5 +++++
gtk/gtkcellview.c | 31 +++++++++++++++++++++----------
2 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog.gtk-extended-layout b/ChangeLog.gtk-extended-layout
index ec8f176..d6cdc34 100644
--- a/ChangeLog.gtk-extended-layout
+++ b/ChangeLog.gtk-extended-layout
@@ -1,3 +1,8 @@
+2007-07-29 Mathias Hasselmann <mathias hasselmann gmx de>
+
+ * gtk/gtkcellview.c: Avoid rounding errors in size
+ allocation by adopting the algorithm used by GtkHBox.
+
2007-07-28 Mathias Hasselmann <mathias hasselmann gmx de>
* tests/testextendedlayout.c: Preparing natural
diff --git a/gtk/gtkcellview.c b/gtk/gtkcellview.c
index 1cd3fc7..9e35df4 100644
--- a/gtk/gtkcellview.c
+++ b/gtk/gtkcellview.c
@@ -323,11 +323,12 @@ static void
gtk_cell_view_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
+ GtkCellView *cellview;
GList *i;
- gint expand_cell_count = 0;
+
+ gint nexpand_cells = 0;
gint full_requested_width = 0;
- gint extra_space;
- GtkCellView *cellview;
+ gint available, extra;
widget->allocation = *allocation;
@@ -342,16 +343,17 @@ gtk_cell_view_size_allocate (GtkWidget *widget,
continue;
if (info->expand)
- expand_cell_count++;
+ nexpand_cells++;
full_requested_width += info->requested_width;
}
- extra_space = widget->allocation.width - full_requested_width;
- if (extra_space < 0)
- extra_space = 0;
- else if (extra_space > 0 && expand_cell_count > 0)
- extra_space /= expand_cell_count;
+ available = MAX (0, widget->allocation.width - full_requested_width);
+
+ if (nexpand_cells > 0)
+ extra = available / nexpand_cells;
+ else
+ extra = 0;
/* iterate list for PACK_START cells */
for (i = cellview->priv->cell_list; i; i = i->next)
@@ -378,7 +380,16 @@ gtk_cell_view_size_allocate (GtkWidget *widget,
if (!info->cell->visible)
continue;
- info->real_width = info->requested_width + (info->expand?extra_space:0);
+ if (info->expand)
+ {
+ if (1 == nexpand_cells)
+ info->real_width += available;
+ else
+ info->real_width += extra;
+
+ nexpand_cells -= 1;
+ available -= extra;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]