diff options
author | Timm Bäder <mail@baedert.org> | 2018-12-21 09:26:38 +0100 |
---|---|---|
committer | Timm Bäder <mail@baedert.org> | 2018-12-31 12:44:02 +0100 |
commit | b4f2a3416ecfd4fbc86606b8c72a60097112b042 (patch) | |
tree | 187e9c834c35d2fa756f2982a81d5d60294e6ab2 /gtk/gtkpicture.c | |
parent | 3b46e2a558f6db8dc500dcc268ba5a24324ca295 (diff) | |
download | gtk+-b4f2a3416ecfd4fbc86606b8c72a60097112b042.tar.gz |
picture: Avoid some unnecessary signal connections
We don't need to ever invalidate the picture size if the paintable tells
us its size is static. Same for the contents.
Diffstat (limited to 'gtk/gtkpicture.c')
-rw-r--r-- | gtk/gtkpicture.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/gtk/gtkpicture.c b/gtk/gtkpicture.c index ba81e517ab..1ae495c35d 100644 --- a/gtk/gtkpicture.c +++ b/gtk/gtkpicture.c @@ -798,26 +798,36 @@ gtk_picture_set_paintable (GtkPicture *self, if (self->paintable) { - g_signal_handlers_disconnect_by_func (self->paintable, - gtk_picture_paintable_invalidate_contents, - self); - g_signal_handlers_disconnect_by_func (self->paintable, - gtk_picture_paintable_invalidate_size, - self); + 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); } self->paintable = paintable; if (paintable) { - g_signal_connect (paintable, - "invalidate-contents", - G_CALLBACK (gtk_picture_paintable_invalidate_contents), - self); - g_signal_connect (paintable, - "invalidate-size", - G_CALLBACK (gtk_picture_paintable_invalidate_size), - self); + const guint flags = gdk_paintable_get_flags (paintable); + + if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0) + g_signal_connect (paintable, + "invalidate-contents", + G_CALLBACK (gtk_picture_paintable_invalidate_contents), + self); + + if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0) + g_signal_connect (paintable, + "invalidate-size", + G_CALLBACK (gtk_picture_paintable_invalidate_size), + self); } gtk_widget_queue_resize (GTK_WIDGET (self)); |