]> Pileus Git - ~andy/gtk/commitdiff
Add a note regarding icon theme changes.
authorMatthias Clasen <mclasen@redhat.com>
Mon, 22 Aug 2005 16:38:46 +0000 (16:38 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Mon, 22 Aug 2005 16:38:46 +0000 (16:38 +0000)
2005-08-22  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtkicontheme.c (gtk_icon_theme_load_icon): Add a note
regarding icon theme changes.

* gtk/gtkiconcache.c (_gtk_icon_cache_get_icon): When returning
pixbufs which are backed by the mmapped memory of an icon cache,
increase the refcount of the icon cache, so that the memory is not
munmapped away underneath the pixbuf upon icon theme changes.
(#314170, Kjartan Maraas)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-8
gtk/gtkiconcache.c
gtk/gtkicontheme.c

index cefda3d86868dae5f6fa4430935b6bb0d7d2c2fc..841ba490e0488622daf664fd9e4b5f84bfd0f24a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2005-08-22  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkicontheme.c (gtk_icon_theme_load_icon): Add a note
+       regarding icon theme changes.
+
+       * gtk/gtkiconcache.c (_gtk_icon_cache_get_icon): When returning
+       pixbufs which are backed by the mmapped memory of an icon cache,
+       increase the refcount of the icon cache, so that the memory is not
+       munmapped away underneath the pixbuf upon icon theme changes.  
+       (#314170, Kjartan Maraas)
+
        * docs/tools/Makefile.am (LDADDS): Add GTK_DEP_LIBS, in order 
        to link against Xext.  (#314062)
 
index cefda3d86868dae5f6fa4430935b6bb0d7d2c2fc..841ba490e0488622daf664fd9e4b5f84bfd0f24a 100644 (file)
@@ -1,5 +1,14 @@
 2005-08-22  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkicontheme.c (gtk_icon_theme_load_icon): Add a note
+       regarding icon theme changes.
+
+       * gtk/gtkiconcache.c (_gtk_icon_cache_get_icon): When returning
+       pixbufs which are backed by the mmapped memory of an icon cache,
+       increase the refcount of the icon cache, so that the memory is not
+       munmapped away underneath the pixbuf upon icon theme changes.  
+       (#314170, Kjartan Maraas)
+
        * docs/tools/Makefile.am (LDADDS): Add GTK_DEP_LIBS, in order 
        to link against Xext.  (#314062)
 
index cefda3d86868dae5f6fa4430935b6bb0d7d2c2fc..841ba490e0488622daf664fd9e4b5f84bfd0f24a 100644 (file)
@@ -1,5 +1,14 @@
 2005-08-22  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtkicontheme.c (gtk_icon_theme_load_icon): Add a note
+       regarding icon theme changes.
+
+       * gtk/gtkiconcache.c (_gtk_icon_cache_get_icon): When returning
+       pixbufs which are backed by the mmapped memory of an icon cache,
+       increase the refcount of the icon cache, so that the memory is not
+       munmapped away underneath the pixbuf upon icon theme changes.  
+       (#314170, Kjartan Maraas)
+
        * docs/tools/Makefile.am (LDADDS): Add GTK_DEP_LIBS, in order 
        to link against Xext.  (#314062)
 
index 8faca64a64960ef0d8a9f6fbc5d3912d332915c0..2af6958de786af13b0ef77821175e03fba16494c 100644 (file)
@@ -326,7 +326,16 @@ _gtk_icon_cache_has_icon (GtkIconCache *cache,
 
   return FALSE;
 }
-                         
+
+static void
+pixbuf_destroy_cb (guchar   *pixels, 
+                  gpointer  data)
+{
+  GtkIconCache *cache = data;
+
+  _gtk_icon_cache_unref (cache);
+}
+
 GdkPixbuf *
 _gtk_icon_cache_get_icon (GtkIconCache *cache,
                          const gchar  *icon_name,
@@ -371,6 +380,11 @@ _gtk_icon_cache_get_icon (GtkIconCache *cache,
 
   pixbuf = gdk_pixbuf_from_pixdata (&pixdata, FALSE, &error);
 
+  pixbuf = gdk_pixbuf_new_from_data (pixdata.pixel_data, GDK_COLORSPACE_RGB,
+                                    (pixdata.pixdata_type & GDK_PIXDATA_COLOR_TYPE_MASK) == GDK_PIXDATA_COLOR_TYPE_RGBA,
+                                    8, pixdata.width, pixdata.height, pixdata.rowstride,
+                                    (GdkPixbufDestroyNotify)pixbuf_destroy_cb, 
+                                    cache);
   if (!pixbuf)
     {
       GTK_NOTE (ICONTHEME,
@@ -380,6 +394,8 @@ _gtk_icon_cache_get_icon (GtkIconCache *cache,
       return NULL;
     }
 
+  _gtk_icon_cache_ref (cache);
+
   return pixbuf;
 }
 
index accdba51a3712f1583c7f5a822c048281afcea58..360a5c7b44740375e43b9fb6f59e4701bec4fdb2 100644 (file)
@@ -1304,6 +1304,14 @@ gtk_icon_theme_error_quark (void)
  * and renders it into a pixbuf. This is a convenience function;
  * if more details about the icon are needed, use
  * gtk_icon_theme_lookup_icon() followed by gtk_icon_info_load_icon().
+ *
+ * Note that you probably want to listen for icon theme changes and
+ * update the icon. This is usually done by connecting to the 
+ * GtkWidget::style-set signal. If for some reason you do not want to
+ * update the icon when the icon theme changes, you should consider
+ * using gdk_pixbuf_copy() to make a private copy of the pixbuf
+ * returned by this function. Otherwise GTK+ may need to keep the old 
+ * icon theme loaded, which would be a waste of memory.
  * 
  * Return value: the rendered icon; this may be a newly created icon
  *  or a new reference to an internal icon, so you must not modify