diff options
Diffstat (limited to 'hardinfo2/iconcache.c')
-rw-r--r-- | hardinfo2/iconcache.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/hardinfo2/iconcache.c b/hardinfo2/iconcache.c index 868185e5..8b2e55e8 100644 --- a/hardinfo2/iconcache.c +++ b/hardinfo2/iconcache.c @@ -24,32 +24,34 @@ static GHashTable *cache = NULL; void icon_cache_init(void) { if (!cache) { - cache = g_hash_table_new(g_str_hash, g_str_equal); + cache = g_hash_table_new(g_str_hash, g_str_equal); } } -GdkPixbuf *icon_cache_get_pixbuf(const gchar *file) +GdkPixbuf *icon_cache_get_pixbuf(const gchar * file) { GdkPixbuf *icon; - - if (!cache) icon_cache_init(); - + + if (!cache) + icon_cache_init(); + icon = g_hash_table_lookup(cache, file); if (!icon) { - gchar *tmp = g_build_filename(params.path_data, "pixmaps", file, NULL); - icon = gdk_pixbuf_new_from_file(tmp, NULL); - g_hash_table_insert(cache, g_strdup(file), icon); - - g_free(tmp); + icon = + gdk_pixbuf_new_from_file(idle_free + (g_build_filename + (params.path_data, "pixmaps", file, + NULL)), NULL); + g_hash_table_insert(cache, g_strdup(file), icon); } - + g_object_ref(icon); - + return icon; } -GtkWidget *icon_cache_get_image(const gchar *file) +GtkWidget *icon_cache_get_image(const gchar * file) { GdkPixbuf *icon; @@ -57,32 +59,36 @@ GtkWidget *icon_cache_get_image(const gchar *file) return gtk_image_new_from_pixbuf(icon); } -GdkPixbuf *icon_cache_get_pixbuf_at_size(const gchar *file, gint wid, gint hei) +GdkPixbuf *icon_cache_get_pixbuf_at_size(const gchar * file, gint wid, + gint hei) { GdkPixbuf *icon; - - if (!cache) icon_cache_init(); + + if (!cache) + icon_cache_init(); icon = g_hash_table_lookup(cache, file); if (!icon) { - gchar *tmp = g_build_filename(params.path_data, "pixmaps", file, NULL); - - icon = gdk_pixbuf_new_from_file_at_size(tmp, wid, hei, NULL); - g_hash_table_insert(cache, g_strdup(file), icon); - - g_free(tmp); + icon = + gdk_pixbuf_new_from_file_at_size(idle_free + (g_build_filename + (params.path_data, "pixmaps", + file, NULL)), wid, hei, + NULL); + g_hash_table_insert(cache, g_strdup(file), icon); } - + g_object_ref(icon); - + return icon; } -GtkWidget *icon_cache_get_image_at_size(const gchar *file, gint wid, gint hei) +GtkWidget *icon_cache_get_image_at_size(const gchar * file, gint wid, + gint hei) { GdkPixbuf *icon; - + icon = icon_cache_get_pixbuf_at_size(file, wid, hei); return gtk_image_new_from_pixbuf(icon); } |