summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorBenjamin Otte <otte.benjamin@googlemail.com>2022-06-28 19:30:17 +0000
committerBenjamin Otte <otte.benjamin@googlemail.com>2022-06-28 19:30:17 +0000
commit672618e560e6ef76992fe4689d9c20a44a638e97 (patch)
tree4452cc3aae51e4e3ee5c78ddf21a0198f1e1255e /gtk
parente28516d1897b83c09402791c7e84b544a9f452ce (diff)
parentbe1729b316da53f12ccc16dc925c563acc2fb4c1 (diff)
downloadgtk+-672618e560e6ef76992fe4689d9c20a44a638e97.tar.gz
Merge branch 'wip/otte/for-main' into 'main'
Rework listitemfactory See merge request GNOME/gtk!4835
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkbuilderlistitemfactory.c12
-rw-r--r--gtk/gtkcolumnlistitemfactory.c40
-rw-r--r--gtk/gtklistitemfactory.c74
-rw-r--r--gtk/gtklistitemfactoryprivate.h41
-rw-r--r--gtk/gtklistitemwidget.c214
-rw-r--r--gtk/gtklistitemwidgetprivate.h10
-rw-r--r--gtk/gtkpicture.c70
-rw-r--r--gtk/gtksignallistitemfactory.c80
8 files changed, 310 insertions, 231 deletions
diff --git a/gtk/gtkbuilderlistitemfactory.c b/gtk/gtkbuilderlistitemfactory.c
index 19c95f2776..b28cf7197a 100644
--- a/gtk/gtkbuilderlistitemfactory.c
+++ b/gtk/gtkbuilderlistitemfactory.c
@@ -85,22 +85,24 @@ static GParamSpec *properties[N_PROPS] = { NULL, };
static void
gtk_builder_list_item_factory_setup (GtkListItemFactory *factory,
- GtkListItemWidget *widget,
- GtkListItem *list_item)
+ GObject *item,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
GtkBuilderListItemFactory *self = GTK_BUILDER_LIST_ITEM_FACTORY (factory);
GtkBuilder *builder;
GError *error = NULL;
- GTK_LIST_ITEM_FACTORY_CLASS (gtk_builder_list_item_factory_parent_class)->setup (factory, widget, list_item);
+ GTK_LIST_ITEM_FACTORY_CLASS (gtk_builder_list_item_factory_parent_class)->setup (factory, item, bind, func, data);
builder = gtk_builder_new ();
- gtk_builder_set_current_object (builder, G_OBJECT (list_item));
+ gtk_builder_set_current_object (builder, item);
if (self->scope)
gtk_builder_set_scope (builder, self->scope);
- if (!gtk_builder_extend_with_template (builder, G_OBJECT (list_item), G_OBJECT_TYPE (list_item),
+ if (!gtk_builder_extend_with_template (builder, G_OBJECT (item), G_OBJECT_TYPE (item),
(const char *)g_bytes_get_data (self->data, NULL),
g_bytes_get_size (self->data),
&error))
diff --git a/gtk/gtkcolumnlistitemfactory.c b/gtk/gtkcolumnlistitemfactory.c
index e6188cb4d4..9951a7c47a 100644
--- a/gtk/gtkcolumnlistitemfactory.c
+++ b/gtk/gtkcolumnlistitemfactory.c
@@ -43,10 +43,13 @@ G_DEFINE_TYPE (GtkColumnListItemFactory, gtk_column_list_item_factory, GTK_TYPE_
static void
gtk_column_list_item_factory_setup (GtkListItemFactory *factory,
- GtkListItemWidget *widget,
- GtkListItem *list_item)
+ GObject *item,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
GtkColumnListItemFactory *self = GTK_COLUMN_LIST_ITEM_FACTORY (factory);
+ GtkListItemWidget *widget = data;
GListModel *columns;
guint i;
@@ -54,7 +57,7 @@ gtk_column_list_item_factory_setup (GtkListItemFactory *factory,
gtk_widget_set_layout_manager (GTK_WIDGET (widget),
gtk_column_view_layout_new (self->view));
- GTK_LIST_ITEM_FACTORY_CLASS (gtk_column_list_item_factory_parent_class)->setup (factory, widget, list_item);
+ GTK_LIST_ITEM_FACTORY_CLASS (gtk_column_list_item_factory_parent_class)->setup (factory, item, bind, func, data);
columns = gtk_column_view_get_columns (self->view);
@@ -63,7 +66,7 @@ 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,
- list_item->owner,
+ widget,
column,
FALSE);
@@ -73,12 +76,15 @@ gtk_column_list_item_factory_setup (GtkListItemFactory *factory,
static void
gtk_column_list_item_factory_teardown (GtkListItemFactory *factory,
- GtkListItemWidget *widget,
- GtkListItem *list_item)
+ GObject *item,
+ gboolean unbind,
+ GFunc func,
+ gpointer data)
{
+ GtkListItemWidget *widget = data;
GtkWidget *child;
- GTK_LIST_ITEM_FACTORY_CLASS (gtk_column_list_item_factory_parent_class)->teardown (factory, widget, list_item);
+ GTK_LIST_ITEM_FACTORY_CLASS (gtk_column_list_item_factory_parent_class)->teardown (factory, item, unbind, func, data);
while ((child = gtk_widget_get_first_child (GTK_WIDGET (widget))))
{
@@ -88,21 +94,25 @@ gtk_column_list_item_factory_teardown (GtkListItemFactory *factory,
static void
gtk_column_list_item_factory_update (GtkListItemFactory *factory,
- GtkListItemWidget *widget,
- GtkListItem *list_item,
- guint position,
- gpointer item,
- gboolean selected)
+ GObject *item,
+ gboolean unbind,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
+ GtkListItem *list_item = GTK_LIST_ITEM (item);
GtkWidget *child;
- GTK_LIST_ITEM_FACTORY_CLASS (gtk_column_list_item_factory_parent_class)->update (factory, widget, list_item, position, item, selected);
+ GTK_LIST_ITEM_FACTORY_CLASS (gtk_column_list_item_factory_parent_class)->update (factory, item, unbind, bind, func, data);
- for (child = gtk_widget_get_first_child (GTK_WIDGET (widget));
+ for (child = gtk_widget_get_first_child (GTK_WIDGET (list_item->owner));
child;
child = gtk_widget_get_next_sibling (child))
{
- gtk_list_item_widget_update (GTK_LIST_ITEM_WIDGET (child), position, item, selected);
+ gtk_list_item_widget_update (GTK_LIST_ITEM_WIDGET (child),
+ gtk_list_item_get_position (list_item),
+ gtk_list_item_get_item (list_item),
+ gtk_list_item_get_selected (list_item));
}
}
diff --git a/gtk/gtklistitemfactory.c b/gtk/gtklistitemfactory.c
index 48383f29de..4d6d75d5a7 100644
--- a/gtk/gtklistitemfactory.c
+++ b/gtk/gtklistitemfactory.c
@@ -80,31 +80,36 @@ G_DEFINE_TYPE (GtkListItemFactory, gtk_list_item_factory, G_TYPE_OBJECT)
static void
gtk_list_item_factory_default_setup (GtkListItemFactory *self,
- GtkListItemWidget *widget,
- GtkListItem *list_item)
+ GObject *item,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
- gtk_list_item_widget_default_setup (widget, list_item);
+ if (func)
+ func (item, data);
}
static void
gtk_list_item_factory_default_teardown (GtkListItemFactory *self,
- GtkListItemWidget *widget,
- GtkListItem *list_item)
+ GObject *item,
+ gboolean unbind,
+ GFunc func,
+ gpointer data)
{
- gtk_list_item_widget_default_teardown (widget, list_item);
-
- gtk_list_item_set_child (list_item, NULL);
+ if (func)
+ func (item, data);
}
static void
gtk_list_item_factory_default_update (GtkListItemFactory *self,
- GtkListItemWidget *widget,
- GtkListItem *list_item,
- guint position,
- gpointer item,
- gboolean selected)
+ GObject *item,
+ gboolean unbind,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
- gtk_list_item_widget_default_update (widget, list_item, position, item, selected);
+ if (func)
+ func (item, data);
}
static void
@@ -122,45 +127,38 @@ gtk_list_item_factory_init (GtkListItemFactory *self)
void
gtk_list_item_factory_setup (GtkListItemFactory *self,
- GtkListItemWidget *widget)
+ GObject *item,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
- GtkListItem *list_item;
-
g_return_if_fail (GTK_IS_LIST_ITEM_FACTORY (self));
- list_item = gtk_list_item_new ();
-
- GTK_LIST_ITEM_FACTORY_GET_CLASS (self)->setup (self, widget, list_item);
+ GTK_LIST_ITEM_FACTORY_GET_CLASS (self)->setup (self, item, bind, func, data);
}
void
gtk_list_item_factory_teardown (GtkListItemFactory *self,
- GtkListItemWidget *widget)
+ GObject *item,
+ gboolean unbind,
+ GFunc func,
+ gpointer data)
{
- GtkListItem *list_item;
-
g_return_if_fail (GTK_IS_LIST_ITEM_FACTORY (self));
- list_item = gtk_list_item_widget_get_list_item (widget);
-
- GTK_LIST_ITEM_FACTORY_GET_CLASS (self)->teardown (self, widget, list_item);
-
- g_object_unref (list_item);
+ GTK_LIST_ITEM_FACTORY_GET_CLASS (self)->teardown (self, item, unbind, func, data);
}
void
gtk_list_item_factory_update (GtkListItemFactory *self,
- GtkListItemWidget *widget,
- guint position,
- gpointer item,
- gboolean selected)
+ GObject *item,
+ gboolean unbind,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
- GtkListItem *list_item;
-
g_return_if_fail (GTK_IS_LIST_ITEM_FACTORY (self));
- g_return_if_fail (GTK_IS_LIST_ITEM_WIDGET (widget));
-
- list_item = gtk_list_item_widget_get_list_item (widget);
+ g_return_if_fail (G_IS_OBJECT (item));
- GTK_LIST_ITEM_FACTORY_GET_CLASS (self)->update (self, widget, list_item, position, item, selected);
+ GTK_LIST_ITEM_FACTORY_GET_CLASS (self)->update (self, item, unbind, bind, func, data);
}
diff --git a/gtk/gtklistitemfactoryprivate.h b/gtk/gtklistitemfactoryprivate.h
index 3ee5e5f088..a860987231 100644
--- a/gtk/gtklistitemfactoryprivate.h
+++ b/gtk/gtklistitemfactoryprivate.h
@@ -37,33 +37,44 @@ struct _GtkListItemFactoryClass
/* setup @list_item so it can be bound */
void (* setup) (GtkListItemFactory *self,
- GtkListItemWidget *widget,
- GtkListItem *list_item);
+ GObject *item,
+ gboolean bind,
+ GFunc func,
+ gpointer data);
/* undo the effects of GtkListItemFactoryClass::setup() */
void (* teardown) (GtkListItemFactory *self,
- GtkListItemWidget *widget,
- GtkListItem *list_item);
+ GObject *item,
+ gboolean unbind,
+ GFunc func,
+ gpointer data);
/* Update properties on @list_item to the given @item, which is in @position and @selected state.
* One or more of those properties might be unchanged. */
void (* update) (GtkListItemFactory *self,
- GtkListItemWidget *widget,
- GtkListItem *list_item,
- guint position,
- gpointer item,
- gboolean selected);
+ GObject *item,
+ gboolean unbind,
+ gboolean bind,
+ GFunc func,
+ gpointer data);
};
void gtk_list_item_factory_setup (GtkListItemFactory *self,
- GtkListItemWidget *widget);
+ GObject *item,
+ gboolean bind,
+ GFunc func,
+ gpointer data);
void gtk_list_item_factory_teardown (GtkListItemFactory *self,
- GtkListItemWidget *widget);
+ GObject *item,
+ gboolean unbind,
+ GFunc func,
+ gpointer data);
void gtk_list_item_factory_update (GtkListItemFactory *self,
- GtkListItemWidget *widget,
- guint position,
- gpointer item,
- gboolean selected);
+ GObject *item,
+ gboolean unbind,
+ gboolean bind,
+ GFunc func,
+ gpointer data);
G_END_DECLS
diff --git a/gtk/gtklistitemwidget.c b/gtk/gtklistitemwidget.c
index fc407fbd83..c62b59f3a2 100644
--- a/gtk/gtklistitemwidget.c
+++ b/gtk/gtklistitemwidget.c
@@ -141,6 +141,85 @@ gtk_list_item_widget_grab_focus (GtkWidget *widget)
}
static void
+gtk_list_item_widget_setup_func (gpointer object,
+ gpointer data)
+{
+ GtkListItemWidget *self = data;
+ GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
+ GtkListItem *list_item = object;
+
+ priv->list_item = list_item;
+ list_item->owner = self;
+
+ if (list_item->child)
+ gtk_list_item_widget_add_child (self, list_item->child);
+
+ gtk_list_item_widget_set_activatable (self, list_item->activatable);
+
+ gtk_list_item_do_notify (list_item,
+ priv->item != NULL,
+ priv->position != GTK_INVALID_LIST_POSITION,
+ priv->selected);
+}
+
+static void
+gtk_list_item_widget_setup_factory (GtkListItemWidget *self)
+{
+ GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
+ GtkListItem *list_item;
+
+ list_item = gtk_list_item_new ();
+
+ gtk_list_item_factory_setup (priv->factory,
+ G_OBJECT (list_item),
+ priv->item != NULL,
+ gtk_list_item_widget_setup_func,
+ self);
+
+ g_assert (priv->list_item == list_item);
+}
+
+static void
+gtk_list_item_widget_teardown_func (gpointer object,
+ gpointer data)
+{
+ GtkListItemWidget *self = data;
+ GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
+ GtkListItem *list_item = object;
+
+ g_assert (priv->list_item == list_item);
+
+ priv->list_item = NULL;
+ list_item->owner = NULL;
+
+ if (list_item->child)
+ gtk_list_item_widget_remove_child (self, list_item->child);
+
+ gtk_list_item_widget_set_activatable (self, FALSE);
+
+ gtk_list_item_do_notify (list_item,
+ priv->item != NULL,
+ priv->position != GTK_INVALID_LIST_POSITION,
+ priv->selected);
+
+ gtk_list_item_set_child (list_item, NULL);
+}
+
+static void
+gtk_list_item_widget_teardown_factory (GtkListItemWidget *self)
+{
+ GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
+
+ gtk_list_item_factory_teardown (priv->factory,
+ G_OBJECT (priv->list_item),
+ priv->item != NULL,
+ gtk_list_item_widget_teardown_func,
+ self);
+
+ g_assert (priv->list_item == NULL);
+}
+
+static void
gtk_list_item_widget_root (GtkWidget *widget)
{
GtkListItemWidget *self = GTK_LIST_ITEM_WIDGET (widget);
@@ -149,7 +228,7 @@ gtk_list_item_widget_root (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_list_item_widget_parent_class)->root (widget);
if (priv->factory)
- gtk_list_item_factory_setup (priv->factory, self);
+ gtk_list_item_widget_setup_factory (self);
}
static void
@@ -161,7 +240,7 @@ gtk_list_item_widget_unroot (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_list_item_widget_parent_class)->unroot (widget);
if (priv->list_item)
- gtk_list_item_factory_teardown (priv->factory, self);
+ gtk_list_item_widget_teardown_factory (self);
}
static void
@@ -474,6 +553,45 @@ gtk_list_item_widget_new (GtkListItemFactory *factory,
NULL);
}
+typedef struct {
+ GtkListItemWidget *widget;
+ guint position;
+ gpointer item;
+ gboolean selected;
+} GtkListItemWidgetUpdate;
+
+static void
+gtk_list_item_widget_update_func (gpointer object,
+ gpointer data)
+{
+ GtkListItemWidgetUpdate *update = data;
+ GtkListItem *list_item = object;
+ /* Track notify manually instead of freeze/thaw_notify for performance reasons. */
+ gboolean notify_item = FALSE, notify_position = FALSE, notify_selected = FALSE;
+ GtkListItemWidget *self = update->widget;
+ GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
+
+ /* FIXME: It's kinda evil to notify external objects from here... */
+
+ if (g_set_object (&priv->item, update->item))
+ notify_item = TRUE;
+
+ if (priv->position != update->position)
+ {
+ priv->position = update->position;
+ notify_position = TRUE;
+ }
+
+ if (priv->selected != update->selected)
+ {
+ priv->selected = update->selected;
+ notify_selected = TRUE;
+ }
+
+ if (list_item)
+ gtk_list_item_do_notify (list_item, notify_item, notify_position, notify_selected);
+}
+
void
gtk_list_item_widget_update (GtkListItemWidget *self,
guint position,
@@ -481,14 +599,24 @@ gtk_list_item_widget_update (GtkListItemWidget *self,
gboolean selected)
{
GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
+ GtkListItemWidgetUpdate update = { self, position, item, selected };
gboolean was_selected;
was_selected = priv->selected;
if (priv->list_item)
- gtk_list_item_factory_update (priv->factory, self, position, item, selected);
+ {
+ gtk_list_item_factory_update (priv->factory,
+ G_OBJECT (priv->list_item),
+ priv->item != NULL,
+ item != NULL,
+ gtk_list_item_widget_update_func,
+ &update);
+ }
else
- gtk_list_item_widget_default_update (self, NULL, position, item, selected);
+ {
+ gtk_list_item_widget_update_func (NULL, &update);
+ }
/* don't look at selected variable, it's not reentrancy safe */
if (was_selected != priv->selected)
@@ -505,80 +633,6 @@ gtk_list_item_widget_update (GtkListItemWidget *self,
}
void
-gtk_list_item_widget_default_setup (GtkListItemWidget *self,
- GtkListItem *list_item)
-{
- GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
-
- priv->list_item = list_item;
- list_item->owner = self;
-
- if (list_item->child)
- gtk_list_item_widget_add_child (self, list_item->child);
-
- gtk_list_item_widget_set_activatable (self, list_item->activatable);
-
- gtk_list_item_do_notify (list_item,
- priv->item != NULL,
- priv->position != GTK_INVALID_LIST_POSITION,
- priv->selected);
-}
-
-void
-gtk_list_item_widget_default_teardown (GtkListItemWidget *self,
- GtkListItem *list_item)
-{
- GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
-
- g_assert (priv->list_item == list_item);
-
- priv->list_item = NULL;
- list_item->owner = NULL;
-
- if (list_item->child)
- gtk_list_item_widget_remove_child (self, list_item->child);
-
- gtk_list_item_widget_set_activatable (self, FALSE);
-
- gtk_list_item_do_notify (list_item,
- priv->item != NULL,
- priv->position != GTK_INVALID_LIST_POSITION,
- priv->selected);
-}
-
-void
-gtk_list_item_widget_default_update (GtkListItemWidget *self,
- GtkListItem *list_item,
- guint position,
- gpointer item,
- gboolean selected)
-{
- /* Track notify manually instead of freeze/thaw_notify for performance reasons. */
- gboolean notify_item = FALSE, notify_position = FALSE, notify_selected = FALSE;
- GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self);
-
- /* FIXME: It's kinda evil to notify external objects from here... */
-
- if (g_set_object (&priv->item, item))
- notify_item = TRUE;
-
- if (priv->position != position)
- {
- priv->position = position;
- notify_position = TRUE;
- }
-
- if (priv->selected != selected)
- {
- priv->selected = selected;
- notify_selected = TRUE;
- }
-
- if (list_item)
- gtk_list_item_do_notify (list_item, notify_item, notify_position, notify_selected);
-}
-
-void
gtk_list_item_widget_set_factory (GtkListItemWidget *self,
GtkListItemFactory *factory)
{
@@ -590,7 +644,7 @@ gtk_list_item_widget_set_factory (GtkListItemWidget *self,
if (priv->factory)
{
if (priv->list_item)
- gtk_list_item_factory_teardown (factory, self);
+ gtk_list_item_widget_teardown_factory (self);
g_clear_object (&priv->factory);
}
@@ -599,7 +653,7 @@ gtk_list_item_widget_set_factory (GtkListItemWidget *self,
priv->factory = g_object_ref (factory);
if (gtk_widget_get_root (GTK_WIDGET (self)))
- gtk_list_item_factory_setup (factory, self);
+ gtk_list_item_widget_setup_factory (self);
}
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FACTORY]);
diff --git a/gtk/gtklistitemwidgetprivate.h b/gtk/gtklistitemwidgetprivate.h
index eca2d21c6b..7ac53df413 100644
--- a/gtk/gtklistitemwidgetprivate.h
+++ b/gtk/gtklistitemwidgetprivate.h
@@ -59,16 +59,6 @@ void gtk_list_item_widget_update (GtkListItemWidg
gboolean selected);
GtkListItem * gtk_list_item_widget_get_list_item (GtkListItemWidget *self);
-void gtk_list_item_widget_default_setup (GtkListItemWidget *self,
- GtkListItem *list_item);
-void gtk_list_item_widget_default_teardown (GtkListItemWidget *self,
- GtkListItem *list_item);
-void gtk_list_item_widget_default_update (GtkListItemWidget *self,
- GtkListItem *list_item,
- guint position,
- gpointer item,
- gboolean selected);
-
void gtk_list_item_widget_set_factory (GtkListItemWidget *self,
GtkListItemFactory *factory);
void gtk_list_item_widget_set_single_click_activate
diff --git a/gtk/gtkpicture.c b/gtk/gtkpicture.c
index 8de6cc0832..0712d1844f 100644
--- a/gtk/gtkpicture.c
+++ b/gtk/gtkpicture.c
@@ -296,11 +296,48 @@ gtk_picture_get_property (GObject *object,
}
static void
+gtk_picture_paintable_invalidate_contents (GdkPaintable *paintable,
+ GtkPicture *self)
+{
+ gtk_widget_queue_draw (GTK_WIDGET (self));
+}
+
+static void
+gtk_picture_paintable_invalidate_size (GdkPaintable *paintable,
+ GtkPicture *self)
+{
+ gtk_widget_queue_resize (GTK_WIDGET (self));
+}
+
+static void
+gtk_picture_clear_paintable (GtkPicture *self)
+{
+ guint flags;
+
+ if (self->paintable == NULL)
+ return;
+
+ flags = gdk_paintable_get_flags (self->paintable);
+
+ if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
+ g_signal_handlers_disconnect_by_func (self->paintable,
+ gtk_picture_paintable_invalidate_contents,
+ self);
+
+ if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
+ g_signal_handlers_disconnect_by_func (self->paintable,
+ gtk_picture_paintable_invalidate_size,
+ self);
+
+ g_object_unref (self->paintable);
+}
+
+static void
gtk_picture_dispose (GObject *object)
{
GtkPicture *self = GTK_PICTURE (object);
- gtk_picture_set_paintable (self, NULL);
+ gtk_picture_clear_paintable (self);
g_clear_object (&self->file);
g_clear_pointer (&self->alternative_text, g_free);
@@ -707,20 +744,6 @@ gtk_picture_set_pixbuf (GtkPicture *self,
g_object_unref (texture);
}
-static void
-gtk_picture_paintable_invalidate_contents (GdkPaintable *paintable,
- GtkPicture *self)
-{
- gtk_widget_queue_draw (GTK_WIDGET (self));
-}
-
-static void
-gtk_picture_paintable_invalidate_size (GdkPaintable *paintable,
- GtkPicture *self)
-{
- gtk_widget_queue_resize (GTK_WIDGET (self));
-}
-
/**
* gtk_picture_set_paintable: (attributes org.gtk.Method.set_property=paintable)
* @self: a `GtkPicture`
@@ -747,22 +770,7 @@ gtk_picture_set_paintable (GtkPicture *self,
if (paintable)
g_object_ref (paintable);
- if (self->paintable)
- {
- const guint flags = gdk_paintable_get_flags (self->paintable);
-
- if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
- g_signal_handlers_disconnect_by_func (self->paintable,
- gtk_picture_paintable_invalidate_contents,
- self);
-
- if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
- g_signal_handlers_disconnect_by_func (self->paintable,
- gtk_picture_paintable_invalidate_size,
- self);
-
- g_object_unref (self->paintable);
- }
+ gtk_picture_clear_paintable (self);
self->paintable = paintable;
diff --git a/gtk/gtksignallistitemfactory.c b/gtk/gtksignallistitemfactory.c
index a2d0240ffe..923bc9c591 100644
--- a/gtk/gtksignallistitemfactory.c
+++ b/gtk/gtksignallistitemfactory.c
@@ -103,45 +103,49 @@ static guint signals[LAST_SIGNAL] = { 0 };
static void
gtk_signal_list_item_factory_setup (GtkListItemFactory *factory,
- GtkListItemWidget *widget,
- GtkListItem *list_item)
+ GObject *item,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
- g_signal_emit (factory, signals[SETUP], 0, list_item);
+ g_signal_emit (factory, signals[SETUP], 0, item);
- GTK_LIST_ITEM_FACTORY_CLASS (gtk_signal_list_item_factory_parent_class)->setup (factory, widget, list_item);
+ GTK_LIST_ITEM_FACTORY_CLASS (gtk_signal_list_item_factory_parent_class)->setup (factory, item, bind, func, data);
- if (gtk_list_item_get_item (list_item))
- g_signal_emit (factory, signals[BIND], 0, list_item);
+ if (bind)
+ g_signal_emit (factory, signals[BIND], 0, item);
}
static void
gtk_signal_list_item_factory_update (GtkListItemFactory *factory,
- GtkListItemWidget *widget,
- GtkListItem *list_item,
- guint position,
- gpointer item,
- gboolean selected)
+ GObject *item,
+ gboolean unbind,
+ gboolean bind,
+ GFunc func,
+ gpointer data)
{
- if (gtk_list_item_get_item (list_item))
- g_signal_emit (factory, signals[UNBIND], 0, list_item);
+ if (unbind)
+ g_signal_emit (factory, signals[UNBIND], 0, item);
- GTK_LIST_ITEM_FACTORY_CLASS (gtk_signal_list_item_factory_parent_class)->update (factory, widget, list_item, position, item, selected);
+ GTK_LIST_ITEM_FACTORY_CLASS (gtk_signal_list_item_factory_parent_class)->update (factory, item, unbind, bind, func, data);
- if (item)
- g_signal_emit (factory, signals[BIND], 0, list_item);
+ if (bind)
+ g_signal_emit (factory, signals[BIND], 0, item);
}
static void
gtk_signal_list_item_factory_teardown (GtkListItemFactory *factory,
- GtkListItemWidget *widget,
- GtkListItem *list_item)
+ GObject *item,
+ gboolean unbind,
+ GFunc func,
+ gpointer data)
{
- if (gtk_list_item_get_item (list_item))
- g_signal_emit (factory, signals[UNBIND], 0, list_item);
+ if (unbind)
+ g_signal_emit (factory, signals[UNBIND], 0, item);
- GTK_LIST_ITEM_FACTORY_CLASS (gtk_signal_list_item_factory_parent_class)->teardown (factory, widget, list_item);
+ GTK_LIST_ITEM_FACTORY_CLASS (gtk_signal_list_item_factory_parent_class)->teardown (factory, item, unbind, func, data);
- g_signal_emit (factory, signals[TEARDOWN], 0, list_item);
+ g_signal_emit (factory, signals[TEARDOWN], 0, item);
}
static void
@@ -156,7 +160,7 @@ gtk_signal_list_item_factory_class_init (GtkSignalListItemFactoryClass *klass)
/**
* GtkSignalListItemFactory::setup:
* @self: The `GtkSignalListItemFactory`
- * @listitem: The `GtkListItem` to set up
+ * @object: The `GObject` to set up
*
* Emitted when a new listitem has been created and needs to be setup for use.
*
@@ -173,7 +177,7 @@ gtk_signal_list_item_factory_class_init (GtkSignalListItemFactoryClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
- GTK_TYPE_LIST_ITEM);
+ G_TYPE_OBJECT);
g_signal_set_va_marshaller (signals[SETUP],
G_TYPE_FROM_CLASS (klass),
g_cclosure_marshal_VOID__OBJECTv);
@@ -181,13 +185,14 @@ gtk_signal_list_item_factory_class_init (GtkSignalListItemFactoryClass *klass)
/**
* GtkSignalListItemFactory::bind:
* @self: The `GtkSignalListItemFactory`
- * @listitem: The `GtkListItem` to bind
+ * @object: The `GObject` to bind
*
- * Emitted when a new [property@Gtk.ListItem:item] has been set
- * on the @listitem and should be bound for use.
+ * Emitted when an object has been bound, for example when a
+ * new [property@Gtk.ListItem:item] has been set on a
+ * `GtkListItem` and should be bound for use.
*
- * After this signal was emitted, the listitem might be shown in
- * a [class@Gtk.ListView] or other list widget.
+ * After this signal was emitted, the object might be shown in
+ * a [class@Gtk.ListView] or other widget.
*
* The [signal@Gtk.SignalListItemFactory::unbind] signal is the
* opposite of this signal and can be used to undo everything done
@@ -201,7 +206,7 @@ gtk_signal_list_item_factory_class_init (GtkSignalListItemFactoryClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
- GTK_TYPE_LIST_ITEM);
+ G_TYPE_OBJECT);
g_signal_set_va_marshaller (signals[BIND],
G_TYPE_FROM_CLASS (klass),
g_cclosure_marshal_VOID__OBJECTv);
@@ -209,9 +214,10 @@ gtk_signal_list_item_factory_class_init (GtkSignalListItemFactoryClass *klass)
/**
* GtkSignalListItemFactory::unbind:
* @self: The `GtkSignalListItemFactory`
- * @listitem: The `GtkListItem` to unbind
+ * @object: The `GObject` to unbind
*
- * Emitted when a listitem has been removed from use in a list widget
+ * Emitted when a object has been unbound from its item, for example when
+ * a listitem was removed from use in a list widget
* and its new [property@Gtk.ListItem:item] is about to be unset.
*
* This signal is the opposite of the [signal@Gtk.SignalListItemFactory::bind]
@@ -225,7 +231,7 @@ gtk_signal_list_item_factory_class_init (GtkSignalListItemFactoryClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
- GTK_TYPE_LIST_ITEM);
+ G_TYPE_OBJECT);
g_signal_set_va_marshaller (signals[UNBIND],
G_TYPE_FROM_CLASS (klass),
g_cclosure_marshal_VOID__OBJECTv);
@@ -233,11 +239,11 @@ gtk_signal_list_item_factory_class_init (GtkSignalListItemFactoryClass *klass)
/**
* GtkSignalListItemFactory::teardown:
* @self: The `GtkSignalListItemFactory`
- * @listitem: The `GtkListItem` to teardown
+ * @object: The `GObject` to tear down
*
- * Emitted when a listitem is about to be destroyed.
+ * Emitted when an object is about to be destroyed.
*
- * It is the last signal ever emitted for this @listitem.
+ * It is the last signal ever emitted for this @object.
*
* This signal is the opposite of the [signal@Gtk.SignalListItemFactory::setup]
* signal and should be used to undo everything done in that signal.
@@ -250,7 +256,7 @@ gtk_signal_list_item_factory_class_init (GtkSignalListItemFactoryClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
- GTK_TYPE_LIST_ITEM);
+ G_TYPE_OBJECT);
g_signal_set_va_marshaller (signals[TEARDOWN],
G_TYPE_FROM_CLASS (klass),
g_cclosure_marshal_VOID__OBJECTv);