Make GtkTreeView tell the column about expand space instead of just assigning column->width.

Also modified the api to open up the way for treeview to tell the column
about how much of its size is really used to render the area.
This commit is contained in:
Tristan Van Berkom 2010-11-29 18:04:47 +09:00
parent 5729d2552b
commit b39521dcf7
3 changed files with 18 additions and 9 deletions

View File

@ -419,7 +419,8 @@ void _gtk_tree_view_column_unrealize_button (GtkTreeViewColumn *column);
void _gtk_tree_view_column_set_tree_view (GtkTreeViewColumn *column,
GtkTreeView *tree_view);
void _gtk_tree_view_column_set_width (GtkTreeViewColumn *column,
int width);
int width,
int internal_width);
void _gtk_tree_view_column_unset_model (GtkTreeViewColumn *column,
GtkTreeModel *old_model);
void _gtk_tree_view_column_unset_tree_view (GtkTreeViewColumn *column);

View File

@ -2360,6 +2360,7 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
list = (rtl ? list->prev : list->next))
{
gint real_requested_width = 0;
gint internal_column_width = 0;
gint old_width, column_width;
column = list->data;
@ -2387,7 +2388,6 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
real_requested_width = gtk_tree_view_get_real_requested_width_from_column (tree_view, column);
allocation.x = width;
_gtk_tree_view_column_set_width (column, real_requested_width);
if (gtk_tree_view_column_get_expand (column))
{
@ -2395,11 +2395,11 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
{
/* We add the remander to the last column as
* */
column->width += extra;
real_requested_width += extra;
}
else
{
column->width += extra_per_column;
real_requested_width += extra_per_column;
extra -= extra_per_column;
number_of_expand_columns --;
}
@ -2407,16 +2407,21 @@ gtk_tree_view_size_allocate_columns (GtkWidget *widget,
else if (number_of_expand_columns == 0 &&
list == last_column)
{
column->width += extra;
real_requested_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;
real_requested_width += extra_for_last;
g_object_notify (G_OBJECT (column), "width");
/* XXX This needs to account the real allocated space for
* the internal GtkCellArea
*/
internal_column_width = real_requested_width /* - all the stuff treeview adds around the area */;
_gtk_tree_view_column_set_width (column, real_requested_width, internal_column_width);
column_width = gtk_tree_view_column_get_width (column);
allocation.width = column_width;

View File

@ -1729,12 +1729,15 @@ gtk_tree_view_column_get_width (GtkTreeViewColumn *tree_column)
void
_gtk_tree_view_column_set_width (GtkTreeViewColumn *tree_column,
int width)
int width,
int internal_width)
{
g_return_if_fail (GTK_IS_TREE_VIEW_COLUMN (tree_column));
gtk_cell_area_context_allocate (tree_column->cell_area_context, width, -1);
gtk_cell_area_context_allocate (tree_column->cell_area_context, internal_width, -1);
tree_column->width = width;
g_object_notify (G_OBJECT (tree_column), "width");
}
/**