[gtk+/spinner] Make it possible to set fix the size in pixbuf cells



commit 1ba3338ce75a4c6307fc80246cd19a87a2e21ee9
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri Jun 20 18:34:06 2014 -0400

    Make it possible to set fix the size in pixbuf cells
    
    The recent icon theme scaling changes make the code more
    sensitive to mis-sized icons (e.g. application icons in
    the app chooser). This can be avoided by passing the
    force-size flag while loading the icon. GtkIconHelper
    already does this if it has a pixel-size set. And
    GtkCellRenderer already has properties to set a fixed
    size. This change connects the two, and passes a fixed
    cell size on to the icon helper as pixel-size.

 gtk/gtkcellrendererpixbuf.c |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c
index 2271457..47a0b94 100644
--- a/gtk/gtkcellrendererpixbuf.c
+++ b/gtk/gtkcellrendererpixbuf.c
@@ -131,6 +131,24 @@ gtk_cell_renderer_pixbuf_finalize (GObject *object)
 }
 
 static void
+gtk_cell_renderer_pixbuf_notify (GObject    *object,
+                                 GParamSpec *pspec)
+{
+  GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object);
+  GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv;
+
+  if (strcmp (pspec->name, "width") == 0 || strcmp (pspec->name, "height") == 0)
+    {
+      gint w, h;
+      g_object_get (object, "width", &w, "height", &h, NULL);
+      _gtk_icon_helper_set_pixel_size (priv->icon_helper, MIN (w, h));
+    }
+
+  if (G_OBJECT_CLASS (gtk_cell_renderer_pixbuf_parent_class)->notify)
+    G_OBJECT_CLASS (gtk_cell_renderer_pixbuf_parent_class)->notify (object, pspec);
+}
+
+static void
 gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (class);
@@ -140,6 +158,7 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
 
   object_class->get_property = gtk_cell_renderer_pixbuf_get_property;
   object_class->set_property = gtk_cell_renderer_pixbuf_set_property;
+  object_class->notify = gtk_cell_renderer_pixbuf_notify;
 
   cell_class->get_size = gtk_cell_renderer_pixbuf_get_size;
   cell_class->render = gtk_cell_renderer_pixbuf_render;


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