[gtk+] Avoid excess notification for GdkCellRendererPixbuf::icon-size



commit 8d9414c228a0d518581184cb80f28f0a5d1caedc
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Dec 26 20:03:19 2017 -0500

    Avoid excess notification for GdkCellRendererPixbuf::icon-size
    
    We have a test that checks this, and it is right thing to do.

 gtk/gtkcellrendererpixbuf.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c
index d6a610c..b438ddc 100644
--- a/gtk/gtkcellrendererpixbuf.c
+++ b/gtk/gtkcellrendererpixbuf.c
@@ -198,7 +198,7 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
                                                      P_("The GtkIconSize value that specifies the size of 
the rendered icon"),
                                                       GTK_TYPE_ICON_SIZE,
                                                      GTK_ICON_SIZE_INHERIT,
-                                                     GTK_PARAM_READWRITE));
+                                                     GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
 
   /**
    * GtkCellRendererPixbuf:icon-name:
@@ -337,6 +337,19 @@ take_image_definition (GtkCellRendererPixbuf *cellpixbuf,
 }
 
 static void
+gtk_cell_renderer_pixbuf_set_icon_size (GtkCellRendererPixbuf *cellpixbuf,
+                                        GtkIconSize            icon_size)
+{
+  GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv;
+
+  if (priv->icon_size == icon_size)
+    return;
+
+  priv->icon_size = icon_size;
+  g_object_notify (G_OBJECT (cellpixbuf), "icon-size");
+}
+
+static void
 gtk_cell_renderer_pixbuf_set_property (GObject      *object,
                                       guint         param_id,
                                       const GValue *value,
@@ -373,7 +386,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject      *object,
       take_image_definition (cellpixbuf, gtk_image_definition_new_texture (g_value_get_object (value)));
       break;
     case PROP_ICON_SIZE:
-      priv->icon_size = g_value_get_enum (value);
+      gtk_cell_renderer_pixbuf_set_icon_size (cellpixbuf, g_value_get_enum (value));
       break;
     case PROP_ICON_NAME:
       take_image_definition (cellpixbuf, gtk_image_definition_new_icon_name (g_value_get_string (value)));


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