[gtk+/treeview-refactor] Adding GtkCellAreaIter arg to GtkCellArea->render/->event
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/treeview-refactor] Adding GtkCellAreaIter arg to GtkCellArea->render/->event
- Date: Sat, 30 Oct 2010 14:48:52 +0000 (UTC)
commit b12e7a811592f82dbce6c36f5df54127d551a4a4
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Sat Oct 30 23:48:52 2010 +0900
Adding GtkCellAreaIter arg to GtkCellArea->render/->event
gtk/gtkcellarea.c | 13 ++++++---
gtk/gtkcellarea.h | 8 ++++-
gtk/gtkcellareabox.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 81 insertions(+), 8 deletions(-)
---
diff --git a/gtk/gtkcellarea.c b/gtk/gtkcellarea.c
index 37d101a..c8cbabf 100644
--- a/gtk/gtkcellarea.c
+++ b/gtk/gtkcellarea.c
@@ -23,6 +23,7 @@
#include "gtkcelllayout.h"
#include "gtkcellarea.h"
+#include "gtkcellareaiter.h"
/* GObjectClass */
static void gtk_cell_area_dispose (GObject *object);
@@ -481,6 +482,7 @@ gtk_cell_area_forall (GtkCellArea *area,
gint
gtk_cell_area_event (GtkCellArea *area,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
GdkEvent *event,
const GdkRectangle *cell_area)
@@ -488,6 +490,7 @@ gtk_cell_area_event (GtkCellArea *area,
GtkCellAreaClass *class;
g_return_val_if_fail (GTK_IS_CELL_AREA (area), 0);
+ g_return_val_if_fail (GTK_IS_CELL_AREA_ITER (iter), 0);
g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
g_return_val_if_fail (event != NULL, 0);
g_return_val_if_fail (cell_area != NULL, 0);
@@ -495,7 +498,7 @@ gtk_cell_area_event (GtkCellArea *area,
class = GTK_CELL_AREA_GET_CLASS (area);
if (class->event)
- return class->event (area, widget, event, cell_area);
+ return class->event (area, iter, widget, event, cell_area);
g_warning ("GtkCellAreaClass::event not implemented for `%s'",
g_type_name (G_TYPE_FROM_INSTANCE (area)));
@@ -504,21 +507,23 @@ gtk_cell_area_event (GtkCellArea *area,
void
gtk_cell_area_render (GtkCellArea *area,
- cairo_t *cr,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
+ cairo_t *cr,
const GdkRectangle *cell_area)
{
GtkCellAreaClass *class;
g_return_if_fail (GTK_IS_CELL_AREA (area));
- g_return_if_fail (cr != NULL);
+ g_return_if_fail (GTK_IS_CELL_AREA_ITER (iter));
g_return_if_fail (GTK_IS_WIDGET (widget));
+ g_return_if_fail (cr != NULL);
g_return_if_fail (cell_area != NULL);
class = GTK_CELL_AREA_GET_CLASS (area);
if (class->render)
- class->render (area, cr, widget, cell_area);
+ class->render (area, iter, widget, cr, cell_area);
else
g_warning ("GtkCellAreaClass::render not implemented for `%s'",
g_type_name (G_TYPE_FROM_INSTANCE (area)));
diff --git a/gtk/gtkcellarea.h b/gtk/gtkcellarea.h
index 9d4b16d..3c2c750 100644
--- a/gtk/gtkcellarea.h
+++ b/gtk/gtkcellarea.h
@@ -80,12 +80,14 @@ struct _GtkCellAreaClass
GtkCellCallback callback,
gpointer callback_data);
gint (* event) (GtkCellArea *area,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
GdkEvent *event,
const GdkRectangle *cell_area);
void (* render) (GtkCellArea *area,
- cairo_t *cr,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
+ cairo_t *cr,
const GdkRectangle *cell_area);
/* Geometry */
@@ -137,12 +139,14 @@ void gtk_cell_area_forall (GtkCellArea
GtkCellCallback callback,
gpointer callback_data);
gint gtk_cell_area_event (GtkCellArea *area,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
GdkEvent *event,
const GdkRectangle *cell_area);
void gtk_cell_area_render (GtkCellArea *area,
- cairo_t *cr,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
+ cairo_t *cr,
const GdkRectangle *cell_area);
/* Geometry */
diff --git a/gtk/gtkcellareabox.c b/gtk/gtkcellareabox.c
index becab50..273da69 100644
--- a/gtk/gtkcellareabox.c
+++ b/gtk/gtkcellareabox.c
@@ -51,12 +51,14 @@ static void gtk_cell_area_box_forall (GtkCellArea
GtkCellCallback callback,
gpointer callback_data);
static gint gtk_cell_area_box_event (GtkCellArea *area,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
GdkEvent *event,
const GdkRectangle *cell_area);
static void gtk_cell_area_box_render (GtkCellArea *area,
- cairo_t *cr,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
+ cairo_t *cr,
const GdkRectangle *cell_area);
static GtkCellAreaIter *gtk_cell_area_box_create_iter (GtkCellArea *area);
@@ -418,8 +420,68 @@ gtk_cell_area_box_allocate (GtkCellAreaBox *box,
gint size,
gint *n_allocs)
{
+ GtkCellAreaBoxPrivate *priv = box->priv;
+ CellGroup *group;
+ GList *group_list;
+ GtkRequestedSize *orientation_sizes;
+ gint n_groups, n_expand_groups, i;
+ gint avail_size = size;
+ gint extra_size, extra_extra;
+ gint position;
+ GtkCellAreaBoxAllocation *allocs;
+
+ n_expand_groups = count_expand_groups (box);
+
+ if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ orientation_sizes = gtk_cell_area_box_iter_get_widths (iter, &n_groups);
+ else
+ orientation_sizes = gtk_cell_area_box_iter_get_heights (iter, &n_groups);
+
+ /* First start by naturally allocating space among groups of cells */
+ avail_size -= (n_groups - 1) * priv->spacing;
+ for (i = 0; i < n_groups; i++)
+ avail_size -= orientation_sizes[i].minimum_size;
+
+ avail_size = gtk_distribute_natural_allocation (avail_size, n_groups, orientation_sizes);
+
+ /* Calculate/distribute expand for groups */
+ if (n_expand_groups > 0)
+ {
+ extra_size = avail_size / n_expand_groups;
+ extra_extra = avail_size % n_expand_groups;
+ }
+ else
+ extra_size = extra_extra = 0;
+
+ allocs = g_new (GtkCellAreaBoxAllocation, n_groups);
+
+ for (position = 0, group_list = priv->groups; group_list; group_list = group_list->next)
+ {
+ group = group_list->data;
+
+ allocs[group->id].position = position;
+ allocs[group->id].size = orientation_sizes[group->id].minimum_size;
+
+ if (group->expand)
+ {
+ allocs[group->id].size += extra_size;
+ if (extra_extra)
+ {
+ allocs[group->id].size++;
+ extra_extra--;
+ }
+ }
+ position += allocs[group->id].size;
+ position += priv->spacing;
+ }
+
+ g_free (orientation_sizes);
+ if (n_allocs)
+ *n_allocs = n_groups;
+
+ return allocs;
}
@@ -546,6 +608,7 @@ gtk_cell_area_box_forall (GtkCellArea *area,
static gint
gtk_cell_area_box_event (GtkCellArea *area,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
GdkEvent *event,
const GdkRectangle *cell_area)
@@ -557,8 +620,9 @@ gtk_cell_area_box_event (GtkCellArea *area,
static void
gtk_cell_area_box_render (GtkCellArea *area,
- cairo_t *cr,
+ GtkCellAreaIter *iter,
GtkWidget *widget,
+ cairo_t *cr,
const GdkRectangle *cell_area)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]