-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * mini-preview-pixbuf-cache.c: GLabels mini-preview pixbuf cache module
+ * mini-preview-pixbuf-cache.c
+ * Copyright (C) 2007-2009 Jim Evins <evins@snaught.com>.
*
- * Copyright (C) 2007 Jim Evins <evins@snaught.com>.
+ * This file is part of gLabels.
*
- * This program is free software; you can redistribute it and/or modify
+ * gLabels is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * gLabels is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include <config.h>
#include "mini-preview-pixbuf-cache.h"
-#include "mini-preview-pixbuf.h"
-#include "libglabels/db.h"
+#include <glib.h>
-#include <glib/gmem.h>
-#include <glib/ghash.h>
+#include <libglabels.h>
+#include "mini-preview-pixbuf.h"
#include "debug.h"
/* Private function prototypes. */
/*========================================================*/
-\f
+
/*****************************************************************************/
/* Create a new hash table to keep track of cached mini preview pixbufs. */
/*****************************************************************************/
gl_debug (DEBUG_PIXBUF_CACHE, "START");
- mini_preview_pixbuf_cache = g_hash_table_new (g_str_hash, g_str_equal);
+ mini_preview_pixbuf_cache = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- names = lgl_db_get_template_name_list_unique (NULL, NULL, NULL);
+ names = lgl_db_get_template_name_list_all (NULL, NULL, NULL);
for ( p=names; p != NULL; p=p->next )
{
gl_debug (DEBUG_PIXBUF_CACHE, "name = \"%s\"", p->data);
gl_debug (DEBUG_PIXBUF_CACHE, "END pixbuf_cache=%p", mini_preview_pixbuf_cache);
}
+
/*****************************************************************************/
/* Add pixbuf to cache by template. */
/*****************************************************************************/
gl_mini_preview_pixbuf_cache_add_by_template (lglTemplate *template)
{
GdkPixbuf *pixbuf;
- GList *p;
- lglTemplateAlias *alias;
gchar *name;
gl_debug (DEBUG_PIXBUF_CACHE, "START");
pixbuf = gl_mini_preview_pixbuf_new (template, 72, 72);
- for ( p=template->aliases; p != NULL; p=p->next )
- {
- alias = (lglTemplateAlias *)p->data;
-
- name = g_strdup_printf ("%s %s", alias->brand, alias->part);
- g_hash_table_insert (mini_preview_pixbuf_cache, name, g_object_ref (pixbuf));
- }
+ name = g_strdup_printf ("%s %s", template->brand, template->part);
+ g_hash_table_insert (mini_preview_pixbuf_cache, name, g_object_ref (pixbuf));
g_object_unref (pixbuf);
gl_debug (DEBUG_PIXBUF_CACHE, "END");
}
+
/*****************************************************************************/
/* Add pixbuf to cache by name. */
/*****************************************************************************/
gl_debug (DEBUG_PIXBUF_CACHE, "END");
}
+
+/*****************************************************************************/
+/* Delete pixbuf from cache by name. */
+/*****************************************************************************/
+void
+gl_mini_preview_pixbuf_cache_delete_by_name (gchar *name)
+{
+ gl_debug (DEBUG_PIXBUF_CACHE, "START");
+
+ g_hash_table_remove (mini_preview_pixbuf_cache, name);
+
+ gl_debug (DEBUG_PIXBUF_CACHE, "END");
+}
+
+
/*****************************************************************************/
/* Get pixbuf. */
/*****************************************************************************/
return g_object_ref (pixbuf);
}
+
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */