Added cs to the list of languages
[midnight-commander.git] / gnome / gcache.c
blobdadaa11d8e6e628816c7d8daa57cbd0da1a245a9
1 /*
2 * Simple Image cache for images
3 * Copyright (C) 1998 the Free Software Foundation
5 * Author: Miguel de Icaza (miguel@kernel.org)
6 */
7 #include <gnome.h>
8 #include <string.h>
9 #include "gcache.h"
10 static GHashTable *image_cache;
12 static void
13 destroy_image_callback (gpointer key, gpointer data, gpointer user_data)
15 gdk_imlib_destroy_image (data);
16 g_free (key);
19 void
20 image_cache_destroy ()
22 g_hash_table_foreach (image_cache, destroy_image_callback, NULL);
23 g_hash_table_destroy (image_cache);
26 GdkImlibImage *
27 image_cache_load_image (char *file)
29 void *data;
31 if (!image_cache)
32 image_cache = g_hash_table_new (g_str_hash, g_str_equal);
34 data = g_hash_table_lookup (image_cache, file);
35 if (data)
36 return data;
38 data = gdk_imlib_load_image (file);
39 if (data){
40 g_hash_table_insert (image_cache, g_strdup (file), data);
42 return data;