summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.van.berkom@gmail.com>2010-11-27 16:05:14 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2010-11-27 16:05:14 +0900
commit5df7dab3cfdafad8656366edf4848329035b109d (patch)
tree8402211073205e54502d2d9438fbf6011629f016 /gtk
parentcbc4416c8e161d649404a6e6d1e979e551847375 (diff)
downloadgtk+-5df7dab3cfdafad8656366edf4848329035b109d.tar.gz
Changed all the flush apis on GtkCellAreaContext for a single "reset" api.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkcellareabox.c14
-rw-r--r--gtk/gtkcellareaboxcontext.c88
-rw-r--r--gtk/gtkcellareacontext.c93
-rw-r--r--gtk/gtkcellareacontext.h86
4 files changed, 95 insertions, 186 deletions
diff --git a/gtk/gtkcellareabox.c b/gtk/gtkcellareabox.c
index 42bb934cd7..c29e260ad0 100644
--- a/gtk/gtkcellareabox.c
+++ b/gtk/gtkcellareabox.c
@@ -160,7 +160,7 @@ static GList *list_consecutive_cells (GtkCellAreaBox *box);
static gint count_expand_groups (GtkCellAreaBox *box);
static void context_weak_notify (GtkCellAreaBox *box,
GtkCellAreaBoxContext *dead_context);
-static void flush_contexts (GtkCellAreaBox *box);
+static void reset_contexts (GtkCellAreaBox *box);
static void init_context_groups (GtkCellAreaBox *box);
static void init_context_group (GtkCellAreaBox *box,
GtkCellAreaBoxContext *context);
@@ -526,7 +526,7 @@ init_context_group (GtkCellAreaBox *box,
expand_groups[i] = (group->expand_cells > 0);
}
- /* This call implies flushing the request info */
+ /* This call implies reseting the request info */
gtk_cell_area_box_init_groups (context, priv->groups->len, expand_groups);
g_free (expand_groups);
}
@@ -549,19 +549,19 @@ init_context_groups (GtkCellAreaBox *box)
}
static void
-flush_contexts (GtkCellAreaBox *box)
+reset_contexts (GtkCellAreaBox *box)
{
GtkCellAreaBoxPrivate *priv = box->priv;
GSList *l;
/* When the box layout changes, contexts need to
- * be flushed and sizes for the box get requested again
+ * be reset and sizes for the box get requested again
*/
for (l = priv->contexts; l; l = l->next)
{
GtkCellAreaContext *context = l->data;
- gtk_cell_area_context_flush (context);
+ gtk_cell_area_context_reset (context);
}
}
@@ -858,7 +858,7 @@ gtk_cell_area_box_set_property (GObject *object,
box->priv->orientation = g_value_get_enum (value);
/* Notify that size needs to be requested again */
- flush_contexts (box);
+ reset_contexts (box);
break;
case PROP_SPACING:
gtk_cell_area_box_set_spacing (box, g_value_get_int (value));
@@ -2022,6 +2022,6 @@ gtk_cell_area_box_set_spacing (GtkCellAreaBox *box,
g_object_notify (G_OBJECT (box), "spacing");
/* Notify that size needs to be requested again */
- flush_contexts (box);
+ reset_contexts (box);
}
}
diff --git a/gtk/gtkcellareaboxcontext.c b/gtk/gtkcellareaboxcontext.c
index b49ec72c38..19fd36e656 100644
--- a/gtk/gtkcellareaboxcontext.c
+++ b/gtk/gtkcellareaboxcontext.c
@@ -28,26 +28,25 @@
#include "gtkorientable.h"
/* GObjectClass */
-static void gtk_cell_area_box_context_finalize (GObject *object);
+static void gtk_cell_area_box_context_finalize (GObject *object);
/* GtkCellAreaContextClass */
-static void gtk_cell_area_box_context_flush_preferred_width (GtkCellAreaContext *context);
-static void gtk_cell_area_box_context_flush_preferred_height (GtkCellAreaContext *context);
-static void gtk_cell_area_box_context_flush_allocation (GtkCellAreaContext *context);
-static void gtk_cell_area_box_context_sum_preferred_width (GtkCellAreaContext *context);
-static void gtk_cell_area_box_context_sum_preferred_height (GtkCellAreaContext *context);
-static void gtk_cell_area_box_context_allocate (GtkCellAreaContext *context,
- gint width,
- gint height);
-
-static void free_cache_array (GArray *array);
-static GArray *group_array_new (GtkCellAreaBoxContext *context);
-static GArray *get_array (GtkCellAreaBoxContext *context,
- GtkOrientation orientation,
- gint for_size);
-static gboolean group_expands (GtkCellAreaBoxContext *context,
- gint group_idx);
-static gint count_expand_groups (GtkCellAreaBoxContext *context);
+static void gtk_cell_area_box_context_reset (GtkCellAreaContext *context);
+static void gtk_cell_area_box_context_sum_preferred_width (GtkCellAreaContext *context);
+static void gtk_cell_area_box_context_sum_preferred_height (GtkCellAreaContext *context);
+static void gtk_cell_area_box_context_allocate (GtkCellAreaContext *context,
+ gint width,
+ gint height);
+
+/* Internal functions */
+static void free_cache_array (GArray *array);
+static GArray *group_array_new (GtkCellAreaBoxContext *context);
+static GArray *get_array (GtkCellAreaBoxContext *context,
+ GtkOrientation orientation,
+ gint for_size);
+static gboolean group_expands (GtkCellAreaBoxContext *context,
+ gint group_idx);
+static gint count_expand_groups (GtkCellAreaBoxContext *context);
/* CachedSize management */
@@ -191,11 +190,9 @@ gtk_cell_area_box_context_class_init (GtkCellAreaBoxContextClass *class)
/* GObjectClass */
object_class->finalize = gtk_cell_area_box_context_finalize;
- context_class->flush_preferred_width = gtk_cell_area_box_context_flush_preferred_width;
- context_class->flush_preferred_height = gtk_cell_area_box_context_flush_preferred_height;
- context_class->flush_allocation = gtk_cell_area_box_context_flush_allocation;
- context_class->sum_preferred_width = gtk_cell_area_box_context_sum_preferred_width;
- context_class->sum_preferred_height = gtk_cell_area_box_context_sum_preferred_height;
+ context_class->reset = gtk_cell_area_box_context_reset;
+ context_class->sum_preferred_width = gtk_cell_area_box_context_sum_preferred_width;
+ context_class->sum_preferred_height = gtk_cell_area_box_context_sum_preferred_height;
context_class->allocate = gtk_cell_area_box_context_allocate;
@@ -226,58 +223,37 @@ gtk_cell_area_box_context_finalize (GObject *object)
* GtkCellAreaContextClass *
*************************************************************/
static void
-gtk_cell_area_box_context_flush_preferred_width (GtkCellAreaContext *context)
+gtk_cell_area_box_context_reset (GtkCellAreaContext *context)
{
GtkCellAreaBoxContext *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
GtkCellAreaBoxContextPrivate *priv = box_context->priv;
+ CachedSize *size;
gint i;
for (i = 0; i < priv->base_widths->len; i++)
{
- CachedSize *size = &g_array_index (priv->base_widths, CachedSize, i);
+ size = &g_array_index (priv->base_widths, CachedSize, i);
size->min_size = 0;
size->nat_size = 0;
- }
-
- /* Flush context widths as well */
- g_hash_table_remove_all (priv->widths);
-
- GTK_CELL_AREA_CONTEXT_CLASS
- (gtk_cell_area_box_context_parent_class)->flush_preferred_width (context);
-}
-
-static void
-gtk_cell_area_box_context_flush_preferred_height (GtkCellAreaContext *context)
-{
- GtkCellAreaBoxContext *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
- GtkCellAreaBoxContextPrivate *priv = box_context->priv;
- gint i;
- for (i = 0; i < priv->base_heights->len; i++)
- {
- CachedSize *size = &g_array_index (priv->base_heights, CachedSize, i);
+ size = &g_array_index (priv->base_heights, CachedSize, i);
size->min_size = 0;
size->nat_size = 0;
}
- /* Flush context heights as well */
+ /* Reset context sizes as well */
+ g_hash_table_remove_all (priv->widths);
g_hash_table_remove_all (priv->heights);
- GTK_CELL_AREA_CONTEXT_CLASS
- (gtk_cell_area_box_context_parent_class)->flush_preferred_height (context);
-}
-
-static void
-gtk_cell_area_box_context_flush_allocation (GtkCellAreaContext *context)
-{
- GtkCellAreaBoxContext *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
- GtkCellAreaBoxContextPrivate *priv = box_context->priv;
-
+ /* Clear the allocation */
g_free (priv->orientation_allocs);
priv->orientation_allocs = NULL;
priv->n_orientation_allocs = 0;
+
+ GTK_CELL_AREA_CONTEXT_CLASS
+ (gtk_cell_area_box_context_parent_class)->reset (context);
}
static void
@@ -522,10 +498,10 @@ gtk_cell_area_box_init_groups (GtkCellAreaBoxContext *box_context,
g_return_if_fail (GTK_IS_CELL_AREA_BOX_CONTEXT (box_context));
g_return_if_fail (n_groups == 0 || expand_groups != NULL);
- /* When the group dimensions change, all info must be flushed
+ /* When the group dimensions change, all info must be reset
* Note this already clears the min/nat values on the CachedSizes
*/
- gtk_cell_area_context_flush (GTK_CELL_AREA_CONTEXT (box_context));
+ gtk_cell_area_context_reset (GTK_CELL_AREA_CONTEXT (box_context));
priv = box_context->priv;
g_array_set_size (priv->base_widths, n_groups);
diff --git a/gtk/gtkcellareacontext.c b/gtk/gtkcellareacontext.c
index 5a3ee8b28a..0cf9357e4a 100644
--- a/gtk/gtkcellareacontext.c
+++ b/gtk/gtkcellareacontext.c
@@ -28,23 +28,21 @@
#include "gtkprivate.h"
/* GObjectClass */
-static void gtk_cell_area_context_dispose (GObject *object);
-static void gtk_cell_area_context_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void gtk_cell_area_context_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
+static void gtk_cell_area_context_dispose (GObject *object);
+static void gtk_cell_area_context_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void gtk_cell_area_context_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
/* GtkCellAreaContextClass */
-static void gtk_cell_area_context_real_flush_preferred_width (GtkCellAreaContext *context);
-static void gtk_cell_area_context_real_flush_preferred_height (GtkCellAreaContext *context);
-static void gtk_cell_area_context_real_flush_allocation (GtkCellAreaContext *context);
-static void gtk_cell_area_context_real_allocate (GtkCellAreaContext *context,
- gint width,
- gint height);
+static void gtk_cell_area_context_real_reset (GtkCellAreaContext *context);
+static void gtk_cell_area_context_real_allocate (GtkCellAreaContext *context,
+ gint width,
+ gint height);
struct _GtkCellAreaContextPrivate
{
@@ -96,9 +94,7 @@ gtk_cell_area_context_class_init (GtkCellAreaContextClass *class)
object_class->set_property = gtk_cell_area_context_set_property;
/* GtkCellAreaContextClass */
- class->flush_preferred_width = gtk_cell_area_context_real_flush_preferred_width;
- class->flush_preferred_height = gtk_cell_area_context_real_flush_preferred_height;
- class->flush_allocation = gtk_cell_area_context_real_flush_allocation;
+ class->reset = gtk_cell_area_context_real_reset;
class->sum_preferred_width = NULL;
class->sum_preferred_height = NULL;
class->allocate = gtk_cell_area_context_real_allocate;
@@ -229,43 +225,26 @@ gtk_cell_area_context_get_property (GObject *object,
* GtkCellAreaContextClass *
*************************************************************/
static void
-gtk_cell_area_context_real_flush_preferred_width (GtkCellAreaContext *context)
+gtk_cell_area_context_real_reset (GtkCellAreaContext *context)
{
GtkCellAreaContextPrivate *priv = context->priv;
- priv->min_width = -1;
- priv->nat_width = -1;
+ priv->min_width = -1;
+ priv->nat_width = -1;
+ priv->min_height = -1;
+ priv->nat_height = -1;
+ priv->alloc_width = 0;
+ priv->alloc_height = 0;
g_object_freeze_notify (G_OBJECT (context));
g_object_notify (G_OBJECT (context), "minimum-width");
g_object_notify (G_OBJECT (context), "natural-width");
- g_object_thaw_notify (G_OBJECT (context));
-}
-
-static void
-gtk_cell_area_context_real_flush_preferred_height (GtkCellAreaContext *context)
-{
- GtkCellAreaContextPrivate *priv = context->priv;
-
- priv->min_height = -1;
- priv->nat_height = -1;
-
- g_object_freeze_notify (G_OBJECT (context));
g_object_notify (G_OBJECT (context), "minimum-height");
g_object_notify (G_OBJECT (context), "natural-height");
g_object_thaw_notify (G_OBJECT (context));
}
static void
-gtk_cell_area_context_real_flush_allocation (GtkCellAreaContext *context)
-{
- GtkCellAreaContextPrivate *priv = context->priv;
-
- priv->alloc_width = 0;
- priv->alloc_height = 0;
-}
-
-static void
gtk_cell_area_context_real_allocate (GtkCellAreaContext *context,
gint width,
gint height)
@@ -292,37 +271,11 @@ gtk_cell_area_context_get_area (GtkCellAreaContext *context)
}
void
-gtk_cell_area_context_flush (GtkCellAreaContext *context)
-{
- g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
-
- gtk_cell_area_context_flush_preferred_width (context);
- gtk_cell_area_context_flush_preferred_height (context);
- gtk_cell_area_context_flush_allocation (context);
-}
-
-void
-gtk_cell_area_context_flush_preferred_width (GtkCellAreaContext *context)
-{
- g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
-
- GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->flush_preferred_width (context);
-}
-
-void
-gtk_cell_area_context_flush_preferred_height (GtkCellAreaContext *context)
-{
- g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
-
- GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->flush_preferred_height (context);
-}
-
-void
-gtk_cell_area_context_flush_allocation (GtkCellAreaContext *context)
+gtk_cell_area_context_reset (GtkCellAreaContext *context)
{
g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));
- GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->flush_allocation (context);
+ GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->reset (context);
}
void
diff --git a/gtk/gtkcellareacontext.h b/gtk/gtkcellareacontext.h
index f9681e7069..4c45293d92 100644
--- a/gtk/gtkcellareacontext.h
+++ b/gtk/gtkcellareacontext.h
@@ -53,22 +53,12 @@ struct _GtkCellAreaContextClass
{
GObjectClass parent_class;
- /* Subclasses can use this to flush their alignments/allocations */
- void (* flush_preferred_width) (GtkCellAreaContext *context);
- void (* flush_preferred_height) (GtkCellAreaContext *context);
- void (* flush_allocation) (GtkCellAreaContext *context);
-
- /* These must be invoked after a series of requests before consulting
- * the context values, implementors use this to push the overall
- * requests while acconting for any internal alignments */
- void (* sum_preferred_width) (GtkCellAreaContext *context);
- void (* sum_preferred_height) (GtkCellAreaContext *context);
-
- /* Store an allocation value for a GtkCellArea contextual to a range of
- * treemodel rows */
- void (* allocate) (GtkCellAreaContext *context,
- gint width,
- gint height);
+ void (* sum_preferred_width) (GtkCellAreaContext *context);
+ void (* sum_preferred_height) (GtkCellAreaContext *context);
+ void (* allocate) (GtkCellAreaContext *context,
+ gint width,
+ gint height);
+ void (* reset) (GtkCellAreaContext *context);
/* Padding for future expansion */
void (*_gtk_reserved1) (void);
@@ -77,45 +67,35 @@ struct _GtkCellAreaContextClass
void (*_gtk_reserved4) (void);
};
-GType gtk_cell_area_context_get_type (void) G_GNUC_CONST;
-
-GtkCellArea *gtk_cell_area_context_get_area (GtkCellAreaContext *context);
-
-/* Apis for GtkCellArea clients to flush the cache */
-void gtk_cell_area_context_flush (GtkCellAreaContext *context);
-void gtk_cell_area_context_flush_preferred_width (GtkCellAreaContext *context);
-void gtk_cell_area_context_flush_preferred_height (GtkCellAreaContext *context);
-void gtk_cell_area_context_flush_allocation (GtkCellAreaContext *context);
-
-/* Apis for GtkCellArea clients to sum up the results of a series of requests, this
- * call is required to reduce the processing while calculating the size of each row */
-void gtk_cell_area_context_sum_preferred_width (GtkCellAreaContext *context);
-void gtk_cell_area_context_sum_preferred_height (GtkCellAreaContext *context);
-
-/* Apis to set an allocation size in one dimension or another, the subclass specific context
- * will store allocated positions/sizes for individual cells or groups of cells */
-void gtk_cell_area_context_allocate (GtkCellAreaContext *context,
- gint width,
- gint height);
-
-/* Apis for GtkCellArea clients to consult cached values for multiple GtkTreeModel rows */
-void gtk_cell_area_context_get_preferred_width (GtkCellAreaContext *context,
- gint *minimum_width,
- gint *natural_width);
-void gtk_cell_area_context_get_preferred_height (GtkCellAreaContext *context,
- gint *minimum_height,
- gint *natural_height);
-void gtk_cell_area_context_get_allocation (GtkCellAreaContext *context,
- gint *width,
- gint *height);
+GType gtk_cell_area_context_get_type (void) G_GNUC_CONST;
+
+/* Main apis */
+GtkCellArea *gtk_cell_area_context_get_area (GtkCellAreaContext *context);
+void gtk_cell_area_context_sum_preferred_width (GtkCellAreaContext *context);
+void gtk_cell_area_context_sum_preferred_height (GtkCellAreaContext *context);
+void gtk_cell_area_context_allocate (GtkCellAreaContext *context,
+ gint width,
+ gint height);
+void gtk_cell_area_context_reset (GtkCellAreaContext *context);
+
+/* Apis for GtkCellArea clients to consult cached values for a series of GtkTreeModel rows */
+void gtk_cell_area_context_get_preferred_width (GtkCellAreaContext *context,
+ gint *minimum_width,
+ gint *natural_width);
+void gtk_cell_area_context_get_preferred_height (GtkCellAreaContext *context,
+ gint *minimum_height,
+ gint *natural_height);
+void gtk_cell_area_context_get_allocation (GtkCellAreaContext *context,
+ gint *width,
+ gint *height);
/* Apis for GtkCellArea implementations to update cached values for multiple GtkTreeModel rows */
-void gtk_cell_area_context_push_preferred_width (GtkCellAreaContext *context,
- gint minimum_width,
- gint natural_width);
-void gtk_cell_area_context_push_preferred_height (GtkCellAreaContext *context,
- gint minimum_height,
- gint natural_height);
+void gtk_cell_area_context_push_preferred_width (GtkCellAreaContext *context,
+ gint minimum_width,
+ gint natural_width);
+void gtk_cell_area_context_push_preferred_height (GtkCellAreaContext *context,
+ gint minimum_height,
+ gint natural_height);
G_END_DECLS