summaryrefslogtreecommitdiff
path: root/gtk/gtktreeview.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2015-07-20 04:20:50 +0200
committerBenjamin Otte <otte@redhat.com>2015-07-21 02:28:53 +0200
commitceab99ff2ffcfd3f3e9644026ea9d4692cfbd11c (patch)
tree6ab7d36d158a51dbcddcc5b755cc81f8d271aaa9 /gtk/gtktreeview.c
parent3402363684de5577b267c743029b2f4a8ef6a9da (diff)
downloadgtk+-ceab99ff2ffcfd3f3e9644026ea9d4692cfbd11c.tar.gz
treeview: Don't underallocate editing widgets that are too big
Diffstat (limited to 'gtk/gtktreeview.c')
-rw-r--r--gtk/gtktreeview.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 05ddece53b..a0286a7b3e 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -2947,19 +2947,35 @@ gtk_tree_view_size_allocate (GtkWidget *widget,
for (tmp_list = tree_view->priv->children; tmp_list; tmp_list = tmp_list->next)
{
GtkTreeViewChild *child = tmp_list->data;
- GtkAllocation child_allocation;
GtkTreePath *path;
- GdkRectangle rect;
+ GdkRectangle child_rect;
+ int size;
- /* totally ignore our child's requisition */
path = _gtk_tree_path_new_from_rbtree (child->tree, child->node);
- gtk_tree_view_get_cell_area (tree_view, path, child->column, &rect);
- child_allocation.x = rect.x + child->border.left;
- child_allocation.y = rect.y + child->border.top;
- child_allocation.width = rect.width - (child->border.left + child->border.right);
- child_allocation.height = rect.height - (child->border.top + child->border.bottom);
+ gtk_tree_view_get_cell_area (tree_view, path, child->column, &child_rect);
+ child_rect.x += child->border.left;
+ child_rect.y += child->border.right;
+ child_rect.width -= child->border.left + child->border.right;
+ child_rect.height -= child->border.top + child->border.bottom;
+
+ gtk_widget_get_preferred_width (GTK_WIDGET (child->widget), &size, NULL);
+ if (size > child_rect.width)
+ {
+ child_rect.x -= size / 2;
+ child_rect.width += size;
+ }
+
+ gtk_widget_get_preferred_height_for_width (GTK_WIDGET (child->widget),
+ child_rect.width,
+ &size, NULL);
+ if (size > child_rect.height)
+ {
+ child_rect.y -= size / 2;
+ child_rect.height += size;
+ }
+
gtk_tree_path_free (path);
- gtk_widget_size_allocate (child->widget, &child_allocation);
+ gtk_widget_size_allocate (child->widget, &child_rect);
}
}
@@ -15706,7 +15722,6 @@ _gtk_tree_view_add_editable (GtkTreeView *tree_view,
GtkCellEditable *cell_editable,
GdkRectangle *cell_area)
{
- GtkRequisition requisition;
GdkRectangle full_area;
GtkBorder border;
@@ -15714,9 +15729,6 @@ _gtk_tree_view_add_editable (GtkTreeView *tree_view,
gtk_tree_view_real_set_cursor (tree_view, path, CLAMP_NODE);
- gtk_widget_get_preferred_size (GTK_WIDGET (cell_editable),
- &requisition, NULL);
-
tree_view->priv->draw_keyfocus = TRUE;
gtk_tree_view_get_cell_area (tree_view, path, column, &full_area);