summaryrefslogtreecommitdiff
path: root/gtk/gtktreeviewcolumn.c
diff options
context:
space:
mode:
authorJohn Lindgren <john.lindgren@aol.com>2012-12-18 02:06:12 -0500
committerBenjamin Otte <otte@redhat.com>2013-01-15 14:41:20 +0100
commit6d53c2339f79baa0b295ecc614f41f9daab2e132 (patch)
treeae594a275b5a440412c39512176b2fc7cec80861 /gtk/gtktreeviewcolumn.c
parent9b6661a0bfecf48eb5bbfbc853cd29d5daae1012 (diff)
downloadgtk+-6d53c2339f79baa0b295ecc614f41f9daab2e132.tar.gz
Use minimum/natural size semantics
Rewrites gtk_tree_view_column_request_width() and gtk_tree_view_size_allocate_columns() to respect the minimum and natural sizes that are already being returned by gtk_cell_area_context_get_preferred_width(). The convoluted logic explained (not!) by this comment has been removed: “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.” This logic seems to have been a workaround for the “jumping” behavior fixed in 16195ad and is no longer necessary. https://bugzilla.gnome.org/show_bug.cgi?id=691751
Diffstat (limited to 'gtk/gtktreeviewcolumn.c')
-rw-r--r--gtk/gtktreeviewcolumn.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/gtk/gtktreeviewcolumn.c b/gtk/gtktreeviewcolumn.c
index 6a47dbe89a..3f32c81312 100644
--- a/gtk/gtktreeviewcolumn.c
+++ b/gtk/gtktreeviewcolumn.c
@@ -2092,48 +2092,48 @@ gtk_tree_view_column_get_x_offset (GtkTreeViewColumn *tree_column)
return tree_column->priv->x_offset;
}
-gint
-_gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column)
+void
+_gtk_tree_view_column_request_width (GtkTreeViewColumn *tree_column,
+ gint *minimum,
+ gint *natural)
{
- GtkTreeViewColumnPrivate *priv;
- gint real_requested_width;
-
- priv = tree_column->priv;
+ GtkTreeViewColumnPrivate *priv = tree_column->priv;
+ gint minimum_width = 1, natural_width = 1;
+ gint button_minimum, button_natural;
- if (priv->fixed_width != -1)
- {
- real_requested_width = priv->fixed_width;
- }
- else if (gtk_tree_view_get_headers_visible (GTK_TREE_VIEW (priv->tree_view)))
+ if (priv->column_type != GTK_TREE_VIEW_COLUMN_FIXED)
{
- gint button_request;
- gint requested_width;
+ gtk_cell_area_context_get_preferred_width (priv->cell_area_context, &minimum_width, &natural_width);
+ minimum_width += priv->padding;
+ natural_width += priv->padding;
- gtk_cell_area_context_get_preferred_width (priv->cell_area_context, &requested_width, NULL);
- requested_width += priv->padding;
-
- gtk_widget_get_preferred_width (priv->button, &button_request, NULL);
- real_requested_width = MAX (requested_width, button_request);
+ if (gtk_tree_view_get_headers_visible (GTK_TREE_VIEW (priv->tree_view)))
+ {
+ gtk_widget_get_preferred_width (priv->button, &button_minimum, &button_natural);
+ minimum_width = MAX (minimum_width, button_minimum);
+ natural_width = MAX (natural_width, button_natural);
+ }
}
- else
- {
- gint requested_width;
- gtk_cell_area_context_get_preferred_width (priv->cell_area_context, &requested_width, NULL);
- requested_width += priv->padding;
-
- real_requested_width = requested_width;
- if (real_requested_width < 0)
- real_requested_width = 0;
- }
+ if (priv->fixed_width != -1)
+ natural_width = MAX (priv->fixed_width, minimum_width);
if (priv->min_width != -1)
- real_requested_width = MAX (real_requested_width, priv->min_width);
+ {
+ minimum_width = MAX (minimum_width, priv->min_width);
+ natural_width = MAX (natural_width, priv->min_width);
+ }
if (priv->max_width != -1)
- real_requested_width = MIN (real_requested_width, priv->max_width);
+ {
+ minimum_width = MIN (minimum_width, priv->max_width);
+ natural_width = MIN (natural_width, priv->max_width);
+ }
- return real_requested_width;
+ if (minimum != NULL)
+ *minimum = minimum_width;
+ if (natural != NULL)
+ *natural = natural_width;
}
void