summaryrefslogtreecommitdiff
path: root/iconcache.c
diff options
context:
space:
mode:
authorSimon Quigley <tsimonq2@ubuntu.com>2017-06-19 14:38:41 -0500
committerSimon Quigley <tsimonq2@ubuntu.com>2017-06-19 14:38:41 -0500
commit11b8179a57e675c6672cbe649c655230ae3e9744 (patch)
tree2919c366d51e154e65279156fef5b4f97b8fd2f9 /iconcache.c
parent720f5023a8f68aaaa54cb6b7bf46efee23b5b4c3 (diff)
Import Upstream version 0.4.2.1
Diffstat (limited to 'iconcache.c')
-rw-r--r--iconcache.c68
1 files changed, 39 insertions, 29 deletions
diff --git a/iconcache.c b/iconcache.c
index fae641d1..fbd0dd84 100644
--- a/iconcache.c
+++ b/iconcache.c
@@ -1,6 +1,6 @@
/*
* HardInfo - Displays System Information
- * Copyright (C) 2003-2006 Leandro A. F. Pereira <leandro@linuxmag.com.br>
+ * Copyright (C) 2003-2007 Leandro A. F. Pereira <leandro@linuxmag.com.br>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,69 +17,79 @@
*/
#include <iconcache.h>
#include <config.h>
-#include <binreloc.h>
+#include <hardinfo.h>
static GHashTable *cache = NULL;
void icon_cache_init(void)
{
+ DEBUG("initializing icon cache");
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();
+
icon = g_hash_table_lookup(cache, file);
if (!icon) {
- gchar *tmp = g_strdup_printf("%s/hardinfo/pixmaps/%s",
- gbr_find_data_dir(PREFIX),
- file);
-
- 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;
-
+
icon = icon_cache_get_pixbuf(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();
+
icon = g_hash_table_lookup(cache, file);
if (!icon) {
- gchar *tmp = g_strdup_printf("%s/hardinfo/pixmaps/%s",
- gbr_find_data_dir(PREFIX),
- file);
-
- 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);
}