gtk2/gtk/gtksizerequestcache.c

77 lines
2.1 KiB
C
Raw Normal View History

/* gtksizerequest.c
* Copyright (C) 2007-2010 Openismus GmbH
*
* Authors:
* Mathias Hasselmann <mathias@openismus.com>
* Tristan Van Berkom <tristan.van.berkom@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "gtksizerequestcacheprivate.h"
#include <string.h>
void
_gtk_size_request_cache_init (SizeRequestCache *cache)
{
memset (cache, 0, sizeof (SizeRequestCache));
}
void
_gtk_size_request_cache_free (SizeRequestCache *cache)
{
_gtk_size_request_cache_clear (cache, GTK_SIZE_GROUP_HORIZONTAL);
_gtk_size_request_cache_clear (cache, GTK_SIZE_GROUP_VERTICAL);
}
void
_gtk_size_request_cache_clear (SizeRequestCache *cache,
GtkSizeGroupMode orientation)
{
SizeRequest **sizes;
gint i;
if (orientation == GTK_SIZE_GROUP_HORIZONTAL)
{
sizes = cache->widths;
cache->widths = NULL;
cache->cached_widths = 0;
cache->last_cached_width = 0;
cache->cached_base_width = FALSE;
}
else
{
sizes = cache->heights;
cache->heights = NULL;
cache->cached_heights = 0;
cache->last_cached_height = 0;
cache->cached_base_height = FALSE;
}
if (sizes)
{
for (i = 0; i < GTK_SIZE_REQUEST_CACHED_SIZES && sizes[i] != NULL; i++)
g_slice_free (SizeRequest, sizes[i]);
g_slice_free1 (sizeof (SizeRequest *) * GTK_SIZE_REQUEST_CACHED_SIZES, sizes);
}
}