[gtk] image: Avoid some unnecessary signal connections



commit c1e1e2da8012fcb975ddfa6170201408c2f51fc4
Author: Timm Bäder <mail baedert org>
Date:   Sun Dec 30 20:37:48 2018 +0100

    image: Avoid some unnecessary signal connections
    
    Equivalent if fd9879e5ffba2c58b897155b39ff79584b3618e0 but for GtkImage.

 gtk/gtkimage.c | 39 +++++++++++++++++++++++++--------------
 1 file changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 1546256341..20e9bc41e3 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -918,15 +918,21 @@ gtk_image_set_from_paintable (GtkImage     *image,
 
   if (paintable)
     {
+      const guint flags = gdk_paintable_get_flags (paintable);
+
       _gtk_icon_helper_set_paintable (priv->icon_helper, paintable);
-      g_signal_connect (paintable,
-                        "invalidate-contents",
-                        G_CALLBACK (gtk_image_paintable_invalidate_contents),
-                        image);
-      g_signal_connect (paintable,
-                        "invalidate-size",
-                        G_CALLBACK (gtk_image_paintable_invalidate_size),
-                        image);
+
+      if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
+        g_signal_connect (paintable,
+                          "invalidate-contents",
+                          G_CALLBACK (gtk_image_paintable_invalidate_contents),
+                          image);
+
+      if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
+        g_signal_connect (paintable,
+                          "invalidate-size",
+                          G_CALLBACK (gtk_image_paintable_invalidate_size),
+                          image);
       g_object_unref (paintable);
     }
 
@@ -1215,12 +1221,17 @@ gtk_image_clear (GtkImage *image)
   if (storage_type == GTK_IMAGE_PAINTABLE)
     {
       GdkPaintable *paintable = _gtk_icon_helper_peek_paintable (priv->icon_helper);
-      g_signal_handlers_disconnect_by_func (paintable,
-                                            gtk_image_paintable_invalidate_contents,
-                                            image);
-      g_signal_handlers_disconnect_by_func (paintable,
-                                            gtk_image_paintable_invalidate_size,
-                                            image);
+      const guint flags = gdk_paintable_get_flags (paintable);
+
+      if ((flags & GDK_PAINTABLE_STATIC_CONTENTS) == 0)
+        g_signal_handlers_disconnect_by_func (paintable,
+                                              gtk_image_paintable_invalidate_contents,
+                                              image);
+
+      if ((flags & GDK_PAINTABLE_STATIC_SIZE) == 0)
+        g_signal_handlers_disconnect_by_func (paintable,
+                                              gtk_image_paintable_invalidate_size,
+                                              image);
     }
 
   _gtk_icon_helper_clear (priv->icon_helper);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]