gtkcolumnviewcolumn: Only create cells when the column is visible
It's a big performance drag to create many cells (and their associated widgets) for columns that may never be shown. Only create cells is the column is visible, and subsequently create/remove cells when in column_set_visible.
This commit is contained in:
@@ -65,10 +65,11 @@ gtk_column_list_item_factory_setup (GtkListItemFactory *factory,
|
|||||||
{
|
{
|
||||||
GtkColumnViewColumn *column = g_list_model_get_item (columns, i);
|
GtkColumnViewColumn *column = g_list_model_get_item (columns, i);
|
||||||
|
|
||||||
gtk_column_list_item_factory_add_column (self,
|
if (gtk_column_view_column_get_visible (column))
|
||||||
widget,
|
gtk_column_list_item_factory_add_column (self,
|
||||||
column,
|
widget,
|
||||||
FALSE);
|
column,
|
||||||
|
FALSE);
|
||||||
|
|
||||||
g_object_unref (column);
|
g_object_unref (column);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -579,7 +579,8 @@ gtk_column_view_column_remove_header (GtkColumnViewColumn *self)
|
|||||||
static void
|
static void
|
||||||
gtk_column_view_column_ensure_cells (GtkColumnViewColumn *self)
|
gtk_column_view_column_ensure_cells (GtkColumnViewColumn *self)
|
||||||
{
|
{
|
||||||
if (self->view && gtk_widget_get_root (GTK_WIDGET (self->view)))
|
if (self->view && gtk_widget_get_root (GTK_WIDGET (self->view)) &&
|
||||||
|
gtk_column_view_column_get_visible (self))
|
||||||
gtk_column_view_column_create_cells (self);
|
gtk_column_view_column_create_cells (self);
|
||||||
else
|
else
|
||||||
gtk_column_view_column_remove_cells (self);
|
gtk_column_view_column_remove_cells (self);
|
||||||
@@ -804,8 +805,6 @@ void
|
|||||||
gtk_column_view_column_set_visible (GtkColumnViewColumn *self,
|
gtk_column_view_column_set_visible (GtkColumnViewColumn *self,
|
||||||
gboolean visible)
|
gboolean visible)
|
||||||
{
|
{
|
||||||
GtkColumnViewCell *cell;
|
|
||||||
|
|
||||||
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
|
||||||
|
|
||||||
if (self->visible == visible)
|
if (self->visible == visible)
|
||||||
@@ -819,10 +818,7 @@ gtk_column_view_column_set_visible (GtkColumnViewColumn *self,
|
|||||||
if (self->header)
|
if (self->header)
|
||||||
gtk_widget_set_visible (GTK_WIDGET (self->header), visible);
|
gtk_widget_set_visible (GTK_WIDGET (self->header), visible);
|
||||||
|
|
||||||
for (cell = self->first_cell; cell; cell = gtk_column_view_cell_get_next (cell))
|
gtk_column_view_column_ensure_cells (self);
|
||||||
{
|
|
||||||
gtk_widget_set_visible (GTK_WIDGET (cell), visible);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VISIBLE]);
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VISIBLE]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user