From 784359c0caef5b4a29d75c2179037c1f1698823e Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Wed, 12 May 2004 18:19:09 +0000 Subject: *** empty log message *** svn path=/trunk/; revision=25886 --- e-util/ChangeLog | 5 +++++ e-util/e-icon-factory.c | 31 ++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 96d6aa32e9..674ef62640 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,8 @@ +2004-05-12 Jeffrey Stedfast + + * e-icon-factory.c (e_icon_factory_shutdown): New function to + clean up the cached icons. + 2004-05-12 Not Zed * e-error-tool.c: Tool to do i18n string extraction for error xml diff --git a/e-util/e-icon-factory.c b/e-util/e-icon-factory.c index f59d5dba55..715a18295d 100644 --- a/e-util/e-icon-factory.c +++ b/e-util/e-icon-factory.c @@ -74,10 +74,6 @@ icon_new (const char *name, GdkPixbuf **pixbufs) return icon; } -#if 0 - -/* (This is not currently used since we never prune icons out of the - cache.) */ static void icon_free (Icon *icon) { @@ -93,8 +89,6 @@ icon_free (Icon *icon) g_free (icon); } -#endif - /* Loading icons. */ static Icon * @@ -151,10 +145,8 @@ pixel_size_to_icon_size (int pixel_size) void e_icon_factory_init (void) { - if (name_to_icon != NULL) { - /* Already initialized. */ + if (name_to_icon != NULL) return; - } name_to_icon = g_hash_table_new (g_str_hash, g_str_equal); icon_theme = gnome_icon_theme_new (); @@ -162,6 +154,27 @@ e_icon_factory_init (void) } +static void +icon_foreach_free (gpointer key, gpointer value, gpointer user_data) +{ + icon_free (value); +} + + +void +e_icon_factory_shutdown (void) +{ + if (name_to_icon == NULL) + return; + + g_hash_table_foreach (name_to_icon, (GHFunc) icon_foreach_free, NULL); + g_hash_table_destroy (name_to_icon); + g_object_unref (empty_pixbuf); + g_object_unref (icon_theme); + name_to_icon = NULL; +} + + /** * e_icon_factory_get_icon_filename: * @icon_name: name of the icon -- cgit v1.2.3