changeset 1706:fb6807b0ab0d

Limit the size of an HICN to 24x24 on GTK... icons are used for Tree and Container controls which on other platforms have limited size.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 05 May 2012 21:18:32 +0000
parents 3fa0448d3a7e
children 0b1be0a99f59
files gtk/dw.c gtk3/dw.c
diffstat 2 files changed, 36 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Sat May 05 20:13:43 2012 +0000
+++ b/gtk/dw.c	Sat May 05 21:18:32 2012 +0000
@@ -6959,6 +6959,23 @@
    return (HICN)id;
 }
 
+#if GTK_MAJOR_VERSION > 1
+/* Internal function to keep HICNs from getting too big */
+GdkPixbuf *_icon_resize(GdkPixbuf *ret)
+{
+   pwidth = gdk_pixbuf_get_width(ret);
+   pheight = gdk_pixbuf_get_height(ret);
+   
+   if(pwidth > 24 || pheight > 24)
+   {
+      GdkPixbuf *orig = ret;
+      ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR);
+      g_object_unref(G_OBJECT(orig));
+   }
+   return ret;
+}
+#endif
+
 /*
  * Obtains an icon from a file.
  * Parameters:
@@ -7036,7 +7053,7 @@
    }
 
 #if GTK_MAJOR_VERSION > 1
-   pixbuf = gdk_pixbuf_new_from_file(file, NULL);
+   pixbuf = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
    if (pixbuf)
    {
       _PixmapArray[found].pixbuf = pixbuf;
@@ -7137,7 +7154,7 @@
    }
 
 #if GTK_MAJOR_VERSION > 1
-   pixbuf = gdk_pixbuf_new_from_file(file, NULL);
+   pixbuf = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
    if (pixbuf)
    {
       _PixmapArray[found].pixbuf = pixbuf;
--- a/gtk3/dw.c	Sat May 05 20:13:43 2012 +0000
+++ b/gtk3/dw.c	Sat May 05 21:18:32 2012 +0000
@@ -5666,6 +5666,21 @@
    return (HICN)id;
 }
 
+/* Internal function to keep HICNs from getting too big */
+GdkPixbuf *_icon_resize(GdkPixbuf *ret)
+{
+   int pwidth = gdk_pixbuf_get_width(ret);
+   int pheight = gdk_pixbuf_get_height(ret);
+   
+   if(pwidth > 24 || pheight > 24)
+   {
+      GdkPixbuf *orig = ret;
+      ret = gdk_pixbuf_scale_simple(ret, pwidth > 24 ? 24 : pwidth, pheight > 24 ? 24 : pheight, GDK_INTERP_BILINEAR);
+      g_object_unref(G_OBJECT(orig));
+   }
+   return ret;
+}
+
 /*
  * Obtains an icon from a file.
  * Parameters:
@@ -5706,7 +5721,7 @@
    }
 
    DW_MUTEX_LOCK;
-   ret = gdk_pixbuf_new_from_file(file, NULL);
+   ret = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
    DW_MUTEX_UNLOCK;
    return ret;
 }
@@ -5740,7 +5755,7 @@
       return 0;
    }
    DW_MUTEX_LOCK;
-   ret = gdk_pixbuf_new_from_file(file, NULL);
+   ret = _icon_resize(gdk_pixbuf_new_from_file(file, NULL));
    DW_MUTEX_UNLOCK;
    return ret;
 }