1 /* modest-icon-factory.c */
4 #include "modest-icon-factory.h"
6 static GHashTable *icon_hash = NULL;
9 gboolean equal_func (const gchar *s1, const gchar *s2)
11 return strcmp (s1, s2) == 0;
15 void free_pixbuf (GdkPixbuf *pixbuf)
18 g_object_unref (G_OBJECT(pixbuf));
23 modest_icon_factory_init (void)
26 g_warning ("modest_icon_factory_init "
27 "should be called only once");
31 icon_hash = g_hash_table_new_full (g_str_hash,
32 (GEqualFunc)equal_func,
33 (GDestroyNotify)g_free,
34 (GDestroyNotify)free_pixbuf);
39 modest_icon_factory_uninit (void)
42 g_warning ("modest_icon_factory_uninit "
43 "must only be called with initialized "
44 "ModestIconFactories");
48 g_hash_table_destroy (icon_hash);
55 modest_icon_factory_get_icon (const gchar *name)
62 g_warning ("ModestIconFactory must be initialized first");
66 /* is it already in the hashtable?
67 * note: this can be NULL
69 if (!g_hash_table_lookup_extended (icon_hash, name, &orig_key,
70 (gpointer*)&pixbuf)) {
71 pixbuf = gdk_pixbuf_new_from_file (name, &err);
73 g_warning (err->message);
76 /* if we cannot find it, we still insert, so we get the error
78 g_hash_table_insert (icon_hash, g_strdup(name),