]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkicontheme.c
Display an error when we come to the root.
[~andy/gtk] / gtk / gtkicontheme.c
index 3b439cc87ea7fcdb946dc049c7ed4cd83bdd6f08..92270bc459dfb13ad9eb8995174c250a73d80d95 100644 (file)
@@ -40,6 +40,7 @@
 #include "gtkiconcache.h"
 #include "gtkbuiltincache.h"
 #include "gtkintl.h"
+#include "gtkmain.h"
 #include "gtksettings.h"
 #include "gtkprivate.h"
 #include "gtkalias.h"
@@ -67,15 +68,17 @@ typedef enum
 
 struct _GtkIconThemePrivate
 {
-  guint custom_theme : 1;
+  guint custom_theme        : 1;
   guint is_screen_singleton : 1;
   guint pixbuf_supports_svg : 1;
+  guint themes_valid        : 1;
+  guint check_reload        : 1;
   
   char *current_theme;
+  char *fallback_theme;
   char **search_path;
   int search_path_len;
 
-  gboolean themes_valid;
   /* A list of all the themes needed to look up icons.
    * In search order, without duplicates
    */
@@ -96,8 +99,6 @@ struct _GtkIconThemePrivate
   GList *dir_mtimes;
 
   gulong reset_styles_idle;
-
-  gboolean check_reload;
 };
 
 struct _GtkIconInfo
@@ -186,8 +187,6 @@ typedef struct
   GtkIconCache *cache;
 } IconThemeDirMtime;
 
-static void  gtk_icon_theme_class_init (GtkIconThemeClass    *klass);
-static void  gtk_icon_theme_init       (GtkIconTheme         *icon_theme);
 static void  gtk_icon_theme_finalize   (GObject              *object);
 static void  theme_dir_destroy         (IconThemeDir         *dir);
 
@@ -228,8 +227,6 @@ static BuiltinIcon *find_builtin_icon (const gchar *icon_name,
                                       gint        *min_difference_p,
                                       gboolean    *has_larger_p);
 
-static GObjectClass *parent_class = NULL;
-
 static guint signal_changed = 0;
 
 static GHashTable *icon_theme_builtin_icons;
@@ -238,32 +235,7 @@ static GHashTable *icon_theme_builtin_icons;
 GtkIconCache *_builtin_cache = NULL;
 static GList *builtin_dirs = NULL;
 
