gtkcenterbox.c 20.1 KB
Newer Older
Matthias Clasen's avatar
Matthias Clasen committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
/*
 * Copyright (c) 2017 Timm Bäder <mail@baedert.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 *
 * This program 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 Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * Author: Timm Bäder <mail@baedert.org>
 */

/**
 * SECTION:gtkcenterbox
 * @Short_description: A centering container
 * @Title: GtkCenterBox
 * @See_also: #GtkBox
 *
 * The GtkCenterBox widget arranges three children in a horizontal
 * or vertical arrangement, keeping the middle child centered as well
 * as possible.
 *
 * To add children to GtkCenterBox, use gtk_center_box_set_start_widget(),
 * gtk_center_box_set_center_widget() and gtk_center_box_set_end_widget().
 *
 * # CSS nodes
 *
 * GtkCenterBox uses a single CSS node with name box.
 *
 * In horizontal orientation, the nodes of the children are always arranged
 * from left to right. So :first-child will always select the leftmost child,
 * regardless of text direction.
 *
 * In vertical orientation, the are arranged from top to bottom.
 */

#include "config.h"
#include "gtkcenterbox.h"
#include "gtkcssnodeprivate.h"
#include "gtkwidgetprivate.h"
49 50
#include "gtkorientable.h"
#include "gtkorientableprivate.h"
51
#include "gtkbuildable.h"
52
#include "gtksizerequest.h"
Matthias Clasen's avatar
Matthias Clasen committed
53 54 55 56 57 58 59 60 61

struct _GtkCenterBox
{
  GtkWidget parent_instance;

  GtkWidget *start_widget;
  GtkWidget *center_widget;
  GtkWidget *end_widget;

62 63
  GtkOrientation orientation;
};
Matthias Clasen's avatar
Matthias Clasen committed
64 65 66 67 68

struct _GtkCenterBoxClass
{
  GtkWidgetClass parent_class;
};
69 70


71 72 73 74 75
enum {
  PROP_0,
  PROP_ORIENTATION
};

76
static void gtk_center_box_buildable_init (GtkBuildableIface *iface);
77

78
G_DEFINE_TYPE_WITH_CODE (GtkCenterBox, gtk_center_box, GTK_TYPE_WIDGET,
79 80
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_ORIENTABLE, NULL)
                         G_IMPLEMENT_INTERFACE (GTK_TYPE_BUILDABLE, gtk_center_box_buildable_init))
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102

static void
gtk_center_box_buildable_add_child (GtkBuildable  *buildable,
                                    GtkBuilder    *builder,
                                    GObject       *child,
                                    const gchar   *type)
{
  if (g_strcmp0 (type, "start") == 0)
    gtk_center_box_set_start_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
  else if (g_strcmp0 (type, "center") == 0)
    gtk_center_box_set_center_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
  else if (g_strcmp0 (type, "end") == 0)
    gtk_center_box_set_end_widget (GTK_CENTER_BOX (buildable), GTK_WIDGET (child));
  else
    GTK_BUILDER_WARN_INVALID_CHILD_TYPE (GTK_CENTER_BOX (buildable), type);
}

static void
gtk_center_box_buildable_init (GtkBuildableIface *iface)
{
  iface->add_child = gtk_center_box_buildable_add_child;
}
103

104 105 106 107 108 109 110 111 112 113
static gboolean
get_expand (GtkWidget      *widget,
            GtkOrientation  orientation)
{
  if (orientation == GTK_ORIENTATION_HORIZONTAL)
    return gtk_widget_get_hexpand (widget);
  else
    return gtk_widget_get_vexpand (widget);
}

