Commit 4366f80a authored by Benjamin Otte's avatar Benjamin Otte

sizerequestcache: Move functions

... into the sizerequestcache.c file.
parent 15570dd6
......@@ -809,6 +809,7 @@ gtk_base_c_sources = \
gtksettings.c \
gtksizegroup.c \
gtksizerequest.c \
gtksizerequestcache.c \
gtkshow.c \
gtkspinbutton.c \
gtkspinner.c \
......
......@@ -84,52 +84,6 @@ pop_recursion_check (GtkWidget *widget,
}
static void
clear_cache (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);
}
}
void
_gtk_widget_free_cached_sizes (GtkWidget *widget)
{
SizeRequestCache *cache;
cache = _gtk_widget_peek_request_cache (widget);
clear_cache (cache, GTK_SIZE_GROUP_HORIZONTAL);
clear_cache (cache, GTK_SIZE_GROUP_VERTICAL);
}
/* This function checks if 'request_needed' flag is present
* and resets the cache state if a request is needed for
* a given orientation.
......@@ -142,10 +96,10 @@ init_cache (GtkWidget *widget)
cache = _gtk_widget_peek_request_cache (widget);
if (_gtk_widget_get_width_request_needed (widget))
clear_cache (cache, GTK_SIZE_GROUP_HORIZONTAL);
_gtk_size_request_cache_clear (cache, GTK_SIZE_GROUP_HORIZONTAL);
if (_gtk_widget_get_height_request_needed (widget))
clear_cache (cache, GTK_SIZE_GROUP_VERTICAL);
_gtk_size_request_cache_clear (cache, GTK_SIZE_GROUP_VERTICAL);
return cache;
}
......
/* 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);
}
}
......@@ -26,6 +26,7 @@
#define __GTK_SIZE_REQUEST_CACHE_PRIVATE_H__
#include <glib.h>
#include <gtk/gtkenums.h>
G_BEGIN_DECLS
......@@ -64,6 +65,12 @@ typedef struct {
guint cached_base_height : 1;
} SizeRequestCache;
void _gtk_size_request_cache_init (SizeRequestCache *cache);
void _gtk_size_request_cache_free (SizeRequestCache *cache);
void _gtk_size_request_cache_clear (SizeRequestCache *cache,
GtkSizeGroupMode orientation);
G_END_DECLS
#endif /* __GTK_SIZE_REQUEST_CACHE_PRIVATE_H__ */
......@@ -3687,6 +3687,8 @@ gtk_widget_init (GtkWidget *widget)
*/
priv->need_compute_expand = FALSE;
_gtk_size_request_cache_init (&priv->requests);
priv->style = gtk_widget_get_default_style ();
g_object_ref (priv->style);
}
......@@ -10373,7 +10375,7 @@ gtk_widget_finalize (GObject *object)
g_object_unref (priv->context);
}
_gtk_widget_free_cached_sizes (widget);
_gtk_size_request_cache_free (&priv->requests);
if (g_object_is_floating (object))
g_warning ("A floating object was finalized. This means that someone\n"
......
......@@ -81,7 +81,6 @@ gboolean _gtk_widget_get_translation_to_window (GtkWidget *widget,
GdkWindow *window,
int *x,
int *y);
void _gtk_widget_free_cached_sizes (GtkWidget *widget);
const gchar* _gtk_widget_get_accel_path (GtkWidget *widget,
gboolean *locked);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment