Files
gtk2/debian/patches/033_treeview_resizing.patch
Josselin Mouette 9b8f38a76b * 033_treeview_resizing.patch:
+ Fix crasher introduced by the patch. Closes: #491611.
  + Add references.
2008-07-21 13:22:16 +00:00

260 lines
8.8 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

GNOME #316087.
Debian #471073, #491611.
Index: gtk+-2.12.11/gtk/gtktreeview.c
===================================================================
--- gtk+-2.12.11.orig/gtk/gtktreeview.c 2008-07-01 15:42:39.000000000 +0200
+++ gtk+-2.12.11/gtk/gtktreeview.c 2008-07-21 15:10:24.382008186 +0200
@@ -1364,6 +1364,8 @@
tree_view->priv->tree_lines_enabled = FALSE;
tree_view->priv->tooltip_column = -1;
+
+ tree_view->priv->post_validation_flag = FALSE;
}
@@ -1998,6 +2000,7 @@
tree_view->priv->prev_width = tree_view->priv->width;
tree_view->priv->width = 0;
+
/* keep this in sync with size_allocate below */
for (list = tree_view->priv->columns, i = 0; list; list = list->next, i++)
{
@@ -2164,18 +2167,20 @@
/* GtkWidget::size_allocate helper */
static void
-gtk_tree_view_size_allocate_columns (GtkWidget *widget)
+gtk_tree_view_size_allocate_columns (GtkWidget *widget,
+ gboolean *width_changed)
{
GtkTreeView *tree_view;
GList *list, *first_column, *last_column;
GtkTreeViewColumn *column;
GtkAllocation allocation;
gint width = 0;
- gint extra, extra_per_column;
+ gint extra, extra_per_column, extra_for_last;
gint full_requested_width = 0;
gint number_of_expand_columns = 0;
gboolean column_changed = FALSE;
gboolean rtl;
+ gboolean update_expand;
tree_view = GTK_TREE_VIEW (widget);
@@ -2210,12 +2215,42 @@
number_of_expand_columns++;
}
- extra = MAX (widget->allocation.width - full_requested_width, 0);
+ /* Only update the expand value if the width of the widget has changed,
+ * or the number of expand columns has changed, or if there are no expand
+ * columns, or if we didn't have an size-allocation yet after the
+ * last validated node.
+ */
+ update_expand = (width_changed && *width_changed == TRUE)
+ || number_of_expand_columns != tree_view->priv->last_number_of_expand_columns
+ || number_of_expand_columns == 0
+ || tree_view->priv->post_validation_flag == TRUE;
+
+ tree_view->priv->post_validation_flag = FALSE;
+
+ if (!update_expand)
+ {
+ extra = tree_view->priv->last_extra_space;
+ extra_for_last = MAX (widget->allocation.width - full_requested_width - extra, 0);
+ }
+ else
+ {
+ extra = MAX (widget->allocation.width - full_requested_width, 0);
+ extra_for_last = 0;
+
+ tree_view->priv->last_extra_space = extra;
+ }
+
if (number_of_expand_columns > 0)
extra_per_column = extra/number_of_expand_columns;
else
extra_per_column = 0;
+ if (update_expand)
+ {
+ tree_view->priv->last_extra_space_per_column = extra_per_column;
+ tree_view->priv->last_number_of_expand_columns = number_of_expand_columns;
+ }
+
for (list = (rtl ? last_column : first_column);
list != (rtl ? first_column->prev : last_column->next);
list = (rtl ? list->prev : list->next))
@@ -2271,6 +2306,12 @@
column->width += extra;
}
+ /* In addition to expand, the last column can get even more
+ * extra space so all available space is filled up.
+ */
+ if (extra_for_last > 0 && list == last_column)
+ column->width += extra_for_last;
+
g_object_notify (G_OBJECT (column), "width");
allocation.width = column->width;
@@ -2288,6 +2329,15 @@
TREE_VIEW_DRAG_WIDTH, allocation.height);
}
+ /* We change the width here. The user has been dragging columns,
+ * and we do need more width than allocated to properly display.
+ * The scrolled window should handle this, if the application
+ * doesn't have one, the tree view can't fit.
+ */
+ tree_view->priv->width = width;
+ if (width_changed)
+ *width_changed = TRUE;
+
if (column_changed)
gtk_widget_queue_draw (GTK_WIDGET (tree_view));
}
@@ -2328,6 +2378,7 @@
gtk_widget_size_allocate (child->widget, &allocation);
}
+ gtk_tree_view_size_allocate_columns (widget, &width_changed);
tree_view->priv->hadjustment->page_size = allocation->width;
tree_view->priv->hadjustment->page_increment = allocation->width * 0.9;
@@ -2336,28 +2387,30 @@
tree_view->priv->hadjustment->upper = MAX (tree_view->priv->hadjustment->page_size, tree_view->priv->width);
if (gtk_widget_get_direction(widget) == GTK_TEXT_DIR_RTL)
- {
+ {
if (allocation->width < tree_view->priv->width)
- {
- if (tree_view->priv->init_hadjust_value)
- {
- tree_view->priv->hadjustment->value = MAX (tree_view->priv->width - allocation->width, 0);
- tree_view->priv->init_hadjust_value = FALSE;
- }
- else if(allocation->width != old_width)
- tree_view->priv->hadjustment->value = CLAMP(tree_view->priv->hadjustment->value - allocation->width + old_width, 0, tree_view->priv->width - allocation->width);
- else
- tree_view->priv->hadjustment->value = CLAMP(tree_view->priv->width - (tree_view->priv->prev_width - tree_view->priv->hadjustment->value), 0, tree_view->priv->width - allocation->width);
- }
- else
- {
- tree_view->priv->hadjustment->value = 0;
- tree_view->priv->init_hadjust_value = TRUE;
- }
- }
+ {
+ if (tree_view->priv->init_hadjust_value)
+ {
+ tree_view->priv->hadjustment->value = MAX (tree_view->priv->width - allocation->width, 0);
+ tree_view->priv->init_hadjust_value = FALSE;
+ }
+ else if (allocation->width != old_width)
+ {
+ tree_view->priv->hadjustment->value = CLAMP (tree_view->priv->hadjustment->value - allocation->width + old_width, 0, tree_view->priv->width - allocation->width);
+ }
+ else
+ tree_view->priv->hadjustment->value = CLAMP (tree_view->priv->width - (tree_view->priv->prev_width - tree_view->priv->hadjustment->value), 0, tree_view->priv->width - allocation->width);
+ }
+ else
+ {
+ tree_view->priv->hadjustment->value = 0;
+ tree_view->priv->init_hadjust_value = TRUE;
+ }
+ }
else
- if (tree_view->priv->hadjustment->value + allocation->width > tree_view->priv->width)
- tree_view->priv->hadjustment->value = MAX (tree_view->priv->width - allocation->width, 0);
+ if (tree_view->priv->hadjustment->value + allocation->width > tree_view->priv->width)
+ tree_view->priv->hadjustment->value = MAX (tree_view->priv->width - allocation->width, 0);
gtk_adjustment_changed (tree_view->priv->hadjustment);
@@ -2397,8 +2450,6 @@
allocation->height - TREE_VIEW_HEADER_HEIGHT (tree_view));
}
- gtk_tree_view_size_allocate_columns (widget);
-
if (tree_view->priv->tree == NULL)
invalidate_empty_focus (tree_view);
@@ -2842,7 +2893,7 @@
gtk_grab_add (widget);
GTK_TREE_VIEW_SET_FLAG (tree_view, GTK_TREE_VIEW_IN_COLUMN_RESIZE);
- column->resized_width = column->width;
+ column->resized_width = column->width - tree_view->priv->last_extra_space_per_column;
/* block attached dnd signal handler */
drag_data = g_object_get_data (G_OBJECT (widget), "gtk-site-data");
@@ -3554,6 +3605,8 @@
{
column->use_resized_width = TRUE;
column->resized_width = new_width;
+ if (column->expand)
+ column->resized_width -= tree_view->priv->last_extra_space_per_column;
gtk_widget_queue_resize (widget);
}
@@ -5661,6 +5714,7 @@
_gtk_rbtree_node_set_height (tree, node, height);
}
_gtk_rbtree_node_mark_valid (tree, node);
+ tree_view->priv->post_validation_flag = TRUE;
return retval;
}
@@ -11516,7 +11570,7 @@
if (GTK_WIDGET_REALIZED (tree_view))
{
gtk_widget_queue_resize (GTK_WIDGET (tree_view));
- gtk_tree_view_size_allocate_columns (GTK_WIDGET (tree_view));
+ gtk_tree_view_size_allocate_columns (GTK_WIDGET (tree_view), NULL);
}
g_signal_emit (tree_view, tree_view_signals[COLUMNS_CHANGED], 0);
Index: gtk+-2.12.11/gtk/gtktreeviewcolumn.c
===================================================================
--- gtk+-2.12.11.orig/gtk/gtktreeviewcolumn.c 2008-07-01 15:42:39.000000000 +0200
+++ gtk+-2.12.11/gtk/gtktreeviewcolumn.c 2008-07-21 14:58:07.660991687 +0200
@@ -2141,6 +2141,7 @@
tree_column->tree_view != NULL &&
GTK_WIDGET_REALIZED (tree_column->tree_view))
{
+ tree_column->use_resized_width = FALSE;
gtk_widget_queue_resize (tree_column->tree_view);
}
Index: gtk+-2.12.11/gtk/gtktreeprivate.h
===================================================================
--- gtk+-2.12.11.orig/gtk/gtktreeprivate.h 2008-07-01 15:42:40.000000000 +0200
+++ gtk+-2.12.11/gtk/gtktreeprivate.h 2008-07-21 14:58:07.660991687 +0200
@@ -236,6 +236,8 @@
guint in_grab : 1;
+ guint post_validation_flag : 1;
+
/* Auto expand/collapse timeout in hover mode */
guint auto_expand_timeout;
@@ -268,6 +270,10 @@
GdkGC *tree_line_gc;
gint tooltip_column;
+
+ gint last_extra_space;
+ gint last_extra_space_per_column;
+ gint last_number_of_expand_columns;
};
#ifdef __GNUC__