X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fmini-preview-pixbuf-cache.c;fp=src%2Fmini-preview-pixbuf-cache.c;h=5ee99ebd8747efd3306520bf4c42f01fe6a67a9b;hb=db2403f05e4bd16e08346e4896e8feead63d0b12;hp=c7d3afa3758bdf09a1b8cb5645a3459a50350b28;hpb=9971dd3e6268224ee930a26fdb30f22395406233;p=glabels diff --git a/src/mini-preview-pixbuf-cache.c b/src/mini-preview-pixbuf-cache.c index c7d3afa3..5ee99ebd 100644 --- a/src/mini-preview-pixbuf-cache.c +++ b/src/mini-preview-pixbuf-cache.c @@ -1,35 +1,31 @@ -/* -*- 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 . * - * Copyright (C) 2007 Jim Evins . + * 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 . */ + #include #include "mini-preview-pixbuf-cache.h" -#include "mini-preview-pixbuf.h" -#include "libglabels/db.h" +#include -#include -#include +#include +#include "mini-preview-pixbuf.h" #include "debug.h" @@ -47,7 +43,7 @@ static GHashTable *mini_preview_pixbuf_cache = NULL; /* Private function prototypes. */ /*========================================================*/ - + /*****************************************************************************/ /* Create a new hash table to keep track of cached mini preview pixbufs. */ /*****************************************************************************/ @@ -60,9 +56,9 @@ gl_mini_preview_pixbuf_cache_init (void) 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); @@ -76,6 +72,7 @@ gl_mini_preview_pixbuf_cache_init (void) gl_debug (DEBUG_PIXBUF_CACHE, "END pixbuf_cache=%p", mini_preview_pixbuf_cache); } + /*****************************************************************************/ /* Add pixbuf to cache by template. */ /*****************************************************************************/ @@ -83,27 +80,21 @@ void 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. */ /*****************************************************************************/ @@ -124,6 +115,21 @@ gl_mini_preview_pixbuf_cache_add_by_name (gchar *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. */ /*****************************************************************************/ @@ -147,3 +153,13 @@ gl_mini_preview_pixbuf_cache_get_pixbuf (gchar *name) 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 + */