+ * (or the cellview has its own context and is not grouped with any other cell views)
+ *
+ * If the cellview is in "fit model" mode, we assume it's not in context and needs to
+ * allocate every time.
+ */
+ if (priv->fit_model)
+ gtk_cell_area_context_allocate (priv->context, allocation->width, allocation->height);
+ else if (alloc_width != allocation->width && priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+ gtk_cell_area_context_allocate (priv->context, allocation->width, -1);
+ else if (alloc_height != allocation->height && priv->orientation == GTK_ORIENTATION_VERTICAL)
+ gtk_cell_area_context_allocate (priv->context, -1, allocation->height);
+}
+
+static void
+gtk_cell_view_request_model (GtkCellView *cellview,
+ GtkTreeIter *parent,
+ GtkOrientation orientation,
+ gint for_size,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkCellViewPrivate *priv = cellview->priv;
+ GtkTreeIter iter;
+ gboolean valid;
+
+ if (!priv->model)
+ return;
+
+ valid = gtk_tree_model_iter_children (priv->model, &iter, parent);
+ while (valid)
+ {
+ gint min, nat;
+
+ gtk_cell_area_apply_attributes (priv->area, priv->model, &iter, FALSE, FALSE);
+
+ if (orientation == GTK_ORIENTATION_HORIZONTAL)
+ {
+ if (for_size < 0)
+ gtk_cell_area_get_preferred_width (priv->area, priv->context,
+ GTK_WIDGET (cellview), &min, &nat);
+ else
+ gtk_cell_area_get_preferred_width_for_height (priv->area, priv->context,
+ GTK_WIDGET (cellview), for_size, &min, &nat);
+ }
+ else
+ {
+ if (for_size < 0)
+ gtk_cell_area_get_preferred_height (priv->area, priv->context,
+ GTK_WIDGET (cellview), &min, &nat);
+ else
+ gtk_cell_area_get_preferred_height_for_width (priv->area, priv->context,
+ GTK_WIDGET (cellview), for_size, &min, &nat);
+ }
+
+ *minimum_size = MAX (min, *minimum_size);
+ *natural_size = MAX (nat, *natural_size);
+
+ /* Recurse into children when they exist */
+ gtk_cell_view_request_model (cellview, &iter, orientation, for_size, minimum_size, natural_size);
+
+ valid = gtk_tree_model_iter_next (priv->model, &iter);
+ }
+}
+
+static GtkSizeRequestMode
+gtk_cell_view_get_request_mode (GtkWidget *widget)
+{
+ GtkCellView *cellview = GTK_CELL_VIEW (widget);
+ GtkCellViewPrivate *priv = cellview->priv;
+
+ return gtk_cell_area_get_request_mode (priv->area);
+}
+
+static void
+gtk_cell_view_get_preferred_width (GtkWidget *widget,
+ gint *minimum_size,
+ gint *natural_size)
+{
+ GtkCellView *cellview = GTK_CELL_VIEW (widget);
+ GtkCellViewPrivate *priv = cellview->priv;
+
+ g_signal_handler_block (priv->context, priv->size_changed_id);
+
+ if (priv->fit_model)
+ {
+ gint min = 0, nat = 0;
+ gtk_cell_view_request_model (cellview, NULL, GTK_ORIENTATION_HORIZONTAL, -1, &min, &nat);
+ }
+ else