114
static void
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
gtk_center_box_distribute (GtkCenterBox     *self,
                           gint              for_size,
                           gint              size,
                           GtkRequestedSize *sizes)
{
  int center_size = 0;
  int start_size = 0;
  int end_size = 0;
  gboolean center_expand = FALSE;
  gboolean start_expand = FALSE;
  gboolean end_expand = FALSE;
  int avail;

  sizes[0].minimum_size = sizes[0].natural_size = 0;
  sizes[1].minimum_size = sizes[1].natural_size = 0;
  sizes[2].minimum_size = sizes[2].natural_size = 0;

  if (self->start_widget)
    gtk_widget_measure (self->start_widget,
134
                        self->orientation,
135 136 137 138 139 140
                        for_size,
                        &sizes[0].minimum_size, &sizes[0].natural_size,
                        NULL, NULL);

  if (self->center_widget)
    gtk_widget_measure (self->center_widget,
141
                        self->orientation,
142 143 144 145 146 147 148
                        for_size,
                        &sizes[1].minimum_size, &sizes[1].natural_size,
                        NULL, NULL);


  if (self->end_widget)
    gtk_widget_measure (self->end_widget,
149
                        self->orientation,
150 151 152 153 154 155 156
                        for_size,
                        &sizes[2].minimum_size, &sizes[2].natural_size,
                        NULL, NULL);

  if (self->center_widget)
    {
      center_size = CLAMP (size - (sizes[0].minimum_size + sizes[2].minimum_size), sizes[1].minimum_size, sizes[1].natural_size);
157
      center_expand = get_expand (self->center_widget, self->orientation);
158 159 160 161 162 163
    }

  if (self->start_widget)
    {
      avail = MIN ((size - center_size) / 2, size - (center_size + sizes[2].minimum_size));
      start_size = CLAMP (avail, sizes[0].minimum_size, sizes[0].natural_size);
164
      start_expand = get_expand (self->start_widget, self->orientation);
165 166 167 168 169 170 171
    }

  if (self->end_widget)
    {
      avail = MIN ((size - center_size) / 2, size - (center_size + sizes[0].minimum_size));
      end_size = CLAMP (avail, sizes[2].minimum_size, sizes[2].natural_size);
      end_expand = gtk_widget_get_hexpand (self->end_widget);
172
      end_expand = get_expand (self->end_widget, self->orientation);
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228
    }

  if (self->center_widget)
    {
      int center_pos;

      center_pos = (size / 2) - (center_size / 2);

      /* Push in from start/end */
      if (start_size > center_pos)
        center_pos = start_size;
      else if (size - end_size < center_pos + center_size)
        center_pos = size - center_size - end_size;
      else if (center_expand)
        {
          center_size = size - 2 * MAX (start_size, end_size);
          center_pos = (size / 2) - (center_size / 2);
        }

      if (start_expand)
        start_size = center_pos;

      if (end_expand)
        end_size = size - center_pos + center_size;
    }
  else
    {
      avail = size - (start_size + end_size);
      if (start_expand && end_expand)
        {
          start_size += avail / 2;
          end_size += avail / 2;
        }
      else if (start_expand)
        {
          start_size += avail;
        }
      else if (end_expand)
        {
          end_size += avail;
        }
    }

  sizes[0].minimum_size = start_size;
  sizes[1].minimum_size = center_size;
  sizes[2].minimum_size = end_size;
}

static void
gtk_center_box_measure_orientation (GtkWidget      *widget,
                                    GtkOrientation  orientation,
                                    int             for_size,
                                    int            *minimum,
                                    int            *natural,
                                    int            *minimum_baseline,
                                    int            *natural_baseline)
229 230
{
  GtkCenterBox *self = GTK_CENTER_BOX (widget);
231 232 233 234 235 236 237
  int min_baseline, nat_baseline;
  int start_min = 0;
  int start_nat = 0;
  int center_min = 0;
  int center_nat = 0;
  int end_min = 0;
  int end_nat = 0;
238

239
  if (self->start_widget)
240 241 242 243 244
    gtk_widget_measure (self->start_widget,
                        orientation,
                        for_size,
                        &start_min, &start_nat,
                        &min_baseline, &nat_baseline);
245

246
  if (self->center_widget)
247 248 249 250 251
    gtk_widget_measure (self->center_widget,
                        orientation,
                        for_size,
                        &center_min, &center_nat,
                        &min_baseline, &nat_baseline);
252 253

  if (self->end_widget)
254 255 256 257 258 259
    gtk_widget_measure (self->end_widget,
                        orientation,
                        for_size,
                        &end_min, &end_nat,
                        &min_baseline, &nat_baseline);

260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
  *minimum = start_min + center_min + end_min;
  *natural = center_nat + 2 * MAX (start_nat, end_nat);
}

static void
gtk_center_box_measure_opposite (GtkWidget      *widget,
                                 GtkOrientation  orientation,
                                 int             for_size,
                                 int            *minimum,
                                 int            *natural,
                                 int            *minimum_baseline,
                                 int            *natural_baseline)
{
  GtkCenterBox *self = GTK_CENTER_BOX (widget);
  int min_baseline, nat_baseline;
  int start_min = 0;
  int start_nat = 0;
  int center_min = 0;
  int center_nat = 0;
  int end_min = 0;
  int end_nat = 0;
  GtkRequestedSize sizes[3];

  if (for_size >= 0)
    gtk_center_box_distribute (self, -1, for_size, sizes);

  if (self->start_widget)
    gtk_widget_measure (self->start_widget,
                        orientation,
                        for_size >= 0 ? sizes[0].minimum_size : -1,
                        &start_min, &start_nat,
                        &min_baseline, &nat_baseline);

  if (self->center_widget)
    gtk_widget_measure (self->center_widget,
                        orientation,
                        for_size >= 0 ? sizes[1].minimum_size : -1,
                        &center_min, &center_nat,
                        &min_baseline, &nat_baseline);

  if (self->end_widget)
    gtk_widget_measure (self->end_widget,
                        orientation,
                        for_size >= 0 ? sizes[2].minimum_size : -1,
                        &end_min, &end_nat,
                        &min_baseline, &nat_baseline);

  *minimum = MAX (start_min, MAX (center_min, end_min));
  *natural = MAX (start_nat, MAX (center_nat, end_nat));
}

