[gtk+] treeview: Don't underallocate editing widgets that are too big
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] treeview: Don't underallocate editing widgets that are too big
- Date: Tue, 21 Jul 2015 00:30:15 +0000 (UTC)
commit ceab99ff2ffcfd3f3e9644026ea9d4692cfbd11c
Author: Benjamin Otte <otte redhat com>
Date: Mon Jul 20 04:20:50 2015 +0200
treeview: Don't underallocate editing widgets that are too big
gtk/gtktreeview.c | 38 +++++++++++++++++++++++++-------------
1 files changed, 25 insertions(+), 13 deletions(-)
---
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 05ddece..a0286a7 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]