Fix some corner cases in the size allocation logic for tabs. (#341577,

2006-05-12  Matthias Clasen  <mclasen@redhat.com>

	* gtk/gtknotebook.c: Fix some corner cases in the size
	allocation logic for tabs.  (#341577, Carlos Garnacho Parro)
This commit is contained in:
Matthias Clasen
2006-05-13 03:16:09 +00:00
committed by Matthias Clasen
parent f24becbe96
commit 171fb95f74
3 changed files with 24 additions and 19 deletions

View File

@ -1,5 +1,8 @@
2006-05-12 Matthias Clasen <mclasen@redhat.com> 2006-05-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtknotebook.c: Fix some corner cases in the size
allocation logic for tabs. (#341577, Carlos Garnacho Parro)
* gtk/gtkprintunixdialog.c: Some fixes to capitalization of * gtk/gtkprintunixdialog.c: Some fixes to capitalization of
labels. (#341558, Dennis Cranston) labels. (#341558, Dennis Cranston)

View File

@ -1,5 +1,8 @@
2006-05-12 Matthias Clasen <mclasen@redhat.com> 2006-05-12 Matthias Clasen <mclasen@redhat.com>
* gtk/gtknotebook.c: Fix some corner cases in the size
allocation logic for tabs. (#341577, Carlos Garnacho Parro)
* gtk/gtkprintunixdialog.c: Some fixes to capitalization of * gtk/gtkprintunixdialog.c: Some fixes to capitalization of
labels. (#341558, Dennis Cranston) labels. (#341558, Dennis Cranston)

View File

@ -4943,7 +4943,8 @@ gtk_notebook_calculate_shown_tabs (GtkNotebook *notebook,
*n = 0; *n = 0;
*remaining_space = max - min - tab_overlap - tab_space; *remaining_space = max - min - tab_overlap - tab_space;
notebook->first_tab = children = gtk_notebook_search_page (notebook, NULL, children = notebook->children;
notebook->first_tab = gtk_notebook_search_page (notebook, NULL,
STEP_NEXT, TRUE); STEP_NEXT, TRUE);
while (children) while (children)
{ {
@ -4998,9 +4999,8 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
GList *last_child, GList *last_child,
gboolean showarrow, gboolean showarrow,
gint direction, gint direction,
gint n,
gint *remaining_space, gint *remaining_space,
gint *i, gint *expanded_tabs,
gint min, gint min,
gint max) gint max)
{ {
@ -5009,8 +5009,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
GtkNotebookPrivate *priv; GtkNotebookPrivate *priv;
GtkNotebookPage *page; GtkNotebookPage *page;
gboolean allocate_at_bottom; gboolean allocate_at_bottom;
gint tab_overlap, tab_pos, delta; gint tab_overlap, tab_pos, tab_extra_space;
gint new_fill, old_fill;
gint left_x, right_x, top_y, bottom_y, anchor; gint left_x, right_x, top_y, bottom_y, anchor;
gboolean gap_left, packing_changed; gboolean gap_left, packing_changed;
GtkAllocation child_allocation = { 0, }; GtkAllocation child_allocation = { 0, };
@ -5022,7 +5021,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
gtk_widget_style_get (widget, "tab-overlap", &tab_overlap, NULL); gtk_widget_style_get (widget, "tab-overlap", &tab_overlap, NULL);
tab_pos = get_effective_tab_pos (notebook); tab_pos = get_effective_tab_pos (notebook);
allocate_at_bottom = get_allocate_at_bottom (widget, direction); allocate_at_bottom = get_allocate_at_bottom (widget, direction);
anchor = old_fill = 0; anchor = 0;
child_allocation.x = widget->allocation.x + container->border_width; child_allocation.x = widget->allocation.x + container->border_width;
child_allocation.y = widget->allocation.y + container->border_width; child_allocation.y = widget->allocation.y + container->border_width;
@ -5083,19 +5082,19 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page)) if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page))
continue; continue;
delta = 0; tab_extra_space = 0;
if (n && (showarrow || page->expand || notebook->homogeneous)) if (*expanded_tabs && (showarrow || page->expand || notebook->homogeneous))
{ {
new_fill = (*remaining_space * (*i)++) / n; tab_extra_space = *remaining_space / *expanded_tabs;
delta = new_fill - old_fill; *remaining_space -= tab_extra_space;
old_fill = new_fill; (*expanded_tabs)--;
} }
switch (tab_pos) switch (tab_pos)
{ {
case GTK_POS_TOP: case GTK_POS_TOP:
case GTK_POS_BOTTOM: case GTK_POS_BOTTOM:
child_allocation.width = page->requisition.width + tab_overlap + delta; child_allocation.width = page->requisition.width + tab_overlap + tab_extra_space;
/* make sure that the reordered tab doesn't go past the last position */ /* make sure that the reordered tab doesn't go past the last position */
if (priv->operation == DRAG_OPERATION_REORDER && if (priv->operation == DRAG_OPERATION_REORDER &&
@ -5152,7 +5151,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook,
break; break;
case GTK_POS_LEFT: case GTK_POS_LEFT:
case GTK_POS_RIGHT: case GTK_POS_RIGHT:
child_allocation.height = page->requisition.height + tab_overlap + delta; child_allocation.height = page->requisition.height + tab_overlap + tab_extra_space;
/* make sure that the reordered tab doesn't go past the last position */ /* make sure that the reordered tab doesn't go past the last position */
if (priv->operation == DRAG_OPERATION_REORDER && if (priv->operation == DRAG_OPERATION_REORDER &&
@ -5316,32 +5315,32 @@ gtk_notebook_pages_allocate (GtkNotebook *notebook)
GList *last_child = NULL; GList *last_child = NULL;
gboolean showarrow = FALSE; gboolean showarrow = FALSE;
gint tab_space, min, max, remaining_space; gint tab_space, min, max, remaining_space;
gint i, n, operation; gint expanded_tabs, operation;
gboolean changed; gboolean changed;
if (!notebook->show_tabs || !notebook->children || !notebook->cur_page) if (!notebook->show_tabs || !notebook->children || !notebook->cur_page)
return; return;
min = max = tab_space = remaining_space = 0; min = max = tab_space = remaining_space = 0;
i = n = 1; expanded_tabs = 1;
gtk_notebook_tab_space (notebook, &showarrow, gtk_notebook_tab_space (notebook, &showarrow,
&min, &max, &tab_space); &min, &max, &tab_space);
gtk_notebook_calculate_shown_tabs (notebook, showarrow, gtk_notebook_calculate_shown_tabs (notebook, showarrow,
min, max, tab_space, &last_child, min, max, tab_space, &last_child,
&n, &remaining_space); &expanded_tabs, &remaining_space);
children = notebook->first_tab; children = notebook->first_tab;
changed = gtk_notebook_calculate_tabs_allocation (notebook, &children, last_child, changed = gtk_notebook_calculate_tabs_allocation (notebook, &children, last_child,
showarrow, STEP_NEXT, showarrow, STEP_NEXT,
n, &remaining_space, &i, min, max); &remaining_space, &expanded_tabs, min, max);
if (children && children != last_child) if (children && children != last_child)
{ {
children = notebook->children; children = notebook->children;
changed |= gtk_notebook_calculate_tabs_allocation (notebook, &children, last_child, changed |= gtk_notebook_calculate_tabs_allocation (notebook, &children, last_child,
showarrow, STEP_PREV, showarrow, STEP_PREV,
n, &remaining_space, &i, min, max); &remaining_space, &expanded_tabs, min, max);
} }
children = notebook->children; children = notebook->children;