static void
gtk_center_box_measure (GtkWidget      *widget,
                        GtkOrientation  orientation,
                        int             for_size,
                        int            *minimum,
                        int            *natural,
                        int            *minimum_baseline,
                        int            *natural_baseline)
{
320 321 322
  GtkCenterBox *self = GTK_CENTER_BOX (widget);

  if (self->orientation == orientation)
323 324 325
    gtk_center_box_measure_orientation (widget, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
  else
    gtk_center_box_measure_opposite (widget, orientation, for_size, minimum, natural, minimum_baseline, natural_baseline);
326 327
}

328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
#define SET_CHILD_ALLOC(pos,size) \
      if (self->orientation == GTK_ORIENTATION_HORIZONTAL) \
        { \
          child_allocation.x = allocation->x + (pos); \
          child_allocation.y = allocation->y; \
          child_allocation.width = (size); \
          child_allocation.height = allocation->height; \
        } \
      else \
        { \
          child_allocation.x = allocation->x; \
          child_allocation.y = allocation->y + (pos); \
          child_allocation.width = allocation->width; \
          child_allocation.height = (size); \
        }

344 345 346 347 348 349 350 351
static void
gtk_center_box_size_allocate (GtkWidget     *widget,
                              GtkAllocation *allocation)
{
  GtkCenterBox *self = GTK_CENTER_BOX (widget);
  GtkAllocation child_allocation;
  GtkAllocation clip = *allocation;
  GtkAllocation child_clip;
352 353 354 355 356 357
  GtkWidget *start;
  GtkWidget *center;
  GtkWidget *end;
  int start_size = 0;
  int center_size = 0;
  int end_size = 0;
358
  GtkRequestedSize sizes[3];
359 360 361
  int size;
  int for_size;
  int child_pos;
362 363 364

  GTK_WIDGET_CLASS (gtk_center_box_parent_class)->size_allocate (widget, allocation);

365 366 367 368 369 370 371 372 373 374 375 376
  if (self->orientation == GTK_ORIENTATION_HORIZONTAL)
    {
      size = allocation->width;
      for_size = allocation->height;
    }
  else
    {
      size = allocation->height;
      for_size = allocation->width;
    }

  gtk_center_box_distribute (self, for_size, size, sizes);
377

378 379
  if (self->orientation == GTK_ORIENTATION_HORIZONTAL &&
      gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
380
    {
381 382 383 384
      start = self->end_widget;
      start_size = sizes[2].minimum_size;
      end = self->start_widget;
      end_size = sizes[0].minimum_size;
385 386 387
    }
  else
    {
388 389 390 391
      start = self->start_widget;
      start_size = sizes[0].minimum_size;
      end = self->end_widget;
      end_size = sizes[2].minimum_size;
392
    }
393

394 395
  center = self->center_widget;
  center_size = sizes[1].minimum_size;
396

397 398 399
  child_allocation = *allocation;

  if (center)
400
    {
401
      child_pos = (size / 2) - (center_size / 2);
402 403

      /* Push in from start/end */
404 405 406 407 408 409 410 411 412
      if (start_size > child_pos)
        child_pos = start_size;
      else if (size - end_size < child_pos + center_size)
        child_pos = size - center_size - end_size;

      SET_CHILD_ALLOC (child_pos, center_size);

      gtk_widget_size_allocate (center, &child_allocation);
      gtk_widget_get_clip (center, &child_clip);
413
      gdk_rectangle_union (&clip, &clip, &child_clip);
414 415
    }

416
  if (start)
417
    {
418 419 420 421
      SET_CHILD_ALLOC (0, start_size);

      gtk_widget_size_allocate (start, &child_allocation);
      gtk_widget_get_clip (start, &child_clip);
422 423 424
      gdk_rectangle_union (&clip, &clip, &child_clip);
    }

425
  if (end)
426
    {
427 428 429 430
      SET_CHILD_ALLOC (size - end_size, end_size);

      gtk_widget_size_allocate (end, &child_allocation);
      gtk_widget_get_clip (end, &child_clip);
431
      gdk_rectangle_union (&clip, &clip, &child_clip);
432 433 434 435 436 437 438 439 440 441 442
    }

  gtk_widget_set_clip (widget, &clip);
}

static void
gtk_center_box_snapshot (GtkWidget   *widget,
                         GtkSnapshot *snapshot)
{
  GtkCenterBox *self = GTK_CENTER_BOX (widget);

443 444
  if (self->start_widget)
    gtk_widget_snapshot_child (widget, self->start_widget, snapshot);
445 446 447 448

  if (self->center_widget)
    gtk_widget_snapshot_child (widget, self->center_widget, snapshot);

449 450
  if (self->end_widget)
    gtk_widget_snapshot_child (widget, self->end_widget, snapshot);
451 452
}

453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
static void
update_css_node_order (GtkCenterBox *self)
{
  GtkCssNode *parent;
  GtkCssNode *first;
  GtkCssNode *last;

  parent = gtk_widget_get_css_node (GTK_WIDGET (self));

  if (gtk_widget_get_direction (GTK_WIDGET (self)) == GTK_TEXT_DIR_LTR)
    {
      first = self->start_widget ? gtk_widget_get_css_node (self->start_widget) : NULL;
      last = self->end_widget ? gtk_widget_get_css_node (self->end_widget) : NULL;
    }
  else
    {
      first = self->end_widget ? gtk_widget_get_css_node (self->end_widget) : NULL;
      last = self->start_widget ? gtk_widget_get_css_node (self->start_widget) : NULL;
    }

  if (first)
    gtk_css_node_insert_after (parent, first, NULL);
  if (last)
    gtk_css_node_insert_before (parent, last, NULL);
}

static void
gtk_center_box_direction_changed (GtkWidget        *widget,
                                  GtkTextDirection  previous_direction)
{
  update_css_node_order (GTK_CENTER_BOX (widget));
}

486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
static GtkSizeRequestMode
gtk_center_box_get_request_mode (GtkWidget *widget)
{
  GtkCenterBox *self = GTK_CENTER_BOX (widget);
  gint count[3] = { 0, 0, 0 };

  if (self->start_widget)
    count[gtk_widget_get_request_mode (self->start_widget)]++;

  if (self->center_widget)
    count[gtk_widget_get_request_mode (self->center_widget)]++;

  if (self->end_widget)
    count[gtk_widget_get_request_mode (self->end_widget)]++;

  if (!count[GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH] &&
      !count[GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT])
    return GTK_SIZE_REQUEST_CONSTANT_SIZE;
  else
    return count[GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT] > count[GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH]
           ? GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
           : GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH;
}

510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558
static void
gtk_center_box_set_property (GObject      *object,
                             guint         prop_id,
                             const GValue *value,
                             GParamSpec   *pspec)
{
  GtkCenterBox *self = GTK_CENTER_BOX (object);

  switch (prop_id)
    {
    case PROP_ORIENTATION:
      {
        GtkOrientation orientation = g_value_get_enum (value);
        if (self->orientation != orientation)
          {
            self->orientation = orientation;
            _gtk_orientable_set_style_classes (GTK_ORIENTABLE (self));
            gtk_widget_queue_resize (GTK_WIDGET (self));
            g_object_notify (object, "orientation");
          }
      }
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

static void
gtk_center_box_get_property (GObject    *object,
                             guint       prop_id,
                             GValue     *value,
                             GParamSpec *pspec)
{
  GtkCenterBox *self = GTK_CENTER_BOX (object);

  switch (prop_id)
    {
    case PROP_ORIENTATION:
      g_value_set_enum (value, self->orientation);
      break;

    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}

559 560 561
static void
gtk_center_box_class_init (GtkCenterBoxClass *klass)
{
562
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
563 564
  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);

565 566 567
  object_class->set_property = gtk_center_box_set_property;
  object_class->get_property = gtk_center_box_get_property;

568 569 570
  widget_class->measure = gtk_center_box_measure;
  widget_class->size_allocate = gtk_center_box_size_allocate;
  widget_class->snapshot = gtk_center_box_snapshot;
571
  widget_class->direction_changed = gtk_center_box_direction_changed;
572
  widget_class->get_request_mode = gtk_center_box_get_request_mode;
Matthias Clasen's avatar
Matthias Clasen committed
573

574 575
  g_object_class_override_property (object_class, PROP_ORIENTATION, "orientation");

Matthias Clasen's avatar
Matthias Clasen committed
576 577
  gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_FILLER);
  gtk_widget_class_set_css_name (widget_class, "box");
578 579 580 581 582 583 584 585 586 587
}

static void
gtk_center_box_init (GtkCenterBox *self)
{
  gtk_widget_set_has_window (GTK_WIDGET (self), FALSE);

  self->start_widget = NULL;
  self->center_widget = NULL;
  self->end_widget = NULL;
588 589

  self->orientation = GTK_ORIENTATION_HORIZONTAL;
590 591
}

Matthias Clasen's avatar
Matthias Clasen committed
592 593 594 595 596 597 598 599 600
/**
 * gtk_center_box_new:
 *
 * Creates a new #GtkCenterBox.
 *
 * Returns: the new #GtkCenterBox.
 *
 * Since: 3.92
 */
601 602 603 604 605 606
GtkWidget *
gtk_center_box_new (void)
{
  return GTK_WIDGET (g_object_new (GTK_TYPE_CENTER_BOX, NULL));
}

Matthias Clasen's avatar
Matthias Clasen committed
607 608 609 610 611 612 613 614 615
/**
 * gtk_center_box_set_start_widget:
 * @self: a #GtkCenterBox
 * @child: the child
 *
 * Sets the start widget.
 *
 * Since: 3.92
 */
616 617 618 619 620 621 622 623 624 625
void
gtk_center_box_set_start_widget (GtkCenterBox *self,
                                 GtkWidget    *child)
{
  if (self->start_widget)
    gtk_widget_unparent (self->start_widget);

  self->start_widget = child;
  if (child)
    gtk_widget_set_parent (child, GTK_WIDGET (self));
626 627

  update_css_node_order (self);
628 629
}

Matthias Clasen's avatar
Matthias Clasen committed
630 631 632 633 634 635 636 637 638
/**
 * gtk_center_box_set_center_widget:
 * @self: a #GtkCenterBox
 * @child: the child
 *
 * Sets the center widget.
 *
 * Since: 3.92
 */
639 640
void
gtk_center_box_set_center_widget (GtkCenterBox *self,
Matthias Clasen's avatar
Matthias Clasen committed
641
                                 GtkWidget     *child)
642 643 644 645 646 647 648
{
  if (self->center_widget)
    gtk_widget_unparent (self->center_widget);

  self->center_widget = child;
  if (child)
    gtk_widget_set_parent (child, GTK_WIDGET (self));
649 650

  update_css_node_order (self);
651 652
}

Matthias Clasen's avatar
Matthias Clasen committed
653 654 655 656 657 658 659 660 661
/**
 * gtk_center_box_set_end_widget:
 * @self: a #GtkCenterBox
 * @child: the child
 *
 * Sets the end widget.
 *
 * Since: 3.92
 */
662 663 664 665 666 667 668 669 670 671
void
gtk_center_box_set_end_widget (GtkCenterBox *self,
                               GtkWidget    *child)
{
  if (self->end_widget)
    gtk_widget_unparent (self->end_widget);

  self->end_widget = child;
  if (child)
    gtk_widget_set_parent (child, GTK_WIDGET (self));
672 673

  update_css_node_order (self);
674 675
}

Matthias Clasen's avatar
Matthias Clasen committed
676 677 678 679 680 681 682 683 684 685
/**
 * gtk_center_box_get_start_widget:
 * @self: a #GtkCenterBox
 *
 * Gets the start widget.
 *
 * Returns: the start widget.
 *
 * Since: 3.92
 */
686 687 688 689 690 691
GtkWidget *
gtk_center_box_get_start_widget (GtkCenterBox *self)
{
  return self->start_widget;
}

Matthias Clasen's avatar
Matthias Clasen committed
692 693 694 695 696 697 698 699 700 701
/**
 * gtk_center_box_get_center_widget:
 * @self: a #GtkCenterBox
 *
 * Gets the center widget.
 *
 * Returns: the center widget.
 *
 * Since: 3.92
 */
702 703 704 705 706 707
GtkWidget *
gtk_center_box_get_center_widget (GtkCenterBox *self)
{
  return self->center_widget;
}

Matthias Clasen's avatar
Matthias Clasen committed
708 709 710 711 712 713 714 715 716 717
/**
 * gtk_center_box_get_end_widget:
 * @self: a #GtkCenterBox
 *
 * Gets the end widget.
 *
 * Returns: the end widget.
 *
 * Since: 3.92
 */
718 719 720 721 722
GtkWidget *
gtk_center_box_get_end_widget (GtkCenterBox *self)
{
  return self->end_widget;
}