Merge branch 'wip/corey/list-item-visible' into 'main'

listitemwidget: Setup factory only once the widget is visible

See merge request GNOME/gtk!5374
This commit is contained in:
Benjamin Otte 2022-12-29 22:21:43 +00:00
commit 188f9269b7
2 changed files with 8 additions and 11 deletions

View File

@ -65,10 +65,11 @@ gtk_column_list_item_factory_setup (GtkListItemFactory *factory,
{
GtkColumnViewColumn *column = g_list_model_get_item (columns, i);
gtk_column_list_item_factory_add_column (self,
widget,
column,
FALSE);
if (gtk_column_view_column_get_visible (column))
gtk_column_list_item_factory_add_column (self,
widget,
column,
FALSE);
g_object_unref (column);
}

View File

@ -579,7 +579,8 @@ gtk_column_view_column_remove_header (GtkColumnViewColumn *self)
static void
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);
else
gtk_column_view_column_remove_cells (self);
@ -804,8 +805,6 @@ void
gtk_column_view_column_set_visible (GtkColumnViewColumn *self,
gboolean visible)
{
GtkColumnViewCell *cell;
g_return_if_fail (GTK_IS_COLUMN_VIEW_COLUMN (self));
if (self->visible == visible)
@ -819,10 +818,7 @@ gtk_column_view_column_set_visible (GtkColumnViewColumn *self,
if (self->header)
gtk_widget_set_visible (GTK_WIDGET (self->header), visible);
for (cell = self->first_cell; cell; cell = gtk_column_view_cell_get_next (cell))
{
gtk_widget_set_visible (GTK_WIDGET (cell), visible);
}
gtk_column_view_column_ensure_cells (self);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_VISIBLE]);
}