-
-GType
-gtk_icon_theme_get_type (void)
-{
-  static GType type = 0;
-
-  if (type == 0)
-    {
-      static const GTypeInfo info =
-       {
-         sizeof (GtkIconThemeClass),
-         NULL,           /* base_init */
-         NULL,           /* base_finalize */
-         (GClassInitFunc) gtk_icon_theme_class_init,
-         NULL,           /* class_finalize */
-         NULL,           /* class_data */
-         sizeof (GtkIconTheme),
-         0,              /* n_preallocs */
-         (GInstanceInitFunc) gtk_icon_theme_init,
-       };
-
-      type = g_type_register_static (G_TYPE_OBJECT, I_("GtkIconTheme"), &info, 0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (GtkIconTheme, gtk_icon_theme, G_TYPE_OBJECT)
 
 /**
  * gtk_icon_theme_new:
@@ -353,8 +325,6 @@ gtk_icon_theme_class_init (GtkIconThemeClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
 
-  parent_class = g_type_class_peek_parent (klass);
-
   gobject_class->finalize = gtk_icon_theme_finalize;
 
 /**
@@ -412,11 +382,15 @@ update_current_theme (GtkIconTheme *icon_theme)
   if (!priv->custom_theme)
     {
       gchar *theme = NULL;
+      gchar *fallback_theme = NULL;
+      gboolean changed = FALSE;
 
       if (priv->screen)
        {
          GtkSettings *settings = gtk_settings_get_for_screen (priv->screen);
-         g_object_get (settings, "gtk-icon-theme-name", &theme, NULL);
+         g_object_get (settings, 
+                       "gtk-icon-theme-name", &theme, 
+                       "gtk-fallback-icon-theme", &fallback_theme, NULL);
        }
 
       if (!theme)
@@ -427,10 +401,26 @@ update_current_theme (GtkIconTheme *icon_theme)
          g_free (priv->current_theme);
          priv->current_theme = theme;
 
-         do_theme_change (icon_theme);
+         changed = TRUE;
        }
       else
        g_free (theme);
+
+      if ((priv->fallback_theme && !fallback_theme) ||
+         (!priv->fallback_theme && fallback_theme) ||
+         (priv->fallback_theme && fallback_theme &&
+          strcmp (priv->fallback_theme, fallback_theme) != 0))
+       {
+         g_free (priv->fallback_theme);
+         priv->fallback_theme = fallback_theme;
+
+         changed = TRUE;
+       }
+      else
+       g_free (fallback_theme);
+
+      if (changed)
+       do_theme_change (icon_theme);
     }
 }
 
@@ -504,6 +494,8 @@ gtk_icon_theme_set_screen (GtkIconTheme *icon_theme,
                        G_CALLBACK (display_closed), icon_theme);
       g_signal_connect (settings, "notify::gtk-icon-theme-name",
                        G_CALLBACK (theme_changed), icon_theme);
+      g_signal_connect (settings, "notify::gtk-fallback-icon-theme-name",
+                       G_CALLBACK (theme_changed), icon_theme);
     }
 
   update_current_theme (icon_theme);
@@ -517,12 +509,12 @@ pixbuf_supports_svg (void)
 {
   GSList *formats = gdk_pixbuf_get_formats ();
   GSList *tmp_list;
-  static gboolean found_svg = FALSE;
-  static gboolean value_known = FALSE;
+  static gint found_svg = -1;
 
-  if (value_known)
+  if (found_svg != -1)
     return found_svg;
-  
+  found_svg = FALSE; 
   for (tmp_list = formats; tmp_list && !found_svg; tmp_list = tmp_list->next)
     {
       gchar **mime_types = gdk_pixbuf_format_get_mime_types (tmp_list->data);
@@ -538,7 +530,6 @@ pixbuf_supports_svg (void)
     }
 
   g_slist_free (formats);
-  value_known = TRUE;
   
   return found_svg;
 }
@@ -588,7 +579,7 @@ free_dir_mtime (IconThemeDirMtime *dir_mtime)
     _gtk_icon_cache_unref (dir_mtime->cache);
 
   g_free (dir_mtime->dir);
-  g_free (dir_mtime);
+  g_slice_free (IconThemeDirMtime, dir_mtime);
 
 }
 
@@ -628,7 +619,8 @@ do_theme_change (GtkIconTheme *icon_theme)
 
   if (!priv->reset_styles_idle)
     priv->reset_styles_idle = 
-      g_idle_add (reset_styles_idle, icon_theme);
+      g_idle_add_full (GTK_PRIORITY_RESIZE - 2, 
+                      reset_styles_idle, icon_theme, NULL);
 }
 
 static void
@@ -673,7 +665,7 @@ gtk_icon_theme_finalize (GObject *object)
   g_free (priv->current_theme);
   priv->current_theme = NULL;
 
-  for (i=0; i < priv->search_path_len; i++)
+  for (i = 0; i < priv->search_path_len; i++)
     g_free (priv->search_path[i]);
 
   g_free (priv->search_path);
@@ -681,7 +673,7 @@ gtk_icon_theme_finalize (GObject *object)
 
   blow_themes (icon_theme);
 
-  G_OBJECT_CLASS (parent_class)->finalize (object);  
+  G_OBJECT_CLASS (gtk_icon_theme_parent_class)->finalize (object);  
 }
 
 /**
@@ -725,6 +717,7 @@ gtk_icon_theme_set_search_path (GtkIconTheme *icon_theme,
 
   priv->search_path = g_new (gchar *, n_elements);
   priv->search_path_len = n_elements;
+
   for (i = 0; i < priv->search_path_len; i++)
     priv->search_path[i] = g_strdup (path[i]);
 
@@ -790,6 +783,7 @@ gtk_icon_theme_append_search_path (GtkIconTheme *icon_theme,
   priv = icon_theme->priv;
   
   priv->search_path_len++;
+
   priv->search_path = g_renew (gchar *, priv->search_path, priv->search_path_len);
   priv->search_path[priv->search_path_len-1] = g_strdup (path);
 
@@ -902,7 +896,7 @@ insert_theme (GtkIconTheme *icon_theme, const char *theme_name)
       path = g_build_filename (priv->search_path[i],
                               theme_name,
                               NULL);
-      dir_mtime = g_new (IconThemeDirMtime, 1);
+      dir_mtime = g_slice_new (IconThemeDirMtime);
       dir_mtime->cache = NULL;
       dir_mtime->dir = path;
       if (g_stat (path, &stat_buf) == 0 && S_ISDIR (stat_buf.st_mode))
@@ -937,19 +931,20 @@ insert_theme (GtkIconTheme *icon_theme, const char *theme_name)
       g_free (path);
     }
 
+  if (theme_file || strcmp (theme_name, DEFAULT_THEME_NAME) == 0)
+    {
+      theme = g_new0 (IconTheme, 1);
+      theme->name = g_strdup (theme_name);
+      priv->themes = g_list_prepend (priv->themes, theme);
+    }
+
   if (theme_file == NULL)
     return;
-  
-  theme = g_new (IconTheme, 1);
+
   theme->display_name = 
     g_key_file_get_locale_string (theme_file, "Icon Theme", "Name", NULL, NULL);
   if (!theme->display_name)
-    {
-      g_warning ("Theme file for %s has no name\n", theme_name);
-      g_free (theme);
-      g_key_file_free (theme_file);
-      return;
-    }
+    g_warning ("Theme file for %s has no name\n", theme_name);
 
   dirs = g_key_file_get_string_list (theme_file, "Icon Theme", "Directories", NULL, NULL);
   if (!dirs)
@@ -961,7 +956,6 @@ insert_theme (GtkIconTheme *icon_theme, const char *theme_name)
       return;
     }
   
-  theme->name = g_strdup (theme_name);
   theme->comment = 
     g_key_file_get_locale_string (theme_file, 
                                  "Icon Theme", "Comment",
@@ -974,13 +968,10 @@ insert_theme (GtkIconTheme *icon_theme, const char *theme_name)
   theme->dirs = NULL;
   for (i = 0; dirs[i] != NULL; i++)
     theme_subdir_load (icon_theme, theme, theme_file, dirs[i]);
-  
+
   g_strfreev (dirs);
-  
-  theme->dirs = g_list_reverse (theme->dirs);
 
-  /* Prepend the finished theme */
-  priv->themes = g_list_prepend (priv->themes, theme);
+  theme->dirs = g_list_reverse (theme->dirs);
 
   themes = g_key_file_get_string_list (theme_file,
                                       "Icon Theme",
@@ -1005,7 +996,20 @@ free_unthemed_icon (UnthemedIcon *unthemed_icon)
     g_free (unthemed_icon->svg_filename);
   if (unthemed_icon->no_svg_filename)
     g_free (unthemed_icon->no_svg_filename);
-  g_free (unthemed_icon);
+  g_slice_free (UnthemedIcon, unthemed_icon);
+}
+
+static char *
+strip_suffix (const char *filename)
+{
+  const char *dot;
+
+  dot = strrchr (filename, '.');
+
+  if (dot == NULL)
+    return g_strdup (filename);
+
+  return g_strndup (filename, dot - filename);
 }
 
 static void
@@ -1014,9 +1018,8 @@ load_themes (GtkIconTheme *icon_theme)
   GtkIconThemePrivate *priv;
   GDir *gdir;
   int base;
-  char *dir, *base_name, *dot;
+  char *dir;
   const char *file;
-  char *abs_file;
   UnthemedIcon *unthemed_icon;
   IconSuffix old_suffix, new_suffix;
   GTimeVal tv;
@@ -1028,8 +1031,10 @@ load_themes (GtkIconTheme *icon_theme)
   priv->all_icons = g_hash_table_new (g_str_hash, g_str_equal);
   
   insert_theme (icon_theme, priv->current_theme);
-  
-  /* Always look in the "default" icon theme */
+
+  /* Always look in the "default" icon theme, and in a fallback theme */
+  if (priv->fallback_theme)
+    insert_theme (icon_theme, priv->fallback_theme);
   insert_theme (icon_theme, DEFAULT_THEME_NAME);
   priv->themes = g_list_reverse (priv->themes);
 
@@ -1041,16 +1046,16 @@ load_themes (GtkIconTheme *icon_theme)
     {
       dir = icon_theme->priv->search_path[base];
 
-      dir_mtime = g_new (IconThemeDirMtime, 1);
+      dir_mtime = g_slice_new (IconThemeDirMtime);
       dir_mtime->cache = _gtk_icon_cache_new_for_path (dir);
       dir_mtime->dir = g_strdup (dir);
       if (g_stat (dir, &stat_buf) == 0 && S_ISDIR (stat_buf.st_mode))
        dir_mtime->mtime = stat_buf.st_mtime;
       else
        dir_mtime->mtime = 0;
-
+      
       priv->dir_mtimes = g_list_append (priv->dir_mtimes, dir_mtime);
-
+      
       if (dir_mtime->cache != NULL)
        continue;
 
@@ -1058,20 +1063,18 @@ load_themes (GtkIconTheme *icon_theme)
 
       if (gdir == NULL)
        continue;
-      
+
       while ((file = g_dir_read_name (gdir)))
        {
          new_suffix = suffix_from_name (file);
-
+         
          if (new_suffix != ICON_SUFFIX_NONE)
            {
-             abs_file = g_build_filename (dir, file, NULL);
+             char *abs_file;
+             char *base_name;
 
-             base_name = g_strdup (file);
-                 
-             dot = strrchr (base_name, '.');
-             if (dot)
-               *dot = 0;
+             abs_file = g_build_filename (dir, file, NULL);
+             base_name = strip_suffix (file);
 
              if ((unthemed_icon = g_hash_table_lookup (priv->unthemed_icons,
                                                        base_name)))
@@ -1104,7 +1107,7 @@ load_themes (GtkIconTheme *icon_theme)
                }
              else
                {
-                 unthemed_icon = g_new0 (UnthemedIcon, 1);
+                 unthemed_icon = g_slice_new0 (UnthemedIcon);
                  
                  if (new_suffix == ICON_SUFFIX_SVG)
                    unthemed_icon->svg_filename = abs_file;
@@ -1128,11 +1131,45 @@ load_themes (GtkIconTheme *icon_theme)
   priv->last_stat_time = tv.tv_sec;
 }
 
+void
+_gtk_icon_theme_ensure_builtin_cache (void)
+{
+  static gboolean initialized = FALSE;
+  IconThemeDir *dir;
+  static IconThemeDir dirs[5] = 
+    {
+      { ICON_THEME_DIR_THRESHOLD, 0, 16, 16, 16, 2, NULL, "16", NULL, NULL, NULL },
+      { ICON_THEME_DIR_THRESHOLD, 0, 20, 20, 20, 2, NULL, "20", NULL, NULL, NULL },
+      { ICON_THEME_DIR_THRESHOLD, 0, 24, 24, 24, 2, NULL, "24", NULL, NULL, NULL },
+      { ICON_THEME_DIR_THRESHOLD, 0, 32, 32, 32, 2, NULL, "32", NULL, NULL, NULL },
+      { ICON_THEME_DIR_THRESHOLD, 0, 48, 48, 48, 2, NULL, "48", NULL, NULL, NULL }
+    };
+  gint i;
+
+  if (!initialized)
+    {
+      initialized = TRUE;
+
+      _builtin_cache = _gtk_icon_cache_new ((gchar *)builtin_icons);
+
+      for (i = 0; i < G_N_ELEMENTS (dirs); i++)
+       {
+         dir = &(dirs[i]);
+         dir->cache = _gtk_icon_cache_ref (_builtin_cache);
+
+         builtin_dirs = g_list_append (builtin_dirs, dir);
+       }
+    }
+}
+
 static void
 ensure_valid_themes (GtkIconTheme *icon_theme)
 {
   GtkIconThemePrivate *priv = icon_theme->priv;
   GTimeVal tv;
+  gboolean was_valid = priv->themes_valid;
+
+  _gtk_icon_theme_ensure_builtin_cache ();
 
   if (priv->themes_valid)
     {
@@ -1146,7 +1183,7 @@ ensure_valid_themes (GtkIconTheme *icon_theme)
     {
       load_themes (icon_theme);
       
-      if (!priv->check_reload && priv->screen)
+      if (!priv->check_reload && was_valid && priv->screen)
        {         
          static GdkAtom atom_iconthemes = GDK_NONE;
          GdkEvent *event = gdk_event_new (GDK_CLIENT_EVENT);
@@ -1196,7 +1233,6 @@ gtk_icon_theme_lookup_icon (GtkIconTheme       *icon_theme,
   UnthemedIcon *unthemed_icon;
   gboolean allow_svg;
   gboolean use_builtin;
-  gboolean found_default;
 
   g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
   g_return_val_if_fail (icon_name != NULL, NULL);
@@ -1218,24 +1254,15 @@ gtk_icon_theme_lookup_icon (GtkIconTheme       *icon_theme,
 
   ensure_valid_themes (icon_theme);
 
-  found_default = FALSE;
-  l = priv->themes;
-  while (l != NULL)
+  for (l = priv->themes; l; l = l->next)
     {
       IconTheme *theme = l->data;
       
-      if (strcmp (theme->name, DEFAULT_THEME_NAME) == 0)
-       found_default = TRUE;
-      
       icon_info = theme_lookup_icon (theme, icon_name, size, allow_svg, use_builtin);
       if (icon_info)
        goto out;
-      
-      l = l->next;
     }
 
-  g_assert (found_default);
-
   unthemed_icon = g_hash_table_lookup (priv->unthemed_icons, icon_name);
   if (unthemed_icon)
     {
@@ -1300,11 +1327,7 @@ gtk_icon_theme_lookup_icon (GtkIconTheme       *icon_theme,
 GQuark
 gtk_icon_theme_error_quark (void)
 {
-  static GQuark q = 0;
-  if (q == 0)
-    q = g_quark_from_static_string ("gtk-icon-theme-error-quark");
-
-  return q;
+  return g_quark_from_static_string ("gtk-icon-theme-error-quark");
 }
 
 /**
@@ -1450,11 +1473,10 @@ gint *
 gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme,
                               const char   *icon_name)
 {
-  GList *l, *d;
+  GList *l, *d, *icons;
   GHashTable *sizes;
   gint *result, *r;
-  guint suffix;
-  
+  guint suffix;  
   GtkIconThemePrivate *priv;
 
   g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
@@ -1483,6 +1505,33 @@ gtk_icon_theme_get_icon_sizes (GtkIconTheme *icon_theme,
        }
     }
 
+  for (d = builtin_dirs; d; d = d->next)
+    {
+      IconThemeDir *dir = d->data;
+      
+      suffix = theme_dir_get_icon_suffix (dir, icon_name, NULL);         
+      if (suffix != ICON_SUFFIX_NONE)
+       {
+         if (suffix == ICON_SUFFIX_SVG)
+           g_hash_table_insert (sizes, GINT_TO_POINTER (-1), NULL);
+         else
+           g_hash_table_insert (sizes, GINT_TO_POINTER (dir->size), NULL);
+       }
+    }
+
+  if (icon_theme_builtin_icons)
+    {
+      icons = g_hash_table_lookup (icon_theme_builtin_icons, icon_name);
+      
+      while (icons)
+        {
+         BuiltinIcon *icon = icons->data;
+       
+         g_hash_table_insert (sizes, GINT_TO_POINTER (icon->size), NULL);
+          icons = icons->next;
+        }      
+    }
+
   r = result = g_new0 (gint, g_hash_table_size (sizes) + 1);
 
   g_hash_table_foreach (sizes, add_size, &r);
@@ -1520,8 +1569,8 @@ add_key_to_list (gpointer  key,
  * Lists the icons in the current icon theme. Only a subset
  * of the icons can be listed by providing a context string.
  * The set of values for the context string is system dependent,
- * but will typically include such values as 'apps' and
- * 'mimetypes'.
+ * but will typically include such values as "Applications" and
+ * "MimeTypes".
  * 
  * Return value: a #GList list holding the names of all the
  *  icons in the theme. You must first free each element
@@ -1811,40 +1860,6 @@ theme_dir_get_icon_suffix (IconThemeDir *dir,
   return suffix;
 }
 
-static void
-_gtk_icon_theme_ensure_builtin_cache (void)
-{
-  static gboolean initialized = FALSE;
-  IconThemeDir *dir;
-  gint sizes[5] = { 16, 20, 24, 32, 48 };
-  gint n_sizes = G_N_ELEMENTS (sizes);
-  gint i;
-
-  if (!initialized)
-    {
-      initialized = TRUE;
-
-      _builtin_cache = _gtk_icon_cache_new ((gchar *)builtin_icons);
-
-      for (i = 0; i < n_sizes; i++)
-       {
-         dir = g_new (IconThemeDir, 1);
-         dir->type = ICON_THEME_DIR_THRESHOLD;
-         dir->context = 0;
-         dir->size = sizes[i];
-         dir->min_size = sizes[i];
-         dir->max_size = sizes[i];
-         dir->threshold = 2;
-         dir->dir = NULL;
-         dir->icon_data = NULL;
-         dir->subdir = g_strdup_printf ("%d", sizes[i]);
-         dir->cache = _gtk_icon_cache_ref (_builtin_cache);
-
-         builtin_dirs = g_list_append (builtin_dirs, dir);
-       }
-    }
-}
-
 static GtkIconInfo *
 theme_lookup_icon (IconTheme          *theme,
                   const char         *icon_name,
@@ -1867,8 +1882,6 @@ theme_lookup_icon (IconTheme          *theme,
   /* Builtin icons are logically part of the default theme and
    * are searched before other subdirectories of the default theme.
    */
-  _gtk_icon_theme_ensure_builtin_cache ();
-
   if (strcmp (theme->name, DEFAULT_THEME_NAME) == 0 && use_builtin)
     {
       closest_builtin = find_builtin_icon (icon_name, 
@@ -2006,8 +2019,9 @@ theme_lookup_icon (IconTheme          *theme,
 }
 
 static void
-theme_list_icons (IconTheme *theme, GHashTable *icons,
-                 GQuark context)
+theme_list_icons (IconTheme  *theme, 
+                 GHashTable *icons,
+                 GQuark      context)
 {
   GList *l = theme->dirs;
   IconThemeDir *dir;
@@ -2044,7 +2058,6 @@ load_icon_data (IconThemeDir *dir, const char *path, const char *name)
   char *base_name;
   char **split;
   gsize length;
-  char *dot;
   char *str;
   char *split_point;
   int i;
@@ -2059,15 +2072,14 @@ load_icon_data (IconThemeDir *dir, const char *path, const char *name)
   if (error)
     {
       g_error_free (error);
+      g_key_file_free (icon_file);      
       return;
     }
   else
     {
-      base_name = g_strdup (name);
-      dot = strrchr (base_name, '.');
-      *dot = 0;
+      base_name = strip_suffix (name);
       
-      data = g_new0 (GtkIconData, 1);
+      data = g_slice_new0 (GtkIconData);
       g_hash_table_replace (dir->icon_data, base_name, data);
       
       ivalues = g_key_file_get_integer_list (icon_file, 
@@ -2093,7 +2105,7 @@ load_icon_data (IconThemeDir *dir, const char *path, const char *name)
          split = g_strsplit (str, "|", -1);
          
          data->n_attach_points = g_strv_length (split);
-         data->attach_points = g_malloc (sizeof (GdkPoint) * data->n_attach_points);
+         data->attach_points = g_new (GdkPoint, data->n_attach_points);
 
          i = 0;
          while (split[i] != NULL && i < data->n_attach_points)
@@ -2126,9 +2138,6 @@ scan_directory (GtkIconThemePrivate *icon_theme,
 {
   GDir *gdir;
   const char *name;
-  char *base_name, *dot;
-  char *path;
-  IconSuffix suffix, hash_suffix;
 
   GTK_NOTE (ICONTHEME, 
            g_print ("scanning directory %s\n", full_dir));
@@ -2142,6 +2151,10 @@ scan_directory (GtkIconThemePrivate *icon_theme,
 
   while ((name = g_dir_read_name (gdir)))
     {
+      char *path;
+      char *base_name;
+      IconSuffix suffix, hash_suffix;
+
       if (g_str_has_suffix (name, ".icon"))
        {
          if (dir->icon_data == NULL)
@@ -2160,11 +2173,9 @@ scan_directory (GtkIconThemePrivate *icon_theme,
       suffix = suffix_from_name (name);
       if (suffix == ICON_SUFFIX_NONE)
        continue;
-      
-      base_name = g_strdup (name);
-      dot = strrchr (base_name, '.');
-      *dot = 0;
-      
+
+      base_name = strip_suffix (name);
+
       hash_suffix = GPOINTER_TO_INT (g_hash_table_lookup (dir->icons, base_name));
       g_hash_table_replace (dir->icons, base_name, GUINT_TO_POINTER (hash_suffix| suffix));
       g_hash_table_insert (icon_theme->all_icons, base_name, NULL);
@@ -2299,7 +2310,7 @@ icon_data_free (GtkIconData *icon_data)
 {
   g_free (icon_data->attach_points);
   g_free (icon_data->display_name);
-  g_free (icon_data);
+  g_slice_free (GtkIconData, icon_data);
 }
 
 /*
@@ -2315,13 +2326,14 @@ gtk_icon_info_get_type (void)
                                             (GBoxedCopyFunc) gtk_icon_info_copy,
                                             (GBoxedFreeFunc) gtk_icon_info_free);
 
+
   return our_type;
 }
 
 static GtkIconInfo *
 icon_info_new (void)
 {
-  GtkIconInfo *icon_info = g_new0 (GtkIconInfo, 1);
+  GtkIconInfo *icon_info = g_slice_new0 (GtkIconInfo);
 
   icon_info->scale = -1.;
 
@@ -2358,7 +2370,7 @@ gtk_icon_info_copy (GtkIconInfo *icon_info)
   
   g_return_val_if_fail (icon_info != NULL, NULL);
 
-  copy = g_memdup (icon_info, sizeof (GtkIconInfo));
+  copy = memcpy (g_slice_new (GtkIconInfo), icon_info, sizeof (GtkIconInfo));
   if (copy->cache_pixbuf)
     g_object_ref (copy->cache_pixbuf);
   if (copy->pixbuf)
@@ -2399,7 +2411,7 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
   if (icon_info->cache_pixbuf)
     g_object_unref (icon_info->cache_pixbuf);
 
-  g_free (icon_info);
+  g_slice_free (GtkIconInfo, icon_info);
 }
 
 /**
@@ -2857,7 +2869,7 @@ gtk_icon_info_get_attach_points (GtkIconInfo *icon_info,
  * Since: 2.4
  **/
 G_CONST_RETURN gchar *
-gtk_icon_info_get_display_name  (GtkIconInfo *icon_info)
+gtk_icon_info_get_display_name (GtkIconInfo *icon_info)
 {
   g_return_val_if_fail (icon_info != NULL, NULL);
 
@@ -2945,8 +2957,6 @@ find_builtin_icon (const gchar *icon_name,
   gboolean has_larger = FALSE;
   BuiltinIcon *min_icon = NULL;
   
-  _gtk_icon_factory_ensure_default_icons ();
-  
   if (!icon_theme_builtin_icons)
     return NULL;