1 /* GTK - The GIMP Toolkit
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
29 * @Short_description: A container for arranging buttons
30 * @Title: GtkButtonBox
32 * A button box should be used to provide a consistent layout of buttons
33 * throughout your application. The layout/spacing can be altered by the
34 * programmer, or if desired, by the user to alter the 'feel' of a
35 * program to a small degree.
37 * gtk_button_box_get_layout() and gtk_button_box_set_layout() retrieve and
38 * alter the method used to spread the buttons in a button box across the
39 * container, respectively.
41 * The main purpose of GtkButtonBox is to make sure the children have all the
42 * same size. GtkButtonBox gives all children the same size, but it does allow
43 * 'outliers' to keep their own larger size. To force all children to be
44 * strictly the same size without exceptions, you can set the
45 * #GtkButtonBox:homogeneous property to %TRUE.
47 * To excempt individual children from homogeneous sizing regardless of their
48 * 'outlier' status, you can set the #GtkButtonBox:non-homogeneous child
56 #include "gtkboxprivate.h"
57 #include "gtkorientable.h"
58 #include "gtktypebuiltins.h"
59 #include "gtkprivate.h"
60 #include "gtksizerequest.h"
65 struct _GtkButtonBoxPrivate
67 GtkButtonBoxStyle layout_style;
78 CHILD_PROP_NONHOMOGENEOUS
81 #define GTK_BOX_SECONDARY_CHILD "gtk-box-secondary-child"
82 #define GTK_BOX_NON_HOMOGENEOUS "gtk-box-non-homogeneous"
84 static void gtk_button_box_set_property (GObject *object,
88 static void gtk_button_box_get_property (GObject *object,
92 static void gtk_button_box_get_preferred_width (GtkWidget *widget,
95 static void gtk_button_box_get_preferred_height (GtkWidget *widget,
98 static void gtk_button_box_get_preferred_width_for_height (GtkWidget *widget,
102 static void gtk_button_box_get_preferred_height_for_width (GtkWidget *widget,
107 static void gtk_button_box_size_allocate (GtkWidget *widget,
108 GtkAllocation *allocation);
109 static void gtk_button_box_remove (GtkContainer *container,
111 static void gtk_button_box_set_child_property (GtkContainer *container,
116 static void gtk_button_box_get_child_property (GtkContainer *container,
122 #define DEFAULT_CHILD_MIN_WIDTH 85
123 #define DEFAULT_CHILD_MIN_HEIGHT 27
124 #define DEFAULT_CHILD_IPAD_X 4
125 #define DEFAULT_CHILD_IPAD_Y 0
126 #define DEFAULT_LAYOUT_STYLE GTK_BUTTONBOX_EDGE
128 G_DEFINE_TYPE (GtkButtonBox, gtk_button_box, GTK_TYPE_BOX)
131 gtk_button_box_class_init (GtkButtonBoxClass *class)
133 GtkWidgetClass *widget_class;
134 GObjectClass *gobject_class;
135 GtkContainerClass *container_class;
137 gobject_class = G_OBJECT_CLASS (class);
138 widget_class = (GtkWidgetClass*) class;
139 container_class = (GtkContainerClass*) class;
141 gobject_class->set_property = gtk_button_box_set_property;
142 gobject_class->get_property = gtk_button_box_get_property;
144 widget_class->get_preferred_width = gtk_button_box_get_preferred_width;
145 widget_class->get_preferred_height = gtk_button_box_get_preferred_height;
146 widget_class->get_preferred_width_for_height = gtk_button_box_get_preferred_width_for_height;
147 widget_class->get_preferred_height_for_width = gtk_button_box_get_preferred_height_for_width;
148 widget_class->size_allocate = gtk_button_box_size_allocate;
150 container_class->remove = gtk_button_box_remove;
151 container_class->set_child_property = gtk_button_box_set_child_property;
152 container_class->get_child_property = gtk_button_box_get_child_property;
153 gtk_container_class_handle_border_width (container_class);
155 /* FIXME we need to override the "spacing" property on GtkBox once
156 * libgobject allows that.
158 gtk_widget_class_install_style_property (widget_class,
159 g_param_spec_int ("child-min-width",
160 P_("Minimum child width"),
161 P_("Minimum width of buttons inside the box"),
164 DEFAULT_CHILD_MIN_WIDTH,
165 GTK_PARAM_READABLE));
167 gtk_widget_class_install_style_property (widget_class,
168 g_param_spec_int ("child-min-height",
169 P_("Minimum child height"),
170 P_("Minimum height of buttons inside the box"),
173 DEFAULT_CHILD_MIN_HEIGHT,
174 GTK_PARAM_READABLE));
176 gtk_widget_class_install_style_property (widget_class,
177 g_param_spec_int ("child-internal-pad-x",
178 P_("Child internal width padding"),
179 P_("Amount to increase child's size on either side"),
182 DEFAULT_CHILD_IPAD_X,
183 GTK_PARAM_READABLE));
185 gtk_widget_class_install_style_property (widget_class,
186 g_param_spec_int ("child-internal-pad-y",
187 P_("Child internal height padding"),
188 P_("Amount to increase child's size on the top and bottom"),
191 DEFAULT_CHILD_IPAD_Y,
192 GTK_PARAM_READABLE));
193 g_object_class_install_property (gobject_class,
195 g_param_spec_enum ("layout-style",
197 P_("How to lay out the buttons in the box. Possible values are: spread, edge, start and end"),
198 GTK_TYPE_BUTTON_BOX_STYLE,
199 DEFAULT_LAYOUT_STYLE,
200 GTK_PARAM_READWRITE));
202 gtk_container_class_install_child_property (container_class,
203 CHILD_PROP_SECONDARY,
204 g_param_spec_boolean ("secondary",
206 P_("If TRUE, the child appears in a secondary group of children, suitable for, e.g., help buttons"),
208 GTK_PARAM_READWRITE));
210 gtk_container_class_install_child_property (container_class,
211 CHILD_PROP_NONHOMOGENEOUS,
212 g_param_spec_boolean ("non-homogeneous",
213 P_("Non-Homogeneous"),
214 P_("If TRUE, the child will not be subject to homogeneous sizing"),
216 GTK_PARAM_READWRITE));
218 g_type_class_add_private (class, sizeof (GtkButtonBoxPrivate));
222 gtk_button_box_init (GtkButtonBox *button_box)
224 GtkButtonBoxPrivate *priv;
226 button_box->priv = G_TYPE_INSTANCE_GET_PRIVATE (button_box,
228 GtkButtonBoxPrivate);
229 priv = button_box->priv;
231 gtk_box_set_spacing (GTK_BOX (button_box), 0);
232 priv->layout_style = DEFAULT_LAYOUT_STYLE;
236 gtk_button_box_set_property (GObject *object,
243 case PROP_LAYOUT_STYLE:
244 gtk_button_box_set_layout (GTK_BUTTON_BOX (object),
245 g_value_get_enum (value));
248 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
254 gtk_button_box_get_property (GObject *object,
259 GtkButtonBoxPrivate *priv = GTK_BUTTON_BOX (object)->priv;
263 case PROP_LAYOUT_STYLE:
264 g_value_set_enum (value, priv->layout_style);
267 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
273 gtk_button_box_set_child_property (GtkContainer *container,
281 case CHILD_PROP_SECONDARY:
282 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (container), child,
283 g_value_get_boolean (value));
285 case CHILD_PROP_NONHOMOGENEOUS:
286 gtk_button_box_set_child_non_homogeneous (GTK_BUTTON_BOX (container), child,
287 g_value_get_boolean (value));
290 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
296 gtk_button_box_get_child_property (GtkContainer *container,
304 case CHILD_PROP_SECONDARY:
305 g_value_set_boolean (value,
306 gtk_button_box_get_child_secondary (GTK_BUTTON_BOX (container),
309 case CHILD_PROP_NONHOMOGENEOUS:
310 g_value_set_boolean (value,
311 gtk_button_box_get_child_non_homogeneous (GTK_BUTTON_BOX (container),
315 GTK_CONTAINER_WARN_INVALID_CHILD_PROPERTY_ID (container, property_id, pspec);
321 gtk_button_box_remove (GtkContainer *container,
324 /* clear is_secondary and nonhomogeneous flag in case the widget
325 * is added to another container
327 gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (container), widget, FALSE);
328 gtk_button_box_set_child_non_homogeneous (GTK_BUTTON_BOX (container), widget, FALSE);
330 GTK_CONTAINER_CLASS (gtk_button_box_parent_class)->remove (container, widget);
334 * gtk_button_box_set_layout:
335 * @widget: a #GtkButtonBox
336 * @layout_style: the new layout style
338 * Changes the way buttons are arranged in their container.
341 gtk_button_box_set_layout (GtkButtonBox *widget,
342 GtkButtonBoxStyle layout_style)
344 GtkButtonBoxPrivate *priv;
346 g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
350 if (priv->layout_style != layout_style)
352 priv->layout_style = layout_style;
353 g_object_notify (G_OBJECT (widget), "layout-style");
354 gtk_widget_queue_resize (GTK_WIDGET (widget));
359 * gtk_button_box_get_layout:
360 * @widget: a #GtkButtonBox
362 * Retrieves the method being used to arrange the buttons in a button box.
364 * Returns: the method used to lay out buttons in @widget.
367 gtk_button_box_get_layout (GtkButtonBox *widget)
369 g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), DEFAULT_LAYOUT_STYLE);
371 return widget->priv->layout_style;
375 * gtk_button_box_get_child_secondary:
376 * @widget: a #GtkButtonBox
377 * @child: a child of @widget
379 * Returns whether @child should appear in a secondary group of children.
381 * Return value: whether @child should appear in a secondary group of children.
386 gtk_button_box_get_child_secondary (GtkButtonBox *widget,
389 g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), FALSE);
390 g_return_val_if_fail (GTK_IS_WIDGET (child), FALSE);
392 return (g_object_get_data (G_OBJECT (child), GTK_BOX_SECONDARY_CHILD) != NULL);
396 * gtk_button_box_set_child_secondary
397 * @widget: a #GtkButtonBox
398 * @child: a child of @widget
399 * @is_secondary: if %TRUE, the @child appears in a secondary group of the
402 * Sets whether @child should appear in a secondary group of children.
403 * A typical use of a secondary child is the help button in a dialog.
405 * This group appears after the other children if the style
406 * is %GTK_BUTTONBOX_START, %GTK_BUTTONBOX_SPREAD or
407 * %GTK_BUTTONBOX_EDGE, and before the other children if the style
408 * is %GTK_BUTTONBOX_END. For horizontal button boxes, the definition
409 * of before/after depends on direction of the widget (see
410 * gtk_widget_set_direction()). If the style is %GTK_BUTTONBOX_START
411 * or %GTK_BUTTONBOX_END, then the secondary children are aligned at
412 * the other end of the button box from the main children. For the
413 * other styles, they appear immediately next to the main children.
416 gtk_button_box_set_child_secondary (GtkButtonBox *widget,
418 gboolean is_secondary)
420 g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
421 g_return_if_fail (GTK_IS_WIDGET (child));
422 g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (widget));
424 g_object_set_data (G_OBJECT (child),
425 GTK_BOX_SECONDARY_CHILD,
426 is_secondary ? GINT_TO_POINTER (1) : NULL);
427 gtk_widget_child_notify (child, "secondary");
429 if (gtk_widget_get_visible (GTK_WIDGET (widget)) &&
430 gtk_widget_get_visible (child))
431 gtk_widget_queue_resize (child);
434 /* Ask children how much space they require and round up
435 * to match minimum size and internal padding.
436 * Returns the size each single child should have.
439 gtk_button_box_child_requisition (GtkWidget *widget,
441 gint *nvis_secondaries,
446 GList *children, *list;
452 GtkRequisition child_requisition;
455 gint child_min_width;
456 gint child_min_height;
459 gboolean homogeneous;
462 g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
464 bbox = GTK_BUTTON_BOX (widget);
466 homogeneous = gtk_box_get_homogeneous (GTK_BOX (widget));
468 gtk_widget_style_get (widget,
469 "child-min-width", &child_min_width,
470 "child-min-height", &child_min_height,
471 "child-internal-pad-x", &ipad_x,
472 "child-internal-pad-y", &ipad_y,
477 list = children = _gtk_box_get_children (GTK_BOX (bbox));
478 needed_width = child_min_width;
479 needed_height = child_min_height;
488 child = children->data;
489 children = children->next;
491 if (gtk_widget_get_visible (child))
494 gtk_widget_get_preferred_size (child,
495 &child_requisition, NULL);
496 avg_w += child_requisition.width + ipad_w;
497 avg_h += child_requisition.height + ipad_h;
500 avg_w /= MAX (nchildren, 1);
501 avg_h /= MAX (nchildren, 1);
503 *widths = g_new (gint, nchildren);
504 *heights = g_new (gint, nchildren);
511 gboolean is_secondary;
512 gboolean non_homogeneous;
514 child = children->data;
515 children = children->next;
517 if (gtk_widget_get_visible (child))
519 is_secondary = gtk_button_box_get_child_secondary (bbox, child);
520 non_homogeneous = gtk_button_box_get_child_non_homogeneous (bbox, child);
525 gtk_widget_get_preferred_size (child, &child_requisition, NULL);
528 (!non_homogeneous && (child_requisition.width + ipad_w < avg_w * 1.5)))
531 if (child_requisition.width + ipad_w > needed_width)
532 needed_width = child_requisition.width + ipad_w;
536 (*widths)[i] = child_requisition.width + ipad_w;
540 (!non_homogeneous && (child_requisition.height + ipad_h < avg_h * 1.5)))
543 if (child_requisition.height + ipad_h > needed_height)
544 needed_height = child_requisition.height + ipad_h;
548 (*heights)[i] = child_requisition.height + ipad_h;
557 for (i = 0; i < nchildren; i++)
559 if ((*widths)[i] == -1)
560 (*widths)[i] = needed_width;
561 if ((*heights)[i] == -1)
562 (*heights)[i] = needed_height;
566 *nvis_children = nchildren;
568 if (nvis_secondaries)
569 *nvis_secondaries = nsecondaries;
573 gtk_button_box_size_request (GtkWidget *widget,
574 GtkRequisition *requisition)
576 GtkButtonBoxPrivate *priv;
582 GtkOrientation orientation;
587 bbox = GTK_BUTTON_BOX (widget);
590 orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
591 spacing = gtk_box_get_spacing (GTK_BOX (widget));
593 gtk_button_box_child_requisition (widget,
600 for (i = 0; i < nvis_children; i++)
602 if (orientation == GTK_ORIENTATION_HORIZONTAL)
604 total_size += widths[i];
605 max_size = MAX (max_size, heights[i]);
609 total_size += heights[i];
610 max_size = MAX (max_size, widths[i]);
616 if (nvis_children == 0)
618 requisition->width = 0;
619 requisition->height = 0;
623 switch (priv->layout_style)
625 case GTK_BUTTONBOX_SPREAD:
626 if (orientation == GTK_ORIENTATION_HORIZONTAL)
627 requisition->width = total_size + ((nvis_children + 1)*spacing);
629 requisition->height = total_size + ((nvis_children + 1)*spacing);
632 case GTK_BUTTONBOX_EDGE:
633 case GTK_BUTTONBOX_START:
634 case GTK_BUTTONBOX_END:
635 case GTK_BUTTONBOX_CENTER:
636 if (orientation == GTK_ORIENTATION_HORIZONTAL)
637 requisition->width = total_size + ((nvis_children - 1)*spacing);
639 requisition->height = total_size + ((nvis_children - 1)*spacing);
643 g_assert_not_reached ();
647 if (orientation == GTK_ORIENTATION_HORIZONTAL)
648 requisition->height = max_size;
650 requisition->width = max_size;
655 gtk_button_box_get_preferred_width (GtkWidget *widget,
659 GtkRequisition requisition;
661 gtk_button_box_size_request (widget, &requisition);
663 *minimum = *natural = requisition.width;
667 gtk_button_box_get_preferred_height (GtkWidget *widget,
671 GtkRequisition requisition;
673 gtk_button_box_size_request (widget, &requisition);
675 *minimum = *natural = requisition.height;
679 gtk_button_box_get_preferred_width_for_height (GtkWidget *widget,
684 gtk_button_box_get_preferred_width (widget, minimum, natural);
688 gtk_button_box_get_preferred_height_for_width (GtkWidget *widget,
693 gtk_button_box_get_preferred_height (widget, minimum, natural);
697 gtk_button_box_size_allocate (GtkWidget *widget,
698 GtkAllocation *allocation)
700 GtkButtonBoxPrivate *priv;
702 GList *children, *list;
703 GtkAllocation child_allocation;
709 gint secondary_x = 0;
710 gint secondary_y = 0;
713 gint childspacing = 0;
715 GtkOrientation orientation;
725 bbox = GTK_BUTTON_BOX (widget);
728 orientation = gtk_orientable_get_orientation (GTK_ORIENTABLE (widget));
729 spacing = gtk_box_get_spacing (GTK_BOX (widget));
731 gtk_widget_style_get (widget,
732 "child-internal-pad-x", &ipad_x,
733 "child-internal-pad-y", &ipad_y,
735 gtk_button_box_child_requisition (widget,
740 n_primaries = nvis_children - n_secondaries;
743 if (orientation == GTK_ORIENTATION_HORIZONTAL)
749 list = children = _gtk_box_get_children (GTK_BOX (widget));
754 child = children->data;
755 children = children->next;
757 if (gtk_widget_get_visible (child))
759 if (gtk_button_box_get_child_secondary (bbox, child))
760 secondary_size += sizes[i];
762 primary_size += sizes[i];
766 total_size = primary_size + secondary_size;
768 gtk_widget_set_allocation (widget, allocation);
770 if (orientation == GTK_ORIENTATION_HORIZONTAL)
771 width = allocation->width;
773 height = allocation->height;
775 switch (priv->layout_style)
777 case GTK_BUTTONBOX_SPREAD:
779 if (orientation == GTK_ORIENTATION_HORIZONTAL)
781 childspacing = (width - total_size) / (nvis_children + 1);
782 x = allocation->x + childspacing;
783 secondary_x = x + primary_size + n_primaries * childspacing;
787 childspacing = (height - total_size) / (nvis_children + 1);
788 y = allocation->y + childspacing;
789 secondary_y = y + primary_size + n_primaries * childspacing;
794 case GTK_BUTTONBOX_EDGE:
796 if (orientation == GTK_ORIENTATION_HORIZONTAL)
798 if (nvis_children >= 2)
800 childspacing = (width - total_size) / (nvis_children - 1);
802 secondary_x = x + primary_size + n_primaries * childspacing;
804 else if (nvis_children == 1)
806 /* one child, just center */
807 childspacing = width;
808 x = secondary_x = allocation->x
809 + (allocation->width - widths[0]) / 2;
813 /* zero children, meh */
814 childspacing = width;
815 x = secondary_x = allocation->x + allocation->width / 2;
820 if (nvis_children >= 2)
822 childspacing = (height - total_size) / (nvis_children - 1);
824 secondary_y = y + primary_size + n_primaries * childspacing;
826 else if (nvis_children == 1)
828 /* one child, just center */
829 childspacing = height;
830 y = secondary_y = allocation->y
831 + (allocation->height - heights[0]) / 2;
835 /* zero children, meh */
836 childspacing = height;
837 y = secondary_y = allocation->y + allocation->height / 2;
843 case GTK_BUTTONBOX_START:
845 if (orientation == GTK_ORIENTATION_HORIZONTAL)
847 childspacing = spacing;
849 secondary_x = allocation->x + allocation->width
850 - secondary_size - spacing * (n_secondaries - 1);
854 childspacing = spacing;
856 secondary_y = allocation->y + allocation->height
857 - secondary_size - spacing * (n_secondaries - 1);
862 case GTK_BUTTONBOX_END:
864 if (orientation == GTK_ORIENTATION_HORIZONTAL)
866 childspacing = spacing;
867 x = allocation->x + allocation->width
868 - primary_size - spacing * (n_primaries - 1);
869 secondary_x = allocation->x;
873 childspacing = spacing;
874 y = allocation->y + allocation->height
875 - primary_size - spacing * (n_primaries - 1);
876 secondary_y = allocation->y;
881 case GTK_BUTTONBOX_CENTER:
883 if (orientation == GTK_ORIENTATION_HORIZONTAL)
885 childspacing = spacing;
888 - (primary_size + spacing * (n_primaries - 1))) / 2
889 + (secondary_size + n_secondaries * spacing) / 2;
890 secondary_x = allocation->x;
894 childspacing = spacing;
897 - (primary_size + spacing * (n_primaries - 1))) / 2
898 + (secondary_size + n_secondaries * spacing) / 2;
899 secondary_y = allocation->y;
905 g_assert_not_reached ();
915 child = children->data;
916 children = children->next;
918 if (gtk_widget_get_visible (child))
920 child_allocation.width = widths[i];
921 child_allocation.height = heights[i];
923 if (orientation == GTK_ORIENTATION_HORIZONTAL)
925 child_allocation.y = allocation->y + (allocation->height - child_allocation.height) / 2;
927 if (gtk_button_box_get_child_secondary (bbox, child))
929 child_allocation.x = secondary_x;
930 secondary_x += child_allocation.width + childspacing;
934 child_allocation.x = x;
935 x += child_allocation.width + childspacing;
938 if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
939 child_allocation.x = (allocation->x + allocation->width)
940 - (child_allocation.x + child_allocation.width - allocation->x);
944 child_allocation.x = allocation->x + (allocation->width - child_allocation.width) / 2;
946 if (gtk_button_box_get_child_secondary (bbox, child))
948 child_allocation.y = secondary_y;
949 secondary_y += child_allocation.height + childspacing;
953 child_allocation.y = y;
954 y += child_allocation.height + childspacing;
958 gtk_widget_size_allocate (child, &child_allocation);
969 * gtk_button_box_new:
970 * @orientation: the box' orientation.
972 * Creates a new #GtkButtonBox.
974 * Return value: a new #GtkButtonBox.
979 gtk_button_box_new (GtkOrientation orientation)
981 return g_object_new (GTK_TYPE_BUTTON_BOX,
982 "orientation", orientation,
987 * gtk_button_box_get_child_non_homogeneous:
988 * @widget: a #GtkButtonBox
989 * @child: a child of @widget
991 * Returns whether the child is exempted from homogenous
994 * Returns: %TRUE if the child is not subject to homogenous sizing
999 gtk_button_box_get_child_non_homogeneous (GtkButtonBox *widget,
1002 g_return_val_if_fail (GTK_IS_BUTTON_BOX (widget), FALSE);
1003 g_return_val_if_fail (GTK_IS_WIDGET (child), FALSE);
1005 return (g_object_get_data (G_OBJECT (child), GTK_BOX_NON_HOMOGENEOUS) != NULL);
1009 * gtk_button_box_set_child_non_homogeneous:
1010 * @widget: a #GtkButtonBox
1011 * @child: a child of @widget
1012 * @non_homogeneous: the new value
1014 * Sets whether the child is exempted from homogeous sizing.
1019 gtk_button_box_set_child_non_homogeneous (GtkButtonBox *widget,
1021 gboolean non_homogeneous)
1023 g_return_if_fail (GTK_IS_BUTTON_BOX (widget));
1024 g_return_if_fail (GTK_IS_WIDGET (child));
1025 g_return_if_fail (gtk_widget_get_parent (child) == GTK_WIDGET (widget));
1027 g_object_set_data (G_OBJECT (child),
1028 GTK_BOX_NON_HOMOGENEOUS,
1029 non_homogeneous ? GINT_TO_POINTER (1) : NULL);
1030 gtk_widget_child_notify (child, "non-homogeneous");
1032 if (gtk_widget_get_visible (GTK_WIDGET (widget)) &&
1033 gtk_widget_get_visible (child))
1034 gtk_widget_queue_resize (child);