listfactorywidget: Stop trying to be smart

The widget would teardown the factory on unroot to avoid unnecessary
work when it isn't shown.

However, recycling may reposition widgets, and repositioning widgets
does a unroot/root.

We don't want to recycle widgets then.
This commit is contained in:
Benjamin Otte 2023-03-27 04:53:48 +02:00
parent 924fd195ab
commit 3fb10ff2d8

View File

@ -204,30 +204,6 @@ gtk_list_factory_widget_update (GtkListItemBase *base,
} }
} }
static void
gtk_list_factory_widget_root (GtkWidget *widget)
{
GtkListFactoryWidget *self = GTK_LIST_FACTORY_WIDGET (widget);
GtkListFactoryWidgetPrivate *priv = gtk_list_factory_widget_get_instance_private (self);
GTK_WIDGET_CLASS (gtk_list_factory_widget_parent_class)->root (widget);
if (priv->factory)
gtk_list_factory_widget_setup_factory (self);
}
static void
gtk_list_factory_widget_unroot (GtkWidget *widget)
{
GtkListFactoryWidget *self = GTK_LIST_FACTORY_WIDGET (widget);
GtkListFactoryWidgetPrivate *priv = gtk_list_factory_widget_get_instance_private (self);
GTK_WIDGET_CLASS (gtk_list_factory_widget_parent_class)->unroot (widget);
if (priv->object)
gtk_list_factory_widget_teardown_factory (self);
}
static void static void
gtk_list_factory_widget_set_property (GObject *object, gtk_list_factory_widget_set_property (GObject *object,
guint property_id, guint property_id,
@ -260,15 +236,25 @@ gtk_list_factory_widget_set_property (GObject *object,
} }
} }
static void
gtk_list_factory_widget_clear_factory (GtkListFactoryWidget *self)
{
GtkListFactoryWidgetPrivate *priv = gtk_list_factory_widget_get_instance_private (self);
if (priv->factory == NULL)
return;
if (priv->object)
gtk_list_factory_widget_teardown_factory (self);
g_clear_object (&priv->factory);
}
static void static void
gtk_list_factory_widget_dispose (GObject *object) gtk_list_factory_widget_dispose (GObject *object)
{ {
GtkListFactoryWidget *self = GTK_LIST_FACTORY_WIDGET (object); GtkListFactoryWidget *self = GTK_LIST_FACTORY_WIDGET (object);
GtkListFactoryWidgetPrivate *priv = gtk_list_factory_widget_get_instance_private (self);
g_assert (priv->object == NULL); gtk_list_factory_widget_clear_factory (self);
g_clear_object (&priv->factory);
G_OBJECT_CLASS (gtk_list_factory_widget_parent_class)->dispose (object); G_OBJECT_CLASS (gtk_list_factory_widget_parent_class)->dispose (object);
} }
@ -319,9 +305,6 @@ gtk_list_factory_widget_class_init (GtkListFactoryWidgetClass *klass)
base_class->update = gtk_list_factory_widget_update; base_class->update = gtk_list_factory_widget_update;
widget_class->root = gtk_list_factory_widget_root;
widget_class->unroot = gtk_list_factory_widget_unroot;
gobject_class->set_property = gtk_list_factory_widget_set_property; gobject_class->set_property = gtk_list_factory_widget_set_property;
gobject_class->dispose = gtk_list_factory_widget_dispose; gobject_class->dispose = gtk_list_factory_widget_dispose;
@ -553,19 +536,13 @@ gtk_list_factory_widget_set_factory (GtkListFactoryWidget *self,
if (priv->factory == factory) if (priv->factory == factory)
return; return;
if (priv->factory) gtk_list_factory_widget_clear_factory (self);
{
if (priv->object)
gtk_list_factory_widget_teardown_factory (self);
g_clear_object (&priv->factory);
}
if (factory) if (factory)
{ {
priv->factory = g_object_ref (factory); priv->factory = g_object_ref (factory);
if (gtk_widget_get_root (GTK_WIDGET (self))) gtk_list_factory_widget_setup_factory (self);
gtk_list_factory_widget_setup_factory (self);
} }
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FACTORY]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FACTORY]);