gtkcellareacontext.c 22.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
/* gtkcellareacontext.c
 *
 * Copyright (C) 2010 Openismus GmbH
 *
 * Authors:
 *      Tristan Van Berkom <tristanvb@openismus.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
Javier Jardón's avatar
Javier Jardón committed
19
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 21
 */

22 23
/**
 * SECTION:gtkcellareacontext
24
 * @Short_Description: Stores geometrical information for a series of rows in a GtkCellArea
25 26
 * @Title: GtkCellAreaContext
 *
Matthias Clasen's avatar
Matthias Clasen committed
27
 * The #GtkCellAreaContext object is created by a given #GtkCellArea
28
 * implementation via its #GtkCellAreaClass.create_context() virtual
Matthias Clasen's avatar
Matthias Clasen committed
29 30
 * method and is used to store cell sizes and alignments for a series of
 * #GtkTreeModel rows that are requested and rendered in the same context.
31
 *
Matthias Clasen's avatar
Matthias Clasen committed
32
 * #GtkCellLayout widgets can create any number of contexts in which to
33
 * request and render groups of data rows. However, it’s important that the
Matthias Clasen's avatar
Matthias Clasen committed
34 35 36
 * same context which was used to request sizes for a given #GtkTreeModel
 * row also be used for the same row when calling other #GtkCellArea APIs
 * such as gtk_cell_area_render() and gtk_cell_area_event().
37
 */
Matthias Clasen's avatar
Matthias Clasen committed
38

39 40 41 42 43 44 45
#include "config.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
#include "gtkcellareacontext.h"
#include "gtkprivate.h"

/* GObjectClass */
Matthias Clasen's avatar
Matthias Clasen committed
46 47 48 49 50 51 52 53 54
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);
55 56

/* GtkCellAreaContextClass */
Matthias Clasen's avatar
Matthias Clasen committed
57 58 59 60
static void gtk_cell_area_context_real_reset    (GtkCellAreaContext *context);
static void gtk_cell_area_context_real_allocate (GtkCellAreaContext *context,
                                                 gint                width,
                                                 gint                height);
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

struct _GtkCellAreaContextPrivate
{
  GtkCellArea *cell_area;

  gint         min_width;
  gint         nat_width;
  gint         min_height;
  gint         nat_height;
  gint         alloc_width;
  gint         alloc_height;
};

enum {
  PROP_0,
  PROP_CELL_AREA,
  PROP_MIN_WIDTH,
  PROP_NAT_WIDTH,
  PROP_MIN_HEIGHT,
  PROP_NAT_HEIGHT
};

83
G_DEFINE_TYPE_WITH_PRIVATE (GtkCellAreaContext, gtk_cell_area_context, G_TYPE_OBJECT)
84 85 86 87

static void
gtk_cell_area_context_init (GtkCellAreaContext *context)
{
88
  context->priv = gtk_cell_area_context_get_instance_private (context);
89 90
}

