3 * Copyright (C) 2010 Openismus GmbH
6 * Tristan Van Berkom <tristanvb@openismus.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
26 #include "gtkorientable.h"
27 #include "gtkcelllayout.h"
28 #include "gtkcellareabox.h"
29 #include "gtkcellareaboxcontext.h"
30 #include "gtkprivate.h"
34 static void gtk_cell_area_box_finalize (GObject *object);
35 static void gtk_cell_area_box_dispose (GObject *object);
36 static void gtk_cell_area_box_set_property (GObject *object,
40 static void gtk_cell_area_box_get_property (GObject *object,
45 /* GtkCellAreaClass */
46 static void gtk_cell_area_box_add (GtkCellArea *area,
47 GtkCellRenderer *renderer);
48 static void gtk_cell_area_box_remove (GtkCellArea *area,
49 GtkCellRenderer *renderer);
50 static void gtk_cell_area_box_forall (GtkCellArea *area,
51 GtkCellCallback callback,
52 gpointer callback_data);
53 static void gtk_cell_area_box_get_cell_allocation (GtkCellArea *area,
54 GtkCellAreaContext *context,
56 GtkCellRenderer *renderer,
57 const GdkRectangle *cell_area,
58 GdkRectangle *allocation);
59 static gint gtk_cell_area_box_event (GtkCellArea *area,
60 GtkCellAreaContext *context,
63 const GdkRectangle *cell_area,
64 GtkCellRendererState flags);
65 static void gtk_cell_area_box_render (GtkCellArea *area,
66 GtkCellAreaContext *context,
69 const GdkRectangle *background_area,
70 const GdkRectangle *cell_area,
71 GtkCellRendererState flags,
72 gboolean paint_focus);
73 static void gtk_cell_area_box_set_cell_property (GtkCellArea *area,
74 GtkCellRenderer *renderer,
78 static void gtk_cell_area_box_get_cell_property (GtkCellArea *area,
79 GtkCellRenderer *renderer,
83 static GtkCellAreaContext *gtk_cell_area_box_create_context (GtkCellArea *area);
84 static GtkSizeRequestMode gtk_cell_area_box_get_request_mode (GtkCellArea *area);
85 static void gtk_cell_area_box_get_preferred_width (GtkCellArea *area,
86 GtkCellAreaContext *context,
90 static void gtk_cell_area_box_get_preferred_height (GtkCellArea *area,
91 GtkCellAreaContext *context,
94 gint *natural_height);
95 static void gtk_cell_area_box_get_preferred_height_for_width (GtkCellArea *area,
96 GtkCellAreaContext *context,
100 gint *natural_height);
101 static void gtk_cell_area_box_get_preferred_width_for_height (GtkCellArea *area,
102 GtkCellAreaContext *context,
106 gint *natural_width);
107 static gboolean gtk_cell_area_box_focus (GtkCellArea *area,
108 GtkDirectionType direction);
110 /* GtkCellLayoutIface */
111 static void gtk_cell_area_box_cell_layout_init (GtkCellLayoutIface *iface);
112 static void gtk_cell_area_box_layout_pack_start (GtkCellLayout *cell_layout,
113 GtkCellRenderer *renderer,
115 static void gtk_cell_area_box_layout_pack_end (GtkCellLayout *cell_layout,
116 GtkCellRenderer *renderer,
118 static void gtk_cell_area_box_layout_reorder (GtkCellLayout *cell_layout,
119 GtkCellRenderer *renderer,
123 /* CellInfo/CellGroup metadata handling and convenience functions */
125 GtkCellRenderer *renderer;
127 guint expand : 1; /* Whether the cell expands */
128 guint pack : 1; /* Whether the cell is packed from the start or end */
129 guint align : 1; /* Whether to align this cell's position with adjacent rows */
137 guint expand_cells : 8;
141 GtkCellRenderer *renderer;
147 static CellInfo *cell_info_new (GtkCellRenderer *renderer,
151 static void cell_info_free (CellInfo *info);
152 static gint cell_info_find (CellInfo *info,
153 GtkCellRenderer *renderer);
155 static AllocatedCell *allocated_cell_new (GtkCellRenderer *renderer,
158 static void allocated_cell_free (AllocatedCell *cell);
159 static GList *list_consecutive_cells (GtkCellAreaBox *box);
160 static gint count_expand_groups (GtkCellAreaBox *box);
161 static void context_weak_notify (GtkCellAreaBox *box,
162 GtkCellAreaBoxContext *dead_context);
163 static void flush_contexts (GtkCellAreaBox *box);
164 static void init_context_groups (GtkCellAreaBox *box);
165 static void init_context_group (GtkCellAreaBox *box,
166 GtkCellAreaBoxContext *context);
167 static GSList *get_allocated_cells (GtkCellAreaBox *box,
168 GtkCellAreaBoxContext *context,
170 gint orientation_size);
173 struct _GtkCellAreaBoxPrivate
175 GtkOrientation orientation;
198 G_DEFINE_TYPE_WITH_CODE (GtkCellAreaBox, gtk_cell_area_box, GTK_TYPE_CELL_AREA,
199 G_IMPLEMENT_INTERFACE (GTK_TYPE_CELL_LAYOUT,
200 gtk_cell_area_box_cell_layout_init)
201 G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL));
203 #define OPPOSITE_ORIENTATION(orientation) \
204 ((orientation) == GTK_ORIENTATION_HORIZONTAL ? \
205 GTK_ORIENTATION_VERTICAL : GTK_ORIENTATION_HORIZONTAL)
208 gtk_cell_area_box_init (GtkCellAreaBox *box)
210 GtkCellAreaBoxPrivate *priv;
212 box->priv = G_TYPE_INSTANCE_GET_PRIVATE (box,
213 GTK_TYPE_CELL_AREA_BOX,
214 GtkCellAreaBoxPrivate);
217 priv->orientation = GTK_ORIENTATION_HORIZONTAL;
218 priv->groups = g_array_new (FALSE, TRUE, sizeof (CellGroup));
220 priv->contexts = NULL;
225 gtk_cell_area_box_class_init (GtkCellAreaBoxClass *class)
227 GObjectClass *object_class = G_OBJECT_CLASS (class);
228 GtkCellAreaClass *area_class = GTK_CELL_AREA_CLASS (class);
231 object_class->finalize = gtk_cell_area_box_finalize;
232 object_class->dispose = gtk_cell_area_box_dispose;
233 object_class->set_property = gtk_cell_area_box_set_property;
234 object_class->get_property = gtk_cell_area_box_get_property;
236 /* GtkCellAreaClass */
237 area_class->add = gtk_cell_area_box_add;
238 area_class->remove = gtk_cell_area_box_remove;
239 area_class->forall = gtk_cell_area_box_forall;
240 area_class->get_cell_allocation = gtk_cell_area_box_get_cell_allocation;
241 area_class->event = gtk_cell_area_box_event;
242 area_class->render = gtk_cell_area_box_render;
243 area_class->set_cell_property = gtk_cell_area_box_set_cell_property;
244 area_class->get_cell_property = gtk_cell_area_box_get_cell_property;
246 area_class->create_context = gtk_cell_area_box_create_context;
247 area_class->get_request_mode = gtk_cell_area_box_get_request_mode;
248 area_class->get_preferred_width = gtk_cell_area_box_get_preferred_width;
249 area_class->get_preferred_height = gtk_cell_area_box_get_preferred_height;
250 area_class->get_preferred_height_for_width = gtk_cell_area_box_get_preferred_height_for_width;
251 area_class->get_preferred_width_for_height = gtk_cell_area_box_get_preferred_width_for_height;
253 area_class->focus = gtk_cell_area_box_focus;
256 g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");
258 g_object_class_install_property (object_class,
260 g_param_spec_int ("spacing",
262 P_("Space which is inserted between cells"),
266 GTK_PARAM_READWRITE));
268 /* Cell Properties */
269 gtk_cell_area_class_install_cell_property (area_class,
274 P_("Whether the cell expands"),
276 GTK_PARAM_READWRITE));
278 gtk_cell_area_class_install_cell_property (area_class,
283 P_("Whether cell should align with adjacent rows"),
285 GTK_PARAM_READWRITE));
287 gtk_cell_area_class_install_cell_property (area_class,
292 P_("A GtkPackType indicating whether the cell is packed with "
293 "reference to the start or end of the cell area"),
294 GTK_TYPE_PACK_TYPE, GTK_PACK_START,
295 GTK_PARAM_READWRITE));
297 g_type_class_add_private (object_class, sizeof (GtkCellAreaBoxPrivate));
301 /*************************************************************
302 * CellInfo/CellGroup basics and convenience functions *
303 *************************************************************/
305 cell_info_new (GtkCellRenderer *renderer,
310 CellInfo *info = g_slice_new (CellInfo);
312 info->renderer = g_object_ref_sink (renderer);
314 info->expand = expand;
321 cell_info_free (CellInfo *info)
323 g_object_unref (info->renderer);
325 g_slice_free (CellInfo, info);
329 cell_info_find (CellInfo *info,
330 GtkCellRenderer *renderer)
332 return (info->renderer == renderer) ? 0 : -1;
335 static AllocatedCell *
336 allocated_cell_new (GtkCellRenderer *renderer,
340 AllocatedCell *cell = g_slice_new (AllocatedCell);
342 cell->renderer = renderer;
343 cell->position = position;
350 allocated_cell_free (AllocatedCell *cell)
352 g_slice_free (AllocatedCell, cell);
356 list_consecutive_cells (GtkCellAreaBox *box)
358 GtkCellAreaBoxPrivate *priv = box->priv;
359 GList *l, *consecutive_cells = NULL, *pack_end_cells = NULL;
362 /* List cells in consecutive order taking their
363 * PACK_START/PACK_END options into account
365 for (l = priv->cells; l; l = l->next)
369 if (info->pack == GTK_PACK_START)
370 consecutive_cells = g_list_prepend (consecutive_cells, info);
373 for (l = priv->cells; l; l = l->next)
377 if (info->pack == GTK_PACK_END)
378 pack_end_cells = g_list_prepend (pack_end_cells, info);
381 consecutive_cells = g_list_reverse (consecutive_cells);
382 consecutive_cells = g_list_concat (consecutive_cells, pack_end_cells);
384 return consecutive_cells;
388 cell_groups_clear (GtkCellAreaBox *box)
390 GtkCellAreaBoxPrivate *priv = box->priv;
393 for (i = 0; i < priv->groups->len; i++)
395 CellGroup *group = &g_array_index (priv->groups, CellGroup, i);
397 g_list_free (group->cells);
400 g_array_set_size (priv->groups, 0);
404 cell_groups_rebuild (GtkCellAreaBox *box)
406 GtkCellAreaBoxPrivate *priv = box->priv;
407 CellGroup group = { 0, };
408 CellGroup *group_ptr;
412 cell_groups_clear (box);
417 cells = list_consecutive_cells (box);
419 /* First group is implied */
420 g_array_append_val (priv->groups, group);
421 group_ptr = &g_array_index (priv->groups, CellGroup, id);
423 for (l = cells; l; l = l->next)
425 CellInfo *info = l->data;
427 /* A new group starts with any aligned cell, the first group is implied */
428 if (info->align && l != cells)
430 memset (&group, 0x0, sizeof (CellGroup));
433 g_array_append_val (priv->groups, group);
434 group_ptr = &g_array_index (priv->groups, CellGroup, id);
437 group_ptr->cells = g_list_prepend (group_ptr->cells, info);
438 group_ptr->n_cells++;
440 /* A group expands if it contains any expand cells */
442 group_ptr->expand_cells++;
447 for (id = 0; id < priv->groups->len; id++)
449 group_ptr = &g_array_index (priv->groups, CellGroup, id);
451 group_ptr->cells = g_list_reverse (group_ptr->cells);
454 /* Contexts need to be updated with the new grouping information */
455 init_context_groups (box);
459 count_visible_cells (CellGroup *group,
463 gint visible_cells = 0;
464 gint n_expand_cells = 0;
466 for (l = group->cells; l; l = l->next)
468 CellInfo *info = l->data;
470 if (gtk_cell_renderer_get_visible (info->renderer))
480 *expand_cells = n_expand_cells;
482 return visible_cells;
486 count_expand_groups (GtkCellAreaBox *box)
488 GtkCellAreaBoxPrivate *priv = box->priv;
490 gint expand_groups = 0;
492 for (i = 0; i < priv->groups->len; i++)
494 CellGroup *group = &g_array_index (priv->groups, CellGroup, i);
496 if (group->expand_cells > 0)
500 return expand_groups;
504 context_weak_notify (GtkCellAreaBox *box,
505 GtkCellAreaBoxContext *dead_context)
507 GtkCellAreaBoxPrivate *priv = box->priv;
509 priv->contexts = g_slist_remove (priv->contexts, dead_context);
513 init_context_group (GtkCellAreaBox *box,
514 GtkCellAreaBoxContext *context)
516 GtkCellAreaBoxPrivate *priv = box->priv;
517 gint *expand_groups, i;
519 expand_groups = g_new (gboolean, priv->groups->len);
521 for (i = 0; i < priv->groups->len; i++)
523 CellGroup *group = &g_array_index (priv->groups, CellGroup, i);
525 expand_groups[i] = (group->expand_cells > 0);
528 /* This call implies flushing the request info */
529 gtk_cell_area_box_init_groups (context, priv->groups->len, expand_groups);
530 g_free (expand_groups);
534 init_context_groups (GtkCellAreaBox *box)
536 GtkCellAreaBoxPrivate *priv = box->priv;
539 /* When the box's groups are reconstructed, contexts need to
542 for (l = priv->contexts; l; l = l->next)
544 GtkCellAreaBoxContext *context = l->data;
546 init_context_group (box, context);
551 flush_contexts (GtkCellAreaBox *box)
553 GtkCellAreaBoxPrivate *priv = box->priv;
556 /* When the box layout changes, contexts need to
557 * be flushed and sizes for the box get requested again
559 for (l = priv->contexts; l; l = l->next)
561 GtkCellAreaContext *context = l->data;
563 gtk_cell_area_context_flush (context);
567 /* Returns an allocation for each cell in the orientation of the box,
568 * used in ->render()/->event() implementations to get a straight-forward
569 * list of allocated cells to operate on.
572 get_allocated_cells (GtkCellAreaBox *box,
573 GtkCellAreaBoxContext *context,
575 gint orientation_size)
577 GtkCellAreaBoxAllocation *group_allocs;
578 GtkCellArea *area = GTK_CELL_AREA (box);
579 GtkCellAreaBoxPrivate *priv = box->priv;
581 GSList *allocated_cells = NULL;
583 gboolean free_allocs = FALSE;
585 group_allocs = gtk_cell_area_box_context_get_orientation_allocs (context, &n_allocs);
588 group_allocs = gtk_cell_area_box_context_allocate (context, orientation_size, &n_allocs);
592 for (i = 0; i < n_allocs; i++)
594 /* We dont always allocate all groups, sometimes the requested group has only invisible
595 * cells for every row, hence the usage of group_allocs[i].group_idx here
597 CellGroup *group = &g_array_index (priv->groups, CellGroup, group_allocs[i].group_idx);
599 /* Exception for single cell groups */
600 if (group->n_cells == 1)
602 CellInfo *info = group->cells->data;
603 AllocatedCell *cell =
604 allocated_cell_new (info->renderer, group_allocs[i].position, group_allocs[i].size);
606 allocated_cells = g_slist_prepend (allocated_cells, cell);
610 GtkRequestedSize *sizes;
611 gint avail_size, position;
612 gint visible_cells, expand_cells;
613 gint extra_size, extra_extra;
615 visible_cells = count_visible_cells (group, &expand_cells);
617 /* If this row has no visible cells in this group, just
618 * skip the allocation */
619 if (visible_cells == 0)
622 /* Offset the allocation to the group position and allocate into
623 * the group's available size */
624 position = group_allocs[i].position;
625 avail_size = group_allocs[i].size;
627 sizes = g_new (GtkRequestedSize, visible_cells);
629 for (j = 0, cell_list = group->cells; cell_list; cell_list = cell_list->next)
631 CellInfo *info = cell_list->data;
633 if (!gtk_cell_renderer_get_visible (info->renderer))
636 gtk_cell_area_request_renderer (area, info->renderer,
639 &sizes[j].minimum_size,
640 &sizes[j].natural_size);
642 sizes[j].data = info;
643 avail_size -= sizes[j].minimum_size;
648 /* Distribute cells naturally within the group */
649 avail_size -= (visible_cells - 1) * priv->spacing;
650 avail_size = gtk_distribute_natural_allocation (avail_size, visible_cells, sizes);
652 /* Calculate/distribute expand for cells */
653 if (expand_cells > 0)
655 extra_size = avail_size / expand_cells;
656 extra_extra = avail_size % expand_cells;
659 extra_size = extra_extra = 0;
661 /* Create the allocated cells (loop only over visible cells here) */
662 for (j = 0; j < visible_cells; j++)
664 CellInfo *info = sizes[j].data;
669 sizes[j].minimum_size += extra_size;
672 sizes[j].minimum_size++;
677 cell = allocated_cell_new (info->renderer, position, sizes[j].minimum_size);
679 allocated_cells = g_slist_prepend (allocated_cells, cell);
681 position += sizes[j].minimum_size;
682 position += priv->spacing;
690 g_free (group_allocs);
692 /* Note it might not be important to reverse the list here at all,
693 * we have the correct positions, no need to allocate from left to right */
694 return g_slist_reverse (allocated_cells);
697 /*************************************************************
699 *************************************************************/
701 gtk_cell_area_box_finalize (GObject *object)
703 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (object);
704 GtkCellAreaBoxPrivate *priv = box->priv;
707 /* Unref/free the context list */
708 for (l = priv->contexts; l; l = l->next)
709 g_object_weak_unref (G_OBJECT (l->data), (GWeakNotify)context_weak_notify, box);
711 g_slist_free (priv->contexts);
712 priv->contexts = NULL;
714 /* Free the cell grouping info */
715 cell_groups_clear (box);
716 g_array_free (priv->groups, TRUE);
718 G_OBJECT_CLASS (gtk_cell_area_box_parent_class)->finalize (object);
722 gtk_cell_area_box_dispose (GObject *object)
724 G_OBJECT_CLASS (gtk_cell_area_box_parent_class)->dispose (object);
728 gtk_cell_area_box_set_property (GObject *object,
733 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (object);
737 case PROP_ORIENTATION:
738 box->priv->orientation = g_value_get_enum (value);
740 /* Notify that size needs to be requested again */
741 flush_contexts (box);
744 gtk_cell_area_box_set_spacing (box, g_value_get_int (value));
747 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
753 gtk_cell_area_box_get_property (GObject *object,
758 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (object);
762 case PROP_ORIENTATION:
763 g_value_set_enum (value, box->priv->orientation);
766 g_value_set_int (value, gtk_cell_area_box_get_spacing (box));
769 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
774 /*************************************************************
776 *************************************************************/
778 gtk_cell_area_box_add (GtkCellArea *area,
779 GtkCellRenderer *renderer)
781 gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (area),
782 renderer, FALSE, TRUE);
786 gtk_cell_area_box_remove (GtkCellArea *area,
787 GtkCellRenderer *renderer)
789 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
790 GtkCellAreaBoxPrivate *priv = box->priv;
793 node = g_list_find_custom (priv->cells, renderer,
794 (GCompareFunc)cell_info_find);
798 CellInfo *info = node->data;
800 cell_info_free (info);
802 priv->cells = g_list_delete_link (priv->cells, node);
804 /* Reconstruct cell groups */
805 cell_groups_rebuild (box);
808 g_warning ("Trying to remove a cell renderer that is not present GtkCellAreaBox");
812 gtk_cell_area_box_forall (GtkCellArea *area,
813 GtkCellCallback callback,
814 gpointer callback_data)
816 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
817 GtkCellAreaBoxPrivate *priv = box->priv;
820 for (list = priv->cells; list; list = list->next)
822 CellInfo *info = list->data;
824 callback (info->renderer, callback_data);
829 gtk_cell_area_box_get_cell_allocation (GtkCellArea *area,
830 GtkCellAreaContext *context,
832 GtkCellRenderer *renderer,
833 const GdkRectangle *cell_area,
834 GdkRectangle *allocation)
836 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
837 GtkCellAreaBoxPrivate *priv = box->priv;
838 GtkCellAreaBoxContext *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
839 GSList *allocated_cells, *l;
841 *allocation = *cell_area;
843 /* Get a list of cells with allocation sizes decided regardless
844 * of alignments and pack order etc. */
845 allocated_cells = get_allocated_cells (box, box_context, widget,
846 priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
847 cell_area->width : cell_area->height);
849 for (l = allocated_cells; l; l = l->next)
851 AllocatedCell *cell = l->data;
853 if (cell->renderer == renderer)
855 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
857 allocation->x = cell_area->x + cell->position;
858 allocation->width = cell->size;
862 allocation->y = cell_area->y + cell->position;
863 allocation->height = cell->size;
870 g_slist_foreach (allocated_cells, (GFunc)allocated_cell_free, NULL);
871 g_slist_free (allocated_cells);
881 gtk_cell_area_box_event (GtkCellArea *area,
882 GtkCellAreaContext *context,
885 const GdkRectangle *cell_area,
886 GtkCellRendererState flags)
890 /* First let the parent class handle activation of cells via keystrokes */
892 GTK_CELL_AREA_CLASS (gtk_cell_area_box_parent_class)->event (area, context, widget,
893 event, cell_area, flags);
898 /* Also detect mouse events, for mouse events we need to allocate the renderers
899 * and find which renderer needs to be activated.
901 if (event->type == GDK_BUTTON_PRESS)
903 GdkEventButton *button_event = (GdkEventButton *)event;
905 if (button_event->button == 1)
907 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
908 GtkCellAreaBoxPrivate *priv = box->priv;
909 GtkCellAreaBoxContext *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
910 GSList *allocated_cells, *l;
911 GdkRectangle cell_background, inner_area;
912 gint event_x, event_y;
914 /* We may need some semantics to tell us the offset of the event
915 * window we are handling events for (i.e. GtkTreeView has a bin_window) */
916 event_x = button_event->x;
917 event_y = button_event->y;
919 cell_background = *cell_area;
921 /* Get a list of cells with allocation sizes decided regardless
922 * of alignments and pack order etc. */
923 allocated_cells = get_allocated_cells (box, box_context, widget,
924 priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
925 cell_area->width : cell_area->height);
927 for (l = allocated_cells; l; l = l->next)
929 AllocatedCell *cell = l->data;
931 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
933 cell_background.x = cell_area->x + cell->position;
934 cell_background.width = cell->size;
938 cell_background.y = cell_area->y + cell->position;
939 cell_background.height = cell->size;
942 /* Remove margins from the background area to produce the cell area
944 gtk_cell_area_inner_cell_area (area, widget, &cell_background, &inner_area);
946 if (event_x >= inner_area.x && event_x <= inner_area.x + inner_area.width &&
947 event_y >= inner_area.y && event_y <= inner_area.y + inner_area.height)
949 GtkCellRenderer *event_renderer = NULL;
951 if (gtk_cell_renderer_can_focus (cell->renderer))
952 event_renderer = cell->renderer;
955 GtkCellRenderer *focus_renderer;
957 /* A renderer can have focus siblings but that renderer might not be
958 * focusable for every row... so we go on to check can_focus here. */
959 focus_renderer = gtk_cell_area_get_focus_from_sibling (area, cell->renderer);
961 if (focus_renderer && gtk_cell_renderer_can_focus (focus_renderer))
962 event_renderer = focus_renderer;
967 if (gtk_cell_area_get_edited_cell (area))
969 /* XXX Was it really canceled in this case ? */
970 gtk_cell_area_stop_editing (area, TRUE);
971 gtk_cell_area_set_focus_cell (area, event_renderer);
976 /* If we are activating via a focus sibling, we need to fix the
978 if (event_renderer != cell->renderer)
979 gtk_cell_area_inner_cell_area (area, widget, cell_area, &cell_background);
981 gtk_cell_area_set_focus_cell (area, event_renderer);
983 retval = gtk_cell_area_activate_cell (area, widget, event_renderer,
984 event, &cell_background, flags);
990 g_slist_foreach (allocated_cells, (GFunc)allocated_cell_free, NULL);
991 g_slist_free (allocated_cells);
999 gtk_cell_area_box_render (GtkCellArea *area,
1000 GtkCellAreaContext *context,
1003 const GdkRectangle *background_area,
1004 const GdkRectangle *cell_area,
1005 GtkCellRendererState flags,
1006 gboolean paint_focus)
1008 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1009 GtkCellAreaBoxPrivate *priv = box->priv;
1010 GtkCellAreaBoxContext *box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
1011 GSList *allocated_cells, *l;
1012 GdkRectangle cell_background, inner_area;
1013 GtkCellRenderer *focus_cell = NULL;
1014 GdkRectangle focus_rect = { 0, };
1015 gboolean first_focus_cell = TRUE;
1017 if (flags & GTK_CELL_RENDERER_FOCUSED)
1019 focus_cell = gtk_cell_area_get_focus_cell (area);
1020 flags &= ~GTK_CELL_RENDERER_FOCUSED;
1023 cell_background = *cell_area;
1025 /* Get a list of cells with allocation sizes decided regardless
1026 * of alignments and pack order etc. */
1027 allocated_cells = get_allocated_cells (box, box_context, widget,
1028 priv->orientation == GTK_ORIENTATION_HORIZONTAL ?
1029 cell_area->width : cell_area->height);
1031 for (l = allocated_cells; l; l = l->next)
1033 AllocatedCell *cell = l->data;
1034 GtkCellRendererState cell_fields = 0;
1035 GdkRectangle render_background;
1037 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
1039 cell_background.x = cell_area->x + cell->position;
1040 cell_background.width = cell->size;
1044 cell_background.y = cell_area->y + cell->position;
1045 cell_background.height = cell->size;
1048 /* Remove margins from the background area to produce the cell area
1050 gtk_cell_area_inner_cell_area (area, widget, &cell_background, &inner_area);
1052 /* Add portions of the background_area to the cell_background
1053 * to create the render_background */
1054 render_background = cell_background;
1056 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
1058 if (l == allocated_cells)
1060 render_background.width += render_background.x - background_area->x;
1061 render_background.x = background_area->x;
1064 if (l->next == NULL)
1065 render_background.width =
1066 background_area->width - (render_background.x - background_area->x);
1068 render_background.y = background_area->y;
1069 render_background.height = background_area->height;
1073 if (l == allocated_cells)
1075 render_background.height += render_background.y - background_area->y;
1076 render_background.y = background_area->y;
1079 if (l->next == NULL)
1080 render_background.height =
1081 background_area->height - (render_background.y - background_area->y);
1083 render_background.x = background_area->x;
1084 render_background.width = background_area->width;
1088 (cell->renderer == focus_cell ||
1089 gtk_cell_area_is_focus_sibling (area, focus_cell, cell->renderer)))
1091 cell_fields |= GTK_CELL_RENDERER_FOCUSED;
1095 GdkRectangle cell_focus;
1097 gtk_cell_area_aligned_cell_area (area, widget, cell->renderer, &inner_area, &cell_focus);
1099 /* Accumulate the focus rectangle for all focus siblings */
1100 if (first_focus_cell)
1102 focus_rect = cell_focus;
1103 first_focus_cell = FALSE;
1106 gdk_rectangle_union (&focus_rect, &cell_focus, &focus_rect);
1110 /* We have to do some per-cell considerations for the 'flags'
1111 * for focus handling */
1112 gtk_cell_renderer_render (cell->renderer, cr, widget,
1113 &render_background, &inner_area,
1114 flags | cell_fields);
1117 if (paint_focus && focus_rect.width != 0 && focus_rect.height != 0)
1119 GtkStateType renderer_state =
1120 flags & GTK_CELL_RENDERER_SELECTED ? GTK_STATE_SELECTED :
1121 (flags & GTK_CELL_RENDERER_PRELIT ? GTK_STATE_PRELIGHT :
1122 (flags & GTK_CELL_RENDERER_INSENSITIVE ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL));
1124 gtk_paint_focus (gtk_widget_get_style (widget), cr,
1125 renderer_state, widget,
1126 gtk_cell_area_get_style_detail (area),
1127 focus_rect.x, focus_rect.y,
1128 focus_rect.width, focus_rect.height);
1132 g_slist_foreach (allocated_cells, (GFunc)allocated_cell_free, NULL);
1133 g_slist_free (allocated_cells);
1137 gtk_cell_area_box_set_cell_property (GtkCellArea *area,
1138 GtkCellRenderer *renderer,
1140 const GValue *value,
1143 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1144 GtkCellAreaBoxPrivate *priv = box->priv;
1147 gboolean rebuild = FALSE;
1149 GtkPackType pack_type;
1151 node = g_list_find_custom (priv->cells, renderer,
1152 (GCompareFunc)cell_info_find);
1160 case CELL_PROP_EXPAND:
1161 val = g_value_get_boolean (value);
1163 if (info->expand != val)
1170 case CELL_PROP_ALIGN:
1171 val = g_value_get_boolean (value);
1173 if (info->align != val)
1180 case CELL_PROP_PACK_TYPE:
1181 pack_type = g_value_get_enum (value);
1183 if (info->pack != pack_type)
1185 info->pack = pack_type;
1190 GTK_CELL_AREA_WARN_INVALID_CHILD_PROPERTY_ID (area, prop_id, pspec);
1194 /* Groups need to be rebuilt */
1196 cell_groups_rebuild (box);
1200 gtk_cell_area_box_get_cell_property (GtkCellArea *area,
1201 GtkCellRenderer *renderer,
1206 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1207 GtkCellAreaBoxPrivate *priv = box->priv;
1211 node = g_list_find_custom (priv->cells, renderer,
1212 (GCompareFunc)cell_info_find);
1220 case CELL_PROP_EXPAND:
1221 g_value_set_boolean (value, info->expand);
1224 case CELL_PROP_ALIGN:
1225 g_value_set_boolean (value, info->align);
1228 case CELL_PROP_PACK_TYPE:
1229 g_value_set_enum (value, info->pack);
1232 GTK_CELL_AREA_WARN_INVALID_CHILD_PROPERTY_ID (area, prop_id, pspec);
1238 static GtkCellAreaContext *
1239 gtk_cell_area_box_create_context (GtkCellArea *area)
1241 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1242 GtkCellAreaBoxPrivate *priv = box->priv;
1243 GtkCellAreaContext *context =
1244 (GtkCellAreaContext *)g_object_new (GTK_TYPE_CELL_AREA_BOX_CONTEXT,
1245 "area", area, NULL);
1247 priv->contexts = g_slist_prepend (priv->contexts, context);
1249 g_object_weak_ref (G_OBJECT (context), (GWeakNotify)context_weak_notify, box);
1251 /* Tell the new group about our cell layout */
1252 init_context_group (box, GTK_CELL_AREA_BOX_CONTEXT (context));
1257 static GtkSizeRequestMode
1258 gtk_cell_area_box_get_request_mode (GtkCellArea *area)
1260 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1261 GtkCellAreaBoxPrivate *priv = box->priv;
1263 return (priv->orientation) == GTK_ORIENTATION_HORIZONTAL ?
1264 GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH :
1265 GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT;
1269 compute_size (GtkCellAreaBox *box,
1270 GtkOrientation orientation,
1271 GtkCellAreaBoxContext *context,
1277 GtkCellAreaBoxPrivate *priv = box->priv;
1278 GtkCellArea *area = GTK_CELL_AREA (box);
1284 for (i = 0; i < priv->groups->len; i++)
1286 CellGroup *group = &g_array_index (priv->groups, CellGroup, i);
1287 gint group_min = 0, group_nat = 0;
1289 for (list = group->cells; list; list = list->next)
1291 CellInfo *info = list->data;
1292 gint renderer_min_size, renderer_nat_size;
1294 if (!gtk_cell_renderer_get_visible (info->renderer))
1297 gtk_cell_area_request_renderer (area, info->renderer, orientation, widget, for_size,
1298 &renderer_min_size, &renderer_nat_size);
1300 if (orientation == priv->orientation)
1304 min_size += priv->spacing;
1305 nat_size += priv->spacing;
1310 group_min += priv->spacing;
1311 group_nat += priv->spacing;
1314 min_size += renderer_min_size;
1315 nat_size += renderer_nat_size;
1316 group_min += renderer_min_size;
1317 group_nat += renderer_nat_size;
1321 min_size = MAX (min_size, renderer_min_size);
1322 nat_size = MAX (nat_size, renderer_nat_size);
1323 group_min = MAX (group_min, renderer_min_size);
1324 group_nat = MAX (group_nat, renderer_nat_size);
1330 if (orientation == GTK_ORIENTATION_HORIZONTAL)
1331 gtk_cell_area_box_context_push_group_width (context, group->id, group_min, group_nat);
1333 gtk_cell_area_box_context_push_group_height (context, group->id, group_min, group_nat);
1337 *minimum_size = min_size;
1338 *natural_size = nat_size;
1342 get_group_sizes (GtkCellArea *area,
1344 GtkOrientation orientation,
1348 GtkRequestedSize *sizes;
1352 *n_sizes = count_visible_cells (group, NULL);
1353 sizes = g_new (GtkRequestedSize, *n_sizes);
1355 for (l = group->cells, i = 0; l; l = l->next)
1357 CellInfo *info = l->data;
1359 if (!gtk_cell_renderer_get_visible (info->renderer))
1362 sizes[i].data = info;
1364 gtk_cell_area_request_renderer (area, info->renderer,
1365 orientation, widget, -1,
1366 &sizes[i].minimum_size,
1367 &sizes[i].natural_size);
1376 compute_group_size_for_opposing_orientation (GtkCellAreaBox *box,
1383 GtkCellAreaBoxPrivate *priv = box->priv;
1384 GtkCellArea *area = GTK_CELL_AREA (box);
1386 /* Exception for single cell groups */
1387 if (group->n_cells == 1)
1389 CellInfo *info = group->cells->data;
1391 gtk_cell_area_request_renderer (area, info->renderer,
1392 OPPOSITE_ORIENTATION (priv->orientation),
1393 widget, for_size, minimum_size, natural_size);
1397 GtkRequestedSize *orientation_sizes;
1400 gint avail_size = for_size;
1401 gint extra_size, extra_extra;
1402 gint min_size = 0, nat_size = 0;
1404 orientation_sizes = get_group_sizes (area, group, priv->orientation, widget, &n_sizes);
1406 /* First naturally allocate the cells in the group into the for_size */
1407 avail_size -= (n_sizes - 1) * priv->spacing;
1408 for (i = 0; i < n_sizes; i++)
1409 avail_size -= orientation_sizes[i].minimum_size;
1411 avail_size = gtk_distribute_natural_allocation (avail_size, n_sizes, orientation_sizes);
1413 /* Calculate/distribute expand for cells */
1414 if (group->expand_cells > 0)
1416 extra_size = avail_size / group->expand_cells;
1417 extra_extra = avail_size % group->expand_cells;
1420 extra_size = extra_extra = 0;
1422 for (i = 0; i < n_sizes; i++)
1424 gint cell_min, cell_nat;
1426 info = orientation_sizes[i].data;
1430 orientation_sizes[i].minimum_size += extra_size;
1433 orientation_sizes[i].minimum_size++;
1438 gtk_cell_area_request_renderer (area, info->renderer,
1439 OPPOSITE_ORIENTATION (priv->orientation),
1441 orientation_sizes[i].minimum_size,
1442 &cell_min, &cell_nat);
1444 min_size = MAX (min_size, cell_min);
1445 nat_size = MAX (nat_size, cell_nat);
1448 *minimum_size = min_size;
1449 *natural_size = nat_size;
1451 g_free (orientation_sizes);
1456 compute_size_for_opposing_orientation (GtkCellAreaBox *box,
1457 GtkCellAreaBoxContext *context,
1463 GtkCellAreaBoxPrivate *priv = box->priv;
1465 GtkRequestedSize *orientation_sizes;
1466 gint n_groups, n_expand_groups, i;
1467 gint avail_size = for_size;
1468 gint extra_size, extra_extra;
1469 gint min_size = 0, nat_size = 0;
1471 n_expand_groups = count_expand_groups (box);
1473 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
1474 orientation_sizes = gtk_cell_area_box_context_get_widths (context, &n_groups);
1476 orientation_sizes = gtk_cell_area_box_context_get_heights (context, &n_groups);
1478 /* First start by naturally allocating space among groups of cells */
1479 avail_size -= (n_groups - 1) * priv->spacing;
1480 for (i = 0; i < n_groups; i++)
1481 avail_size -= orientation_sizes[i].minimum_size;
1483 avail_size = gtk_distribute_natural_allocation (avail_size, n_groups, orientation_sizes);
1485 /* Calculate/distribute expand for groups */
1486 if (n_expand_groups > 0)
1488 extra_size = avail_size / n_expand_groups;
1489 extra_extra = avail_size % n_expand_groups;
1492 extra_size = extra_extra = 0;
1494 /* Now we need to naturally allocate sizes for cells in each group
1495 * and push the height-for-width for each group accordingly while accumulating
1496 * the overall height-for-width for this row.
1498 for (i = 0; i < n_groups; i++)
1500 gint group_min, group_nat;
1501 gint group_idx = GPOINTER_TO_INT (orientation_sizes[i].data);
1503 group = &g_array_index (priv->groups, CellGroup, group_idx);
1505 if (group->expand_cells > 0)
1507 orientation_sizes[i].minimum_size += extra_size;
1510 orientation_sizes[i].minimum_size++;
1515 /* Now we have the allocation for the group, request it's height-for-width */
1516 compute_group_size_for_opposing_orientation (box, group, widget,
1517 orientation_sizes[i].minimum_size,
1518 &group_min, &group_nat);
1520 min_size = MAX (min_size, group_min);
1521 nat_size = MAX (nat_size, group_nat);
1524 *minimum_size = min_size;
1525 *natural_size = nat_size;
1527 g_free (orientation_sizes);
1533 gtk_cell_area_box_get_preferred_width (GtkCellArea *area,
1534 GtkCellAreaContext *context,
1536 gint *minimum_width,
1537 gint *natural_width)
1539 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1540 GtkCellAreaBoxContext *box_context;
1541 gint min_width, nat_width;
1543 g_return_if_fail (GTK_IS_CELL_AREA_BOX_CONTEXT (context));
1545 box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
1547 /* Compute the size of all renderers for current row data,
1548 * bumping cell alignments in the context along the way */
1549 compute_size (box, GTK_ORIENTATION_HORIZONTAL,
1550 box_context, widget, -1, &min_width, &nat_width);
1553 *minimum_width = min_width;
1556 *natural_width = nat_width;
1560 gtk_cell_area_box_get_preferred_height (GtkCellArea *area,
1561 GtkCellAreaContext *context,
1563 gint *minimum_height,
1564 gint *natural_height)
1566 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1567 GtkCellAreaBoxContext *box_context;
1568 gint min_height, nat_height;
1570 g_return_if_fail (GTK_IS_CELL_AREA_BOX_CONTEXT (context));
1572 box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
1574 /* Compute the size of all renderers for current row data,
1575 * bumping cell alignments in the context along the way */
1576 compute_size (box, GTK_ORIENTATION_VERTICAL,
1577 box_context, widget, -1, &min_height, &nat_height);
1580 *minimum_height = min_height;
1583 *natural_height = nat_height;
1587 gtk_cell_area_box_get_preferred_height_for_width (GtkCellArea *area,
1588 GtkCellAreaContext *context,
1591 gint *minimum_height,
1592 gint *natural_height)
1594 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1595 GtkCellAreaBoxContext *box_context;
1596 GtkCellAreaBoxPrivate *priv;
1597 gint min_height, nat_height;
1599 g_return_if_fail (GTK_IS_CELL_AREA_BOX_CONTEXT (context));
1601 box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
1604 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
1606 /* Add up vertical requests of height for width and push the overall
1607 * cached sizes for alignments */
1608 compute_size (box, priv->orientation, box_context, widget, width, &min_height, &nat_height);
1612 /* Juice: virtually allocate cells into the for_width using the
1613 * alignments and then return the overall height for that width, and cache it */
1614 compute_size_for_opposing_orientation (box, box_context, widget, width, &min_height, &nat_height);
1618 *minimum_height = min_height;
1621 *natural_height = nat_height;
1625 gtk_cell_area_box_get_preferred_width_for_height (GtkCellArea *area,
1626 GtkCellAreaContext *context,
1629 gint *minimum_width,
1630 gint *natural_width)
1632 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1633 GtkCellAreaBoxContext *box_context;
1634 GtkCellAreaBoxPrivate *priv;
1635 gint min_width, nat_width;
1637 g_return_if_fail (GTK_IS_CELL_AREA_BOX_CONTEXT (context));
1639 box_context = GTK_CELL_AREA_BOX_CONTEXT (context);
1642 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL)
1644 /* Add up horizontal requests of width for height and push the overall
1645 * cached sizes for alignments */
1646 compute_size (box, priv->orientation, box_context, widget, height, &min_width, &nat_width);
1650 /* Juice: horizontally allocate cells into the for_height using the
1651 * alignments and then return the overall width for that height, and cache it */
1652 compute_size_for_opposing_orientation (box, box_context, widget, height, &min_width, &nat_width);
1656 *minimum_width = min_width;
1659 *natural_width = nat_width;
1663 gtk_cell_area_box_focus (GtkCellArea *area,
1664 GtkDirectionType direction)
1666 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (area);
1667 GtkCellAreaBoxPrivate *priv = box->priv;
1668 gint cycle = FOCUS_NONE;
1669 gboolean cycled_focus = FALSE;
1670 GtkCellRenderer *focus_cell;
1672 focus_cell = gtk_cell_area_get_focus_cell (area);
1676 case GTK_DIR_TAB_FORWARD:
1679 case GTK_DIR_TAB_BACKWARD:
1683 if (priv->orientation == GTK_ORIENTATION_VERTICAL || !focus_cell)
1687 if (priv->orientation == GTK_ORIENTATION_VERTICAL || !focus_cell)
1691 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL || !focus_cell)
1695 if (priv->orientation == GTK_ORIENTATION_HORIZONTAL || !focus_cell)
1702 if (cycle != FOCUS_NONE)
1704 gboolean found_cell = FALSE;
1708 /* If there is no focused cell, focus on the first (or last) one in the list */
1712 for (i = (cycle == FOCUS_NEXT) ? 0 : priv->groups->len -1;
1713 cycled_focus == FALSE && i >= 0 && i < priv->groups->len;
1714 i = (cycle == FOCUS_NEXT) ? i + 1 : i - 1)
1716 CellGroup *group = &g_array_index (priv->groups, CellGroup, i);
1718 for (list = (cycle == FOCUS_NEXT) ? g_list_first (group->cells) : g_list_last (group->cells);
1719 list; list = (cycle == FOCUS_NEXT) ? list->next : list->prev)
1721 CellInfo *info = list->data;
1723 if (info->renderer == focus_cell)
1725 else if (found_cell)
1727 if (gtk_cell_renderer_can_focus (info->renderer))
1729 gtk_cell_area_set_focus_cell (area, info->renderer);
1731 cycled_focus = TRUE;
1740 gtk_cell_area_set_focus_cell (area, NULL);
1742 return cycled_focus;
1746 /*************************************************************
1747 * GtkCellLayoutIface *
1748 *************************************************************/
1750 gtk_cell_area_box_cell_layout_init (GtkCellLayoutIface *iface)
1752 iface->pack_start = gtk_cell_area_box_layout_pack_start;
1753 iface->pack_end = gtk_cell_area_box_layout_pack_end;
1754 iface->reorder = gtk_cell_area_box_layout_reorder;
1758 gtk_cell_area_box_layout_pack_start (GtkCellLayout *cell_layout,
1759 GtkCellRenderer *renderer,
1762 gtk_cell_area_box_pack_start (GTK_CELL_AREA_BOX (cell_layout), renderer, expand, TRUE);
1766 gtk_cell_area_box_layout_pack_end (GtkCellLayout *cell_layout,
1767 GtkCellRenderer *renderer,
1770 gtk_cell_area_box_pack_end (GTK_CELL_AREA_BOX (cell_layout), renderer, expand, TRUE);
1774 gtk_cell_area_box_layout_reorder (GtkCellLayout *cell_layout,
1775 GtkCellRenderer *renderer,
1778 GtkCellAreaBox *box = GTK_CELL_AREA_BOX (cell_layout);
1779 GtkCellAreaBoxPrivate *priv = box->priv;
1783 node = g_list_find_custom (priv->cells, renderer,
1784 (GCompareFunc)cell_info_find);
1790 priv->cells = g_list_delete_link (priv->cells, node);
1791 priv->cells = g_list_insert (priv->cells, info, position);
1793 cell_groups_rebuild (box);
1797 /*************************************************************
1799 *************************************************************/
1801 gtk_cell_area_box_new (void)
1803 return (GtkCellArea *)g_object_new (GTK_TYPE_CELL_AREA_BOX, NULL);
1807 gtk_cell_area_box_pack_start (GtkCellAreaBox *box,
1808 GtkCellRenderer *renderer,
1812 GtkCellAreaBoxPrivate *priv;
1815 g_return_if_fail (GTK_IS_CELL_AREA_BOX (box));
1816 g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
1820 if (g_list_find_custom (priv->cells, renderer,
1821 (GCompareFunc)cell_info_find))
1823 g_warning ("Refusing to add the same cell renderer to a GtkCellAreaBox twice");
1827 info = cell_info_new (renderer, GTK_PACK_START, expand, align);
1829 priv->cells = g_list_append (priv->cells, info);
1831 cell_groups_rebuild (box);
1835 gtk_cell_area_box_pack_end (GtkCellAreaBox *box,
1836 GtkCellRenderer *renderer,
1840 GtkCellAreaBoxPrivate *priv;
1843 g_return_if_fail (GTK_IS_CELL_AREA_BOX (box));
1844 g_return_if_fail (GTK_IS_CELL_RENDERER (renderer));
1848 if (g_list_find_custom (priv->cells, renderer,
1849 (GCompareFunc)cell_info_find))
1851 g_warning ("Refusing to add the same cell renderer to a GtkCellArea twice");
1855 info = cell_info_new (renderer, GTK_PACK_END, expand, align);
1857 priv->cells = g_list_append (priv->cells, info);
1859 cell_groups_rebuild (box);
1863 gtk_cell_area_box_get_spacing (GtkCellAreaBox *box)
1865 g_return_val_if_fail (GTK_IS_CELL_AREA_BOX (box), 0);
1867 return box->priv->spacing;
1871 gtk_cell_area_box_set_spacing (GtkCellAreaBox *box,
1874 GtkCellAreaBoxPrivate *priv;
1876 g_return_if_fail (GTK_IS_CELL_AREA_BOX (box));
1880 if (priv->spacing != spacing)
1882 priv->spacing = spacing;
1884 g_object_notify (G_OBJECT (box), "spacing");
1886 /* Notify that size needs to be requested again */
1887 flush_contexts (box);