Matthias Clasen's avatar
Matthias Clasen committed
91
static void
92 93 94 95 96 97 98 99 100 101
gtk_cell_area_context_class_init (GtkCellAreaContextClass *class)
{
  GObjectClass     *object_class = G_OBJECT_CLASS (class);

  /* GObjectClass */
  object_class->dispose      = gtk_cell_area_context_dispose;
  object_class->get_property = gtk_cell_area_context_get_property;
  object_class->set_property = gtk_cell_area_context_set_property;

  /* GtkCellAreaContextClass */
102 103
  class->reset    = gtk_cell_area_context_real_reset;
  class->allocate = gtk_cell_area_context_real_allocate;
104

105 106 107 108 109 110 111
  /**
   * GtkCellAreaContext:area:
   *
   * The #GtkCellArea this context was created by
   *
   * Since: 3.0
   */
112 113 114
  g_object_class_install_property (object_class,
                                   PROP_CELL_AREA,
                                   g_param_spec_object ("area",
Matthias Clasen's avatar
Matthias Clasen committed
115 116 117 118
                                                        P_("Area"),
                                                        P_("The Cell Area this context was created for"),
                                                        GTK_TYPE_CELL_AREA,
                                                        GTK_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
119

120 121 122 123 124 125 126 127 128
  /**
   * GtkCellAreaContext:minimum-width:
   *
   * The minimum width for the #GtkCellArea in this context
   * for all #GtkTreeModel rows that this context was requested
   * for using gtk_cell_area_get_preferred_width().
   *
   * Since: 3.0
   */
129 130 131
  g_object_class_install_property (object_class,
                                   PROP_MIN_WIDTH,
                                   g_param_spec_int ("minimum-width",
Matthias Clasen's avatar
Matthias Clasen committed
132 133 134 135 136 137
                                                     P_("Minimum Width"),
                                                     P_("Minimum cached width"),
                                                     -1,
                                                     G_MAXINT,
                                                     -1,
                                                     G_PARAM_READABLE));
138

139 140 141 142 143 144 145 146 147
  /**
   * GtkCellAreaContext:natural-width:
   *
   * The natural width for the #GtkCellArea in this context
   * for all #GtkTreeModel rows that this context was requested
   * for using gtk_cell_area_get_preferred_width().
   *
   * Since: 3.0
   */
148 149 150
  g_object_class_install_property (object_class,
                                   PROP_NAT_WIDTH,
                                   g_param_spec_int ("natural-width",
Matthias Clasen's avatar
Matthias Clasen committed
151 152 153 154 155 156
                                                     P_("Minimum Width"),
                                                     P_("Minimum cached width"),
                                                     -1,
                                                     G_MAXINT,
                                                     -1,
                                                     G_PARAM_READABLE));
157

158 159 160 161 162 163 164 165 166
  /**
   * GtkCellAreaContext:minimum-height:
   *
   * The minimum height for the #GtkCellArea in this context
   * for all #GtkTreeModel rows that this context was requested
   * for using gtk_cell_area_get_preferred_height().
   *
   * Since: 3.0
   */
167 168 169
  g_object_class_install_property (object_class,
                                   PROP_MIN_HEIGHT,
                                   g_param_spec_int ("minimum-height",
Matthias Clasen's avatar
Matthias Clasen committed
170 171 172 173 174 175
                                                     P_("Minimum Height"),
                                                     P_("Minimum cached height"),
                                                     -1,
                                                     G_MAXINT,
                                                     -1,
                                                     G_PARAM_READABLE));
176

177 178 179 180 181 182 183 184 185
  /**
   * GtkCellAreaContext:natural-height:
   *
   * The natural height for the #GtkCellArea in this context
   * for all #GtkTreeModel rows that this context was requested
   * for using gtk_cell_area_get_preferred_height().
   *
   * Since: 3.0
   */
186 187 188
  g_object_class_install_property (object_class,
                                   PROP_NAT_HEIGHT,
                                   g_param_spec_int ("natural-height",
Matthias Clasen's avatar
Matthias Clasen committed
189 190 191 192 193 194
                                                     P_("Minimum Height"),
                                                     P_("Minimum cached height"),
                                                     -1,
                                                     G_MAXINT,
                                                     -1,
                                                     G_PARAM_READABLE));
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
}

/*************************************************************
 *                      GObjectClass                         *
 *************************************************************/
static void
gtk_cell_area_context_dispose (GObject *object)
{
  GtkCellAreaContext        *context = GTK_CELL_AREA_CONTEXT (object);
  GtkCellAreaContextPrivate *priv = context->priv;

  if (priv->cell_area)
    {
      g_object_unref (priv->cell_area);

      priv->cell_area = NULL;
    }

  G_OBJECT_CLASS (gtk_cell_area_context_parent_class)->dispose (object);
}

static void
gtk_cell_area_context_set_property (GObject      *object,
Matthias Clasen's avatar
Matthias Clasen committed
218 219 220
                                    guint         prop_id,
                                    const GValue *value,
                                    GParamSpec   *pspec)
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
{
  GtkCellAreaContext        *context = GTK_CELL_AREA_CONTEXT (object);
  GtkCellAreaContextPrivate *priv = context->priv;

  switch (prop_id)
    {
    case PROP_CELL_AREA:
      priv->cell_area = g_value_dup_object (value);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
gtk_cell_area_context_get_property (GObject     *object,
Matthias Clasen's avatar
Matthias Clasen committed
238 239 240
                                    guint        prop_id,
                                    GValue      *value,
                                    GParamSpec  *pspec)
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
{
  GtkCellAreaContext        *context = GTK_CELL_AREA_CONTEXT (object);
  GtkCellAreaContextPrivate *priv = context->priv;

  switch (prop_id)
    {
    case PROP_CELL_AREA:
      g_value_set_object (value, priv->cell_area);
      break;
    case PROP_MIN_WIDTH:
      g_value_set_int (value, priv->min_width);
      break;
    case PROP_NAT_WIDTH:
      g_value_set_int (value, priv->nat_width);
      break;
    case PROP_MIN_HEIGHT:
      g_value_set_int (value, priv->min_height);
      break;
    case PROP_NAT_HEIGHT:
      g_value_set_int (value, priv->nat_height);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

/*************************************************************
Matthias Clasen's avatar
Matthias Clasen committed
269
 *                    GtkCellAreaContextClass                *
270 271
 *************************************************************/
static void
272
gtk_cell_area_context_real_reset (GtkCellAreaContext *context)
273 274
{
  GtkCellAreaContextPrivate *priv = context->priv;
Matthias Clasen's avatar
Matthias Clasen committed
275

276 277
  g_object_freeze_notify (G_OBJECT (context));

278
  if (priv->min_width != 0)
279
    {
280
      priv->min_width = 0;
281 282 283
      g_object_notify (G_OBJECT (context), "minimum-width");
    }

284
  if (priv->nat_width != 0)
285
    {
286
      priv->nat_width = 0;
287 288 289
      g_object_notify (G_OBJECT (context), "natural-width");
    }

290
  if (priv->min_height != 0)
291
    {
292
      priv->min_height = 0;
293 294 295
      g_object_notify (G_OBJECT (context), "minimum-height");
    }

296
  if (priv->nat_height != 0)
297
    {
298
      priv->nat_height = 0;
299 300 301
      g_object_notify (G_OBJECT (context), "natural-height");
    }

302 303
  priv->alloc_width  = 0;
  priv->alloc_height = 0;
304 305 306 307 308

  g_object_thaw_notify (G_OBJECT (context));
}

static void
309
gtk_cell_area_context_real_allocate (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
310 311
                                     gint                width,
                                     gint                height)
312 313 314
{
  GtkCellAreaContextPrivate *priv = context->priv;

315
  priv->alloc_width  = width;
316 317 318 319 320 321
  priv->alloc_height = height;
}

/*************************************************************
 *                            API                            *
 *************************************************************/
322 323 324 325 326 327
/**
 * gtk_cell_area_context_get_area:
 * @context: a #GtkCellAreaContext
 *
 * Fetches the #GtkCellArea this @context was created by.
 *
328
 * This is generally unneeded by layouting widgets; however,
Matthias Clasen's avatar
Matthias Clasen committed
329
 * it is important for the context implementation itself to
330 331 332
 * fetch information about the area it is being used for.
 *
 * For instance at #GtkCellAreaContextClass.allocate() time
333
 * it’s important to know details about any cell spacing
Matthias Clasen's avatar
Matthias Clasen committed
334
 * that the #GtkCellArea is configured with in order to
335 336
 * compute a proper allocation.
 *
337
 * Returns: (transfer none): the #GtkCellArea this context was created by.
338 339 340
 *
 * Since: 3.0
 */
341 342 343 344 345 346 347 348 349 350 351 352
GtkCellArea *
gtk_cell_area_context_get_area (GtkCellAreaContext *context)
{
  GtkCellAreaContextPrivate *priv;

  g_return_val_if_fail (GTK_IS_CELL_AREA_CONTEXT (context), NULL);

  priv = context->priv;

  return priv->cell_area;
}

353 354 355 356 357
/**
 * gtk_cell_area_context_reset:
 * @context: a #GtkCellAreaContext
 *
 * Resets any previously cached request and allocation
Matthias Clasen's avatar
Matthias Clasen committed
358
 * data.
359
 *
360
 * When underlying #GtkTreeModel data changes its
361 362 363 364 365
 * important to reset the context if the content
 * size is allowed to shrink. If the content size
 * is only allowed to grow (this is usually an option
 * for views rendering large data stores as a measure
 * of optimization), then only the row that changed
Matthias Clasen's avatar
Matthias Clasen committed
366
 * or was inserted needs to be (re)requested with
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
 * gtk_cell_area_get_preferred_width().
 *
 * When the new overall size of the context requires
 * that the allocated size changes (or whenever this
 * allocation changes at all), the variable row
 * sizes need to be re-requested for every row.
 *
 * For instance, if the rows are displayed all with
 * the same width from top to bottom then a change
 * in the allocated width necessitates a recalculation
 * of all the displayed row heights using
 * gtk_cell_area_get_preferred_height_for_width().
 *
 * Since 3.0
 */
382
void
383
gtk_cell_area_context_reset (GtkCellAreaContext *context)
384 385 386
{
  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

387
  GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->reset (context);
388 389
}

390 391 392
/**
 * gtk_cell_area_context_allocate:
 * @context: a #GtkCellAreaContext
Matthias Clasen's avatar
Matthias Clasen committed
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407
 * @width: the allocated width for all #GtkTreeModel rows rendered
 *     with @context, or -1.
 * @height: the allocated height for all #GtkTreeModel rows rendered
 *     with @context, or -1.
 *
 * Allocates a width and/or a height for all rows which are to be
 * rendered with @context.
 *
 * Usually allocation is performed only horizontally or sometimes
 * vertically since a group of rows are usually rendered side by
 * side vertically or horizontally and share either the same width
 * or the same height. Sometimes they are allocated in both horizontal
 * and vertical orientations producing a homogeneous effect of the
 * rows. This is generally the case for #GtkTreeView when
 * #GtkTreeView:fixed-height-mode is enabled.
408 409 410
 *
 * Since 3.0
 */
411
void
412
gtk_cell_area_context_allocate (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
413 414
                                gint                width,
                                gint                height)
415 416 417
{
  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

418
  GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->allocate (context, width, height);
419 420
}

421 422 423
/**
 * gtk_cell_area_context_get_preferred_width:
 * @context: a #GtkCellAreaContext
Matthias Clasen's avatar
Matthias Clasen committed
424 425 426 427
 * @minimum_width: (out) (allow-none): location to store the minimum width,
 *     or %NULL
 * @natural_width: (out) (allow-none): location to store the natural width,
 *     or %NULL
428
 *
Matthias Clasen's avatar
Matthias Clasen committed
429 430
 * Gets the accumulative preferred width for all rows which have been
 * requested with this context.
431
 *
Matthias Clasen's avatar
Matthias Clasen committed
432
 * After gtk_cell_area_context_reset() is called and/or before ever
433
 * requesting the size of a #GtkCellArea, the returned values are 0.
434
 *
Matthias Clasen's avatar
Matthias Clasen committed
435
 * Since: 3.0
436
 */
437 438
void
gtk_cell_area_context_get_preferred_width (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
439 440
                                           gint               *minimum_width,
                                           gint               *natural_width)
441 442 443 444 445 446 447 448 449 450 451 452 453 454
{
  GtkCellAreaContextPrivate *priv;

  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

  priv = context->priv;

  if (minimum_width)
    *minimum_width = priv->min_width;

  if (natural_width)
    *natural_width = priv->nat_width;
}

455 456 457
/**
 * gtk_cell_area_context_get_preferred_height:
 * @context: a #GtkCellAreaContext
Matthias Clasen's avatar
Matthias Clasen committed
458 459 460 461
 * @minimum_height: (out) (allow-none): location to store the minimum height,
 *     or %NULL
 * @natural_height: (out) (allow-none): location to store the natural height,
 *     or %NULL
462
 *
Matthias Clasen's avatar
Matthias Clasen committed
463 464
 * Gets the accumulative preferred height for all rows which have been
 * requested with this context.
465
 *
Matthias Clasen's avatar
Matthias Clasen committed
466
 * After gtk_cell_area_context_reset() is called and/or before ever
467
 * requesting the size of a #GtkCellArea, the returned values are 0.
468 469 470
 *
 * Since: 3.0
 */
471 472
void
gtk_cell_area_context_get_preferred_height (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
473 474
                                            gint               *minimum_height,
                                            gint               *natural_height)
475 476 477 478 479 480 481 482 483 484 485 486 487 488
{
  GtkCellAreaContextPrivate *priv;

  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

  priv = context->priv;

  if (minimum_height)
    *minimum_height = priv->min_height;

  if (natural_height)
    *natural_height = priv->nat_height;
}

489 490 491 492
/**
 * gtk_cell_area_context_get_preferred_height_for_width:
 * @context: a #GtkCellAreaContext
 * @width: a proposed width for allocation
Matthias Clasen's avatar
Matthias Clasen committed
493 494 495 496
 * @minimum_height: (out) (allow-none): location to store the minimum height,
 *     or %NULL
 * @natural_height: (out) (allow-none): location to store the natural height,
 *     or %NULL
497
 *
Matthias Clasen's avatar
Matthias Clasen committed
498 499
 * Gets the accumulative preferred height for @width for all rows
 * which have been requested for the same said @width with this context.
500
 *
Matthias Clasen's avatar
Matthias Clasen committed
501 502
 * After gtk_cell_area_context_reset() is called and/or before ever
 * requesting the size of a #GtkCellArea, the returned values are -1.
503 504 505 506 507
 *
 * Since: 3.0
 */
void
gtk_cell_area_context_get_preferred_height_for_width (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
508 509 510
                                                      gint                width,
                                                      gint               *minimum_height,
                                                      gint               *natural_height)
511 512 513 514 515
{
  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

  if (GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->get_preferred_height_for_width)
    GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->get_preferred_height_for_width (context,
Matthias Clasen's avatar
Matthias Clasen committed
516 517 518
                                                                               width,
                                                                               minimum_height,
                                                                               natural_height);
519 520 521 522 523 524
}

/**
 * gtk_cell_area_context_get_preferred_width_for_height:
 * @context: a #GtkCellAreaContext
 * @height: a proposed height for allocation
Matthias Clasen's avatar
Matthias Clasen committed
525 526 527 528
 * @minimum_width: (out) (allow-none): location to store the minimum width,
 *     or %NULL
 * @natural_width: (out) (allow-none): location to store the natural width,
 *     or %NULL
529
 *
Matthias Clasen's avatar
Matthias Clasen committed
530 531
 * Gets the accumulative preferred width for @height for all rows which
 * have been requested for the same said @height with this context.
532
 *
Matthias Clasen's avatar
Matthias Clasen committed
533 534
 * After gtk_cell_area_context_reset() is called and/or before ever
 * requesting the size of a #GtkCellArea, the returned values are -1.
535
 *
Matthias Clasen's avatar
Matthias Clasen committed
536
 * Since: 3.0
537 538 539
 */
void
gtk_cell_area_context_get_preferred_width_for_height (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
540 541 542 543
                                                      gint                height,
                                                      gint               *minimum_width,
                                                      gint               *natural_width)
{
544 545 546 547
  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

  if (GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->get_preferred_width_for_height)
    GTK_CELL_AREA_CONTEXT_GET_CLASS (context)->get_preferred_width_for_height (context,
Matthias Clasen's avatar
Matthias Clasen committed
548 549 550
                                                                               height,
                                                                               minimum_width,
                                                                               natural_width);
551 552
}

553 554 555
/**
 * gtk_cell_area_context_get_allocation:
 * @context: a #GtkCellAreaContext
Matthias Clasen's avatar
Matthias Clasen committed
556 557
 * @width: (out) (allow-none): location to store the allocated width, or %NULL
 * @height: (out) (allow-none): location to store the allocated height, or %NULL
558 559 560 561 562 563 564 565 566
 *
 * Fetches the current allocation size for @context.
 *
 * If the context was not allocated in width or height, or if the
 * context was recently reset with gtk_cell_area_context_reset(),
 * the returned value will be -1.
 *
 * Since: 3.0
 */
567 568
void
gtk_cell_area_context_get_allocation (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
569 570
                                      gint               *width,
                                      gint               *height)
571 572 573 574 575 576 577 578 579 580 581 582 583 584
{
  GtkCellAreaContextPrivate *priv;

  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

  priv = context->priv;

  if (width)
    *width = priv->alloc_width;

  if (height)
    *height = priv->alloc_height;
}

585 586 587
/**
 * gtk_cell_area_context_push_preferred_width:
 * @context: a #GtkCellAreaContext
Matthias Clasen's avatar
Matthias Clasen committed
588 589
 * @minimum_width: the proposed new minimum width for @context
 * @natural_width: the proposed new natural width for @context
590 591 592 593 594 595 596 597 598 599 600
 *
 * Causes the minimum and/or natural width to grow if the new
 * proposed sizes exceed the current minimum and natural width.
 *
 * This is used by #GtkCellAreaContext implementations during
 * the request process over a series of #GtkTreeModel rows to
 * progressively push the requested width over a series of
 * gtk_cell_area_get_preferred_width() requests.
 *
 * Since: 3.0
 */
601 602
void
gtk_cell_area_context_push_preferred_width (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
603 604
                                            gint                minimum_width,
                                            gint                natural_width)
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630
{
  GtkCellAreaContextPrivate *priv;

  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

  priv = context->priv;

  g_object_freeze_notify (G_OBJECT (context));

  if (minimum_width > priv->min_width)
    {
      priv->min_width = minimum_width;

      g_object_notify (G_OBJECT (context), "minimum-width");
    }

  if (natural_width > priv->nat_width)
    {
      priv->nat_width = natural_width;

      g_object_notify (G_OBJECT (context), "natural-width");
    }

  g_object_thaw_notify (G_OBJECT (context));
}

631 632 633
/**
 * gtk_cell_area_context_push_preferred_height:
 * @context: a #GtkCellAreaContext
Matthias Clasen's avatar
Matthias Clasen committed
634 635
 * @minimum_height: the proposed new minimum height for @context
 * @natural_height: the proposed new natural height for @context
636 637 638 639 640 641 642 643 644 645 646
 *
 * Causes the minimum and/or natural height to grow if the new
 * proposed sizes exceed the current minimum and natural height.
 *
 * This is used by #GtkCellAreaContext implementations during
 * the request process over a series of #GtkTreeModel rows to
 * progressively push the requested height over a series of
 * gtk_cell_area_get_preferred_height() requests.
 *
 * Since: 3.0
 */
647 648
void
gtk_cell_area_context_push_preferred_height (GtkCellAreaContext *context,
Matthias Clasen's avatar
Matthias Clasen committed
649 650
                                             gint                minimum_height,
                                             gint                natural_height)
651 652
{
  GtkCellAreaContextPrivate *priv;
Matthias Clasen's avatar
Matthias Clasen committed
653

654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675
  g_return_if_fail (GTK_IS_CELL_AREA_CONTEXT (context));

  priv = context->priv;

  g_object_freeze_notify (G_OBJECT (context));

  if (minimum_height > priv->min_height)
    {
      priv->min_height = minimum_height;

      g_object_notify (G_OBJECT (context), "minimum-height");
    }

  if (natural_height > priv->nat_height)
    {
      priv->nat_height = natural_height;

      g_object_notify (G_OBJECT (context), "natural-height");
    }

  g_object_thaw_notify (G_OBJECT (context));
}