1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gtk.Container;
26 
27 private import cairo.Context;
28 private import glib.ListG;
29 private import glib.Str;
30 private import gobject.ObjectG;
31 private import gobject.ParamSpec;
32 private import gobject.Signals;
33 private import gobject.Value;
34 private import gtk.Adjustment;
35 private import gtk.Widget;
36 private import gtk.WidgetPath;
37 private import gtk.c.functions;
38 public  import gtk.c.types;
39 public  import gtkc.gtktypes;
40 private import std.algorithm;
41 
42 
43 /**
44  * A GTK+ user interface is constructed by nesting widgets inside widgets.
45  * Container widgets are the inner nodes in the resulting tree of widgets:
46  * they contain other widgets. So, for example, you might have a #GtkWindow
47  * containing a #GtkFrame containing a #GtkLabel. If you wanted an image instead
48  * of a textual label inside the frame, you might replace the #GtkLabel widget
49  * with a #GtkImage widget.
50  * 
51  * There are two major kinds of container widgets in GTK+. Both are subclasses
52  * of the abstract GtkContainer base class.
53  * 
54  * The first type of container widget has a single child widget and derives
55  * from #GtkBin. These containers are decorators, which
56  * add some kind of functionality to the child. For example, a #GtkButton makes
57  * its child into a clickable button; a #GtkFrame draws a frame around its child
58  * and a #GtkWindow places its child widget inside a top-level window.
59  * 
60  * The second type of container can have more than one child; its purpose is to
61  * manage layout. This means that these containers assign
62  * sizes and positions to their children. For example, a #GtkHBox arranges its
63  * children in a horizontal row, and a #GtkGrid arranges the widgets it contains
64  * in a two-dimensional grid.
65  * 
66  * For implementations of #GtkContainer the virtual method #GtkContainerClass.forall()
67  * is always required, since it's used for drawing and other internal operations
68  * on the children.
69  * If the #GtkContainer implementation expect to have non internal children
70  * it's needed to implement both #GtkContainerClass.add() and #GtkContainerClass.remove().
71  * If the GtkContainer implementation has internal children, they should be added
72  * with gtk_widget_set_parent() on init() and removed with gtk_widget_unparent()
73  * in the #GtkWidgetClass.destroy() implementation.
74  * See more about implementing custom widgets at https://wiki.gnome.org/HowDoI/CustomWidgets
75  * 
76  * # Height for width geometry management
77  * 
78  * GTK+ uses a height-for-width (and width-for-height) geometry management system.
79  * Height-for-width means that a widget can change how much vertical space it needs,
80  * depending on the amount of horizontal space that it is given (and similar for
81  * width-for-height).
82  * 
83  * There are some things to keep in mind when implementing container widgets
84  * that make use of GTK+’s height for width geometry management system. First,
85  * it’s important to note that a container must prioritize one of its
86  * dimensions, that is to say that a widget or container can only have a
87  * #GtkSizeRequestMode that is %GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH or
88  * %GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT. However, every widget and container
89  * must be able to respond to the APIs for both dimensions, i.e. even if a
90  * widget has a request mode that is height-for-width, it is possible that
91  * its parent will request its sizes using the width-for-height APIs.
92  * 
93  * To ensure that everything works properly, here are some guidelines to follow
94  * when implementing height-for-width (or width-for-height) containers.
95  * 
96  * Each request mode involves 2 virtual methods. Height-for-width apis run
97  * through gtk_widget_get_preferred_width() and then through gtk_widget_get_preferred_height_for_width().
98  * When handling requests in the opposite #GtkSizeRequestMode it is important that
99  * every widget request at least enough space to display all of its content at all times.
100  * 
101  * When gtk_widget_get_preferred_height() is called on a container that is height-for-width,
102  * the container must return the height for its minimum width. This is easily achieved by
103  * simply calling the reverse apis implemented for itself as follows:
104  * 
105  * |[<!-- language="C" -->
106  * static void
107  * foo_container_get_preferred_height (GtkWidget *widget,
108  * gint *min_height,
109  * gint *nat_height)
110  * {
111  * if (i_am_in_height_for_width_mode)
112  * {
113  * gint min_width;
114  * 
115  * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
116  * &min_width,
117  * NULL);
118  * GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width
119  * (widget,
120  * min_width,
121  * min_height,
122  * nat_height);
123  * }
124  * else
125  * {
126  * ... many containers support both request modes, execute the
127  * real width-for-height request here by returning the
128  * collective heights of all widgets that are stacked
129  * vertically (or whatever is appropriate for this container)
130  * ...
131  * }
132  * }
133  * ]|
134  * 
135  * Similarly, when gtk_widget_get_preferred_width_for_height() is called for a container or widget
136  * that is height-for-width, it then only needs to return the base minimum width like so:
137  * 
138  * |[<!-- language="C" -->
139  * static void
140  * foo_container_get_preferred_width_for_height (GtkWidget *widget,
141  * gint for_height,
142  * gint *min_width,
143  * gint *nat_width)
144  * {
145  * if (i_am_in_height_for_width_mode)
146  * {
147  * GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
148  * min_width,
149  * nat_width);
150  * }
151  * else
152  * {
153  * ... execute the real width-for-height request here based on
154  * the required width of the children collectively if the
155  * container were to be allocated the said height ...
156  * }
157  * }
158  * ]|
159  * 
160  * Height for width requests are generally implemented in terms of a virtual allocation
161  * of widgets in the input orientation. Assuming an height-for-width request mode, a container
162  * would implement the get_preferred_height_for_width() virtual function by first calling
163  * gtk_widget_get_preferred_width() for each of its children.
164  * 
165  * For each potential group of children that are lined up horizontally, the values returned by
166  * gtk_widget_get_preferred_width() should be collected in an array of #GtkRequestedSize structures.
167  * Any child spacing should be removed from the input @for_width and then the collective size should be
168  * allocated using the gtk_distribute_natural_allocation() convenience function.
169  * 
170  * The container will then move on to request the preferred height for each child by using
171  * gtk_widget_get_preferred_height_for_width() and using the sizes stored in the #GtkRequestedSize array.
172  * 
173  * To allocate a height-for-width container, it’s again important
174  * to consider that a container must prioritize one dimension over the other. So if
175  * a container is a height-for-width container it must first allocate all widgets horizontally
176  * using a #GtkRequestedSize array and gtk_distribute_natural_allocation() and then add any
177  * extra space (if and where appropriate) for the widget to expand.
178  * 
179  * After adding all the expand space, the container assumes it was allocated sufficient
180  * height to fit all of its content. At this time, the container must use the total horizontal sizes
181  * of each widget to request the height-for-width of each of its children and store the requests in a
182  * #GtkRequestedSize array for any widgets that stack vertically (for tabular containers this can
183  * be generalized into the heights and widths of rows and columns).
184  * The vertical space must then again be distributed using gtk_distribute_natural_allocation()
185  * while this time considering the allocated height of the widget minus any vertical spacing
186  * that the container adds. Then vertical expand space should be added where appropriate and available
187  * and the container should go on to actually allocating the child widgets.
188  * 
189  * See [GtkWidget’s geometry management section][geometry-management]
190  * to learn more about implementing height-for-width geometry management for widgets.
191  * 
192  * # Child properties
193  * 
194  * GtkContainer introduces child properties.
195  * These are object properties that are not specific
196  * to either the container or the contained widget, but rather to their relation.
197  * Typical examples of child properties are the position or pack-type of a widget
198  * which is contained in a #GtkBox.
199  * 
200  * Use gtk_container_class_install_child_property() to install child properties
201  * for a container class and gtk_container_class_find_child_property() or
202  * gtk_container_class_list_child_properties() to get information about existing
203  * child properties.
204  * 
205  * To set the value of a child property, use gtk_container_child_set_property(),
206  * gtk_container_child_set() or gtk_container_child_set_valist().
207  * To obtain the value of a child property, use
208  * gtk_container_child_get_property(), gtk_container_child_get() or
209  * gtk_container_child_get_valist(). To emit notification about child property
210  * changes, use gtk_widget_child_notify().
211  * 
212  * # GtkContainer as GtkBuildable
213  * 
214  * The GtkContainer implementation of the GtkBuildable interface supports
215  * a <packing> element for children, which can contain multiple <property>
216  * elements that specify child properties for the child.
217  * 
218  * Since 2.16, child properties can also be marked as translatable using
219  * the same “translatable”, “comments” and “context” attributes that are used
220  * for regular properties.
221  * 
222  * Since 3.16, containers can have a <focus-chain> element containing multiple
223  * <widget> elements, one for each child that should be added to the focus
224  * chain. The ”name” attribute gives the id of the widget.
225  * 
226  * An example of these properties in UI definitions:
227  * |[
228  * <object class="GtkBox">
229  * <child>
230  * <object class="GtkEntry" id="entry1"/>
231  * <packing>
232  * <property name="pack-type">start</property>
233  * </packing>
234  * </child>
235  * <child>
236  * <object class="GtkEntry" id="entry2"/>
237  * </child>
238  * <focus-chain>
239  * <widget name="entry1"/>
240  * <widget name="entry2"/>
241  * </focus-chain>
242  * </object>
243  * ]|
244  */
245 public class Container : Widget
246 {
247 	/** the main Gtk struct */
248 	protected GtkContainer* gtkContainer;
249 
250 	/** Get the main Gtk struct */
251 	public GtkContainer* getContainerStruct(bool transferOwnership = false)
252 	{
253 		if (transferOwnership)
254 			ownedRef = false;
255 		return gtkContainer;
256 	}
257 
258 	/** the main Gtk struct as a void* */
259 	protected override void* getStruct()
260 	{
261 		return cast(void*)gtkContainer;
262 	}
263 
264 	protected override void setStruct(GObject* obj)
265 	{
266 		gtkContainer = cast(GtkContainer*)obj;
267 		super.setStruct(obj);
268 	}
269 
270 	/**
271 	 * Sets our main struct and passes it to the parent class.
272 	 */
273 	public this (GtkContainer* gtkContainer, bool ownedRef = false)
274 	{
275 		this.gtkContainer = gtkContainer;
276 		super(cast(GtkWidget*)gtkContainer, ownedRef);
277 	}
278 
279 	/**
280 	 * Removes all widgets from the container
281 	 */
282 	void removeAll()
283 	{
284 		GList* gList = gtk_container_get_children(getContainerStruct());
285 		while ( gList !is null )
286 		{
287 			gtk_container_remove(getContainerStruct(), cast(GtkWidget*)gList.data);
288 			gList = gList.next;
289 		}
290 	}
291 
292 	/**
293 	 */
294 
295 	/** */
296 	public static GType getType()
297 	{
298 		return gtk_container_get_type();
299 	}
300 
301 	/**
302 	 * Adds @widget to @container. Typically used for simple containers
303 	 * such as #GtkWindow, #GtkFrame, or #GtkButton; for more complicated
304 	 * layout containers such as #GtkBox or #GtkGrid, this function will
305 	 * pick default packing parameters that may not be correct.  So
306 	 * consider functions such as gtk_box_pack_start() and
307 	 * gtk_grid_attach() as an alternative to gtk_container_add() in
308 	 * those cases. A widget may be added to only one container at a time;
309 	 * you can’t place the same widget inside two different containers.
310 	 *
311 	 * Note that some containers, such as #GtkScrolledWindow or #GtkListBox,
312 	 * may add intermediate children between the added widget and the
313 	 * container.
314 	 *
315 	 * Params:
316 	 *     widget = a widget to be placed inside @container
317 	 */
318 	public void add(Widget widget)
319 	{
320 		gtk_container_add(gtkContainer, (widget is null) ? null : widget.getWidgetStruct());
321 	}
322 
323 	/** */
324 	public void checkResize()
325 	{
326 		gtk_container_check_resize(gtkContainer);
327 	}
328 
329 	/**
330 	 * Gets the value of a child property for @child and @container.
331 	 *
332 	 * Params:
333 	 *     child = a widget which is a child of @container
334 	 *     propertyName = the name of the property to get
335 	 *     value = a location to return the value
336 	 */
337 	public void childGetProperty(Widget child, string propertyName, Value value)
338 	{
339 		gtk_container_child_get_property(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
340 	}
341 
342 	/**
343 	 * Gets the values of one or more child properties for @child and @container.
344 	 *
345 	 * Params:
346 	 *     child = a widget which is a child of @container
347 	 *     firstPropertyName = the name of the first property to get
348 	 *     varArgs = return location for the first property, followed
349 	 *         optionally by more name/return location pairs, followed by %NULL
350 	 */
351 	public void childGetValist(Widget child, string firstPropertyName, void* varArgs)
352 	{
353 		gtk_container_child_get_valist(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(firstPropertyName), varArgs);
354 	}
355 
356 	/**
357 	 * Emits a #GtkWidget::child-notify signal for the
358 	 * [child property][child-properties]
359 	 * @child_property on the child.
360 	 *
361 	 * This is an analogue of g_object_notify() for child properties.
362 	 *
363 	 * Also see gtk_widget_child_notify().
364 	 *
365 	 * Params:
366 	 *     child = the child widget
367 	 *     childProperty = the name of a child property installed on
368 	 *         the class of @container
369 	 *
370 	 * Since: 3.2
371 	 */
372 	public void childNotify(Widget child, string childProperty)
373 	{
374 		gtk_container_child_notify(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(childProperty));
375 	}
376 
377 	/**
378 	 * Emits a #GtkWidget::child-notify signal for the
379 	 * [child property][child-properties] specified by
380 	 * @pspec on the child.
381 	 *
382 	 * This is an analogue of g_object_notify_by_pspec() for child properties.
383 	 *
384 	 * Params:
385 	 *     child = the child widget
386 	 *     pspec = the #GParamSpec of a child property instealled on
387 	 *         the class of @container
388 	 *
389 	 * Since: 3.18
390 	 */
391 	public void childNotifyByPspec(Widget child, ParamSpec pspec)
392 	{
393 		gtk_container_child_notify_by_pspec(gtkContainer, (child is null) ? null : child.getWidgetStruct(), (pspec is null) ? null : pspec.getParamSpecStruct());
394 	}
395 
396 	/**
397 	 * Sets a child property for @child and @container.
398 	 *
399 	 * Params:
400 	 *     child = a widget which is a child of @container
401 	 *     propertyName = the name of the property to set
402 	 *     value = the value to set the property to
403 	 */
404 	public void childSetProperty(Widget child, string propertyName, Value value)
405 	{
406 		gtk_container_child_set_property(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(propertyName), (value is null) ? null : value.getValueStruct());
407 	}
408 
409 	/**
410 	 * Sets one or more child properties for @child and @container.
411 	 *
412 	 * Params:
413 	 *     child = a widget which is a child of @container
414 	 *     firstPropertyName = the name of the first property to set
415 	 *     varArgs = a %NULL-terminated list of property names and values, starting
416 	 *         with @first_prop_name
417 	 */
418 	public void childSetValist(Widget child, string firstPropertyName, void* varArgs)
419 	{
420 		gtk_container_child_set_valist(gtkContainer, (child is null) ? null : child.getWidgetStruct(), Str.toStringz(firstPropertyName), varArgs);
421 	}
422 
423 	/**
424 	 * Returns the type of the children supported by the container.
425 	 *
426 	 * Note that this may return %G_TYPE_NONE to indicate that no more
427 	 * children can be added, e.g. for a #GtkPaned which already has two
428 	 * children.
429 	 *
430 	 * Returns: a #GType.
431 	 */
432 	public GType childType()
433 	{
434 		return gtk_container_child_type(gtkContainer);
435 	}
436 
437 	/**
438 	 * Invokes @callback on each direct child of @container, including
439 	 * children that are considered “internal” (implementation details
440 	 * of the container). “Internal” children generally weren’t added
441 	 * by the user of the container, but were added by the container
442 	 * implementation itself.
443 	 *
444 	 * Most applications should use gtk_container_foreach(), rather
445 	 * than gtk_container_forall().
446 	 *
447 	 * Params:
448 	 *     callback = a callback
449 	 *     callbackData = callback user data
450 	 */
451 	public void forall(GtkCallback callback, void* callbackData)
452 	{
453 		gtk_container_forall(gtkContainer, callback, callbackData);
454 	}
455 
456 	/**
457 	 * Invokes @callback on each non-internal child of @container.
458 	 * See gtk_container_forall() for details on what constitutes
459 	 * an “internal” child. For all practical purposes, this function
460 	 * should iterate over precisely those child widgets that were
461 	 * added to the container by the application with explicit add()
462 	 * calls.
463 	 *
464 	 * Most applications should use gtk_container_foreach(),
465 	 * rather than gtk_container_forall().
466 	 *
467 	 * Params:
468 	 *     callback = a callback
469 	 *     callbackData = callback user data
470 	 */
471 	public void foreac(GtkCallback callback, void* callbackData)
472 	{
473 		gtk_container_foreach(gtkContainer, callback, callbackData);
474 	}
475 
476 	/**
477 	 * Retrieves the border width of the container. See
478 	 * gtk_container_set_border_width().
479 	 *
480 	 * Returns: the current border width
481 	 */
482 	public uint getBorderWidth()
483 	{
484 		return gtk_container_get_border_width(gtkContainer);
485 	}
486 
487 	/**
488 	 * Returns the container’s non-internal children. See
489 	 * gtk_container_forall() for details on what constitutes an "internal" child.
490 	 *
491 	 * Returns: a newly-allocated list of the container’s non-internal children.
492 	 */
493 	public ListG getChildren()
494 	{
495 		auto p = gtk_container_get_children(gtkContainer);
496 
497 		if(p is null)
498 		{
499 			return null;
500 		}
501 
502 		return new ListG(cast(GList*) p);
503 	}
504 
505 	/**
506 	 * Retrieves the focus chain of the container, if one has been
507 	 * set explicitly. If no focus chain has been explicitly
508 	 * set, GTK+ computes the focus chain based on the positions
509 	 * of the children. In that case, GTK+ stores %NULL in
510 	 * @focusable_widgets and returns %FALSE.
511 	 *
512 	 * Params:
513 	 *     focusableWidgets = location
514 	 *         to store the focus chain of the
515 	 *         container, or %NULL. You should free this list
516 	 *         using g_list_free() when you are done with it, however
517 	 *         no additional reference count is added to the
518 	 *         individual widgets in the focus chain.
519 	 *
520 	 * Returns: %TRUE if the focus chain of the container
521 	 *     has been set explicitly.
522 	 */
523 	public bool getFocusChain(out ListG focusableWidgets)
524 	{
525 		GList* outfocusableWidgets = null;
526 
527 		auto p = gtk_container_get_focus_chain(gtkContainer, &outfocusableWidgets) != 0;
528 
529 		focusableWidgets = new ListG(outfocusableWidgets);
530 
531 		return p;
532 	}
533 
534 	/**
535 	 * Returns the current focus child widget inside @container. This is not the
536 	 * currently focused widget. That can be obtained by calling
537 	 * gtk_window_get_focus().
538 	 *
539 	 * Returns: The child widget which will receive the
540 	 *     focus inside @container when the @container is focused,
541 	 *     or %NULL if none is set.
542 	 *
543 	 * Since: 2.14
544 	 */
545 	public Widget getFocusChild()
546 	{
547 		auto p = gtk_container_get_focus_child(gtkContainer);
548 
549 		if(p is null)
550 		{
551 			return null;
552 		}
553 
554 		return ObjectG.getDObject!(Widget)(cast(GtkWidget*) p);
555 	}
556 
557 	/**
558 	 * Retrieves the horizontal focus adjustment for the container. See
559 	 * gtk_container_set_focus_hadjustment ().
560 	 *
561 	 * Returns: the horizontal focus adjustment, or %NULL if
562 	 *     none has been set.
563 	 */
564 	public Adjustment getFocusHadjustment()
565 	{
566 		auto p = gtk_container_get_focus_hadjustment(gtkContainer);
567 
568 		if(p is null)
569 		{
570 			return null;
571 		}
572 
573 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
574 	}
575 
576 	/**
577 	 * Retrieves the vertical focus adjustment for the container. See
578 	 * gtk_container_set_focus_vadjustment().
579 	 *
580 	 * Returns: the vertical focus adjustment, or
581 	 *     %NULL if none has been set.
582 	 */
583 	public Adjustment getFocusVadjustment()
584 	{
585 		auto p = gtk_container_get_focus_vadjustment(gtkContainer);
586 
587 		if(p is null)
588 		{
589 			return null;
590 		}
591 
592 		return ObjectG.getDObject!(Adjustment)(cast(GtkAdjustment*) p);
593 	}
594 
595 	/**
596 	 * Returns a newly created widget path representing all the widget hierarchy
597 	 * from the toplevel down to and including @child.
598 	 *
599 	 * Params:
600 	 *     child = a child of @container
601 	 *
602 	 * Returns: A newly created #GtkWidgetPath
603 	 */
604 	public WidgetPath getPathForChild(Widget child)
605 	{
606 		auto p = gtk_container_get_path_for_child(gtkContainer, (child is null) ? null : child.getWidgetStruct());
607 
608 		if(p is null)
609 		{
610 			return null;
611 		}
612 
613 		return ObjectG.getDObject!(WidgetPath)(cast(GtkWidgetPath*) p, true);
614 	}
615 
616 	/**
617 	 * Returns the resize mode for the container. See
618 	 * gtk_container_set_resize_mode ().
619 	 *
620 	 * Deprecated: Resize modes are deprecated. They aren’t necessary
621 	 * anymore since frame clocks and might introduce obscure bugs if
622 	 * used.
623 	 *
624 	 * Returns: the current resize mode
625 	 */
626 	public GtkResizeMode getResizeMode()
627 	{
628 		return gtk_container_get_resize_mode(gtkContainer);
629 	}
630 
631 	/**
632 	 * When a container receives a call to the draw function, it must send
633 	 * synthetic #GtkWidget::draw calls to all children that don’t have their
634 	 * own #GdkWindows. This function provides a convenient way of doing this.
635 	 * A container, when it receives a call to its #GtkWidget::draw function,
636 	 * calls gtk_container_propagate_draw() once for each child, passing in
637 	 * the @cr the container received.
638 	 *
639 	 * gtk_container_propagate_draw() takes care of translating the origin of @cr,
640 	 * and deciding whether the draw needs to be sent to the child. It is a
641 	 * convenient and optimized way of getting the same effect as calling
642 	 * gtk_widget_draw() on the child directly.
643 	 *
644 	 * In most cases, a container can simply either inherit the
645 	 * #GtkWidget::draw implementation from #GtkContainer, or do some drawing
646 	 * and then chain to the ::draw implementation from #GtkContainer.
647 	 *
648 	 * Params:
649 	 *     child = a child of @container
650 	 *     cr = Cairo context as passed to the container. If you want to use @cr
651 	 *         in container’s draw function, consider using cairo_save() and
652 	 *         cairo_restore() before calling this function.
653 	 */
654 	public void propagateDraw(Widget child, Context cr)
655 	{
656 		gtk_container_propagate_draw(gtkContainer, (child is null) ? null : child.getWidgetStruct(), (cr is null) ? null : cr.getContextStruct());
657 	}
658 
659 	/**
660 	 * Removes @widget from @container. @widget must be inside @container.
661 	 * Note that @container will own a reference to @widget, and that this
662 	 * may be the last reference held; so removing a widget from its
663 	 * container can destroy that widget. If you want to use @widget
664 	 * again, you need to add a reference to it before removing it from
665 	 * a container, using g_object_ref(). If you don’t want to use @widget
666 	 * again it’s usually more efficient to simply destroy it directly
667 	 * using gtk_widget_destroy() since this will remove it from the
668 	 * container and help break any circular reference count cycles.
669 	 *
670 	 * Params:
671 	 *     widget = a current child of @container
672 	 */
673 	public void remove(Widget widget)
674 	{
675 		gtk_container_remove(gtkContainer, (widget is null) ? null : widget.getWidgetStruct());
676 	}
677 
678 	/** */
679 	public void resizeChildren()
680 	{
681 		gtk_container_resize_children(gtkContainer);
682 	}
683 
684 	/**
685 	 * Sets the border width of the container.
686 	 *
687 	 * The border width of a container is the amount of space to leave
688 	 * around the outside of the container. The only exception to this is
689 	 * #GtkWindow; because toplevel windows can’t leave space outside,
690 	 * they leave the space inside. The border is added on all sides of
691 	 * the container. To add space to only one side, use a specific
692 	 * #GtkWidget:margin property on the child widget, for example
693 	 * #GtkWidget:margin-top.
694 	 *
695 	 * Params:
696 	 *     borderWidth = amount of blank space to leave outside
697 	 *         the container. Valid values are in the range 0-65535 pixels.
698 	 */
699 	public void setBorderWidth(uint borderWidth)
700 	{
701 		gtk_container_set_border_width(gtkContainer, borderWidth);
702 	}
703 
704 	/**
705 	 * Sets a focus chain, overriding the one computed automatically by GTK+.
706 	 *
707 	 * In principle each widget in the chain should be a descendant of the
708 	 * container, but this is not enforced by this method, since it’s allowed
709 	 * to set the focus chain before you pack the widgets, or have a widget
710 	 * in the chain that isn’t always packed. The necessary checks are done
711 	 * when the focus chain is actually traversed.
712 	 *
713 	 * Params:
714 	 *     focusableWidgets = the new focus chain
715 	 */
716 	public void setFocusChain(ListG focusableWidgets)
717 	{
718 		gtk_container_set_focus_chain(gtkContainer, (focusableWidgets is null) ? null : focusableWidgets.getListGStruct());
719 	}
720 
721 	/**
722 	 * Sets, or unsets if @child is %NULL, the focused child of @container.
723 	 *
724 	 * This function emits the GtkContainer::set_focus_child signal of
725 	 * @container. Implementations of #GtkContainer can override the
726 	 * default behaviour by overriding the class closure of this signal.
727 	 *
728 	 * This is function is mostly meant to be used by widgets. Applications can use
729 	 * gtk_widget_grab_focus() to manually set the focus to a specific widget.
730 	 *
731 	 * Params:
732 	 *     child = a #GtkWidget, or %NULL
733 	 */
734 	public void setFocusChild(Widget child)
735 	{
736 		gtk_container_set_focus_child(gtkContainer, (child is null) ? null : child.getWidgetStruct());
737 	}
738 
739 	/**
740 	 * Hooks up an adjustment to focus handling in a container, so when a child
741 	 * of the container is focused, the adjustment is scrolled to show that
742 	 * widget. This function sets the horizontal alignment.
743 	 * See gtk_scrolled_window_get_hadjustment() for a typical way of obtaining
744 	 * the adjustment and gtk_container_set_focus_vadjustment() for setting
745 	 * the vertical adjustment.
746 	 *
747 	 * The adjustments have to be in pixel units and in the same coordinate
748 	 * system as the allocation for immediate children of the container.
749 	 *
750 	 * Params:
751 	 *     adjustment = an adjustment which should be adjusted when the focus is
752 	 *         moved among the descendents of @container
753 	 */
754 	public void setFocusHadjustment(Adjustment adjustment)
755 	{
756 		gtk_container_set_focus_hadjustment(gtkContainer, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
757 	}
758 
759 	/**
760 	 * Hooks up an adjustment to focus handling in a container, so when a
761 	 * child of the container is focused, the adjustment is scrolled to
762 	 * show that widget. This function sets the vertical alignment. See
763 	 * gtk_scrolled_window_get_vadjustment() for a typical way of obtaining
764 	 * the adjustment and gtk_container_set_focus_hadjustment() for setting
765 	 * the horizontal adjustment.
766 	 *
767 	 * The adjustments have to be in pixel units and in the same coordinate
768 	 * system as the allocation for immediate children of the container.
769 	 *
770 	 * Params:
771 	 *     adjustment = an adjustment which should be adjusted when the focus
772 	 *         is moved among the descendents of @container
773 	 */
774 	public void setFocusVadjustment(Adjustment adjustment)
775 	{
776 		gtk_container_set_focus_vadjustment(gtkContainer, (adjustment is null) ? null : adjustment.getAdjustmentStruct());
777 	}
778 
779 	/**
780 	 * Sets the @reallocate_redraws flag of the container to the given value.
781 	 *
782 	 * Containers requesting reallocation redraws get automatically
783 	 * redrawn if any of their children changed allocation.
784 	 *
785 	 * Deprecated: Call gtk_widget_queue_draw() in your size_allocate handler.
786 	 *
787 	 * Params:
788 	 *     needsRedraws = the new value for the container’s @reallocate_redraws flag
789 	 */
790 	public void setReallocateRedraws(bool needsRedraws)
791 	{
792 		gtk_container_set_reallocate_redraws(gtkContainer, needsRedraws);
793 	}
794 
795 	/**
796 	 * Sets the resize mode for the container.
797 	 *
798 	 * The resize mode of a container determines whether a resize request
799 	 * will be passed to the container’s parent, queued for later execution
800 	 * or executed immediately.
801 	 *
802 	 * Deprecated: Resize modes are deprecated. They aren’t necessary
803 	 * anymore since frame clocks and might introduce obscure bugs if
804 	 * used.
805 	 *
806 	 * Params:
807 	 *     resizeMode = the new resize mode
808 	 */
809 	public void setResizeMode(GtkResizeMode resizeMode)
810 	{
811 		gtk_container_set_resize_mode(gtkContainer, resizeMode);
812 	}
813 
814 	/**
815 	 * Removes a focus chain explicitly set with gtk_container_set_focus_chain().
816 	 */
817 	public void unsetFocusChain()
818 	{
819 		gtk_container_unset_focus_chain(gtkContainer);
820 	}
821 
822 	protected class OnAddDelegateWrapper
823 	{
824 		void delegate(Widget, Container) dlg;
825 		gulong handlerId;
826 
827 		this(void delegate(Widget, Container) dlg)
828 		{
829 			this.dlg = dlg;
830 			onAddListeners ~= this;
831 		}
832 
833 		void remove(OnAddDelegateWrapper source)
834 		{
835 			foreach(index, wrapper; onAddListeners)
836 			{
837 				if (wrapper.handlerId == source.handlerId)
838 				{
839 					onAddListeners[index] = null;
840 					onAddListeners = std.algorithm.remove(onAddListeners, index);
841 					break;
842 				}
843 			}
844 		}
845 	}
846 	OnAddDelegateWrapper[] onAddListeners;
847 
848 	/** */
849 	gulong addOnAdd(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
850 	{
851 		auto wrapper = new OnAddDelegateWrapper(dlg);
852 		wrapper.handlerId = Signals.connectData(
853 			this,
854 			"add",
855 			cast(GCallback)&callBackAdd,
856 			cast(void*)wrapper,
857 			cast(GClosureNotify)&callBackAddDestroy,
858 			connectFlags);
859 		return wrapper.handlerId;
860 	}
861 
862 	extern(C) static void callBackAdd(GtkContainer* containerStruct, GtkWidget* object, OnAddDelegateWrapper wrapper)
863 	{
864 		wrapper.dlg(ObjectG.getDObject!(Widget)(object), wrapper.outer);
865 	}
866 
867 	extern(C) static void callBackAddDestroy(OnAddDelegateWrapper wrapper, GClosure* closure)
868 	{
869 		wrapper.remove(wrapper);
870 	}
871 
872 	protected class OnCheckResizeDelegateWrapper
873 	{
874 		void delegate(Container) dlg;
875 		gulong handlerId;
876 
877 		this(void delegate(Container) dlg)
878 		{
879 			this.dlg = dlg;
880 			onCheckResizeListeners ~= this;
881 		}
882 
883 		void remove(OnCheckResizeDelegateWrapper source)
884 		{
885 			foreach(index, wrapper; onCheckResizeListeners)
886 			{
887 				if (wrapper.handlerId == source.handlerId)
888 				{
889 					onCheckResizeListeners[index] = null;
890 					onCheckResizeListeners = std.algorithm.remove(onCheckResizeListeners, index);
891 					break;
892 				}
893 			}
894 		}
895 	}
896 	OnCheckResizeDelegateWrapper[] onCheckResizeListeners;
897 
898 	/** */
899 	gulong addOnCheckResize(void delegate(Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
900 	{
901 		auto wrapper = new OnCheckResizeDelegateWrapper(dlg);
902 		wrapper.handlerId = Signals.connectData(
903 			this,
904 			"check-resize",
905 			cast(GCallback)&callBackCheckResize,
906 			cast(void*)wrapper,
907 			cast(GClosureNotify)&callBackCheckResizeDestroy,
908 			connectFlags);
909 		return wrapper.handlerId;
910 	}
911 
912 	extern(C) static void callBackCheckResize(GtkContainer* containerStruct, OnCheckResizeDelegateWrapper wrapper)
913 	{
914 		wrapper.dlg(wrapper.outer);
915 	}
916 
917 	extern(C) static void callBackCheckResizeDestroy(OnCheckResizeDelegateWrapper wrapper, GClosure* closure)
918 	{
919 		wrapper.remove(wrapper);
920 	}
921 
922 	protected class OnRemoveDelegateWrapper
923 	{
924 		void delegate(Widget, Container) dlg;
925 		gulong handlerId;
926 
927 		this(void delegate(Widget, Container) dlg)
928 		{
929 			this.dlg = dlg;
930 			onRemoveListeners ~= this;
931 		}
932 
933 		void remove(OnRemoveDelegateWrapper source)
934 		{
935 			foreach(index, wrapper; onRemoveListeners)
936 			{
937 				if (wrapper.handlerId == source.handlerId)
938 				{
939 					onRemoveListeners[index] = null;
940 					onRemoveListeners = std.algorithm.remove(onRemoveListeners, index);
941 					break;
942 				}
943 			}
944 		}
945 	}
946 	OnRemoveDelegateWrapper[] onRemoveListeners;
947 
948 	/** */
949 	gulong addOnRemove(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
950 	{
951 		auto wrapper = new OnRemoveDelegateWrapper(dlg);
952 		wrapper.handlerId = Signals.connectData(
953 			this,
954 			"remove",
955 			cast(GCallback)&callBackRemove,
956 			cast(void*)wrapper,
957 			cast(GClosureNotify)&callBackRemoveDestroy,
958 			connectFlags);
959 		return wrapper.handlerId;
960 	}
961 
962 	extern(C) static void callBackRemove(GtkContainer* containerStruct, GtkWidget* object, OnRemoveDelegateWrapper wrapper)
963 	{
964 		wrapper.dlg(ObjectG.getDObject!(Widget)(object), wrapper.outer);
965 	}
966 
967 	extern(C) static void callBackRemoveDestroy(OnRemoveDelegateWrapper wrapper, GClosure* closure)
968 	{
969 		wrapper.remove(wrapper);
970 	}
971 
972 	protected class OnSetFocusChildDelegateWrapper
973 	{
974 		void delegate(Widget, Container) dlg;
975 		gulong handlerId;
976 
977 		this(void delegate(Widget, Container) dlg)
978 		{
979 			this.dlg = dlg;
980 			onSetFocusChildListeners ~= this;
981 		}
982 
983 		void remove(OnSetFocusChildDelegateWrapper source)
984 		{
985 			foreach(index, wrapper; onSetFocusChildListeners)
986 			{
987 				if (wrapper.handlerId == source.handlerId)
988 				{
989 					onSetFocusChildListeners[index] = null;
990 					onSetFocusChildListeners = std.algorithm.remove(onSetFocusChildListeners, index);
991 					break;
992 				}
993 			}
994 		}
995 	}
996 	OnSetFocusChildDelegateWrapper[] onSetFocusChildListeners;
997 
998 	/** */
999 	gulong addOnSetFocusChild(void delegate(Widget, Container) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
1000 	{
1001 		auto wrapper = new OnSetFocusChildDelegateWrapper(dlg);
1002 		wrapper.handlerId = Signals.connectData(
1003 			this,
1004 			"set-focus-child",
1005 			cast(GCallback)&callBackSetFocusChild,
1006 			cast(void*)wrapper,
1007 			cast(GClosureNotify)&callBackSetFocusChildDestroy,
1008 			connectFlags);
1009 		return wrapper.handlerId;
1010 	}
1011 
1012 	extern(C) static void callBackSetFocusChild(GtkContainer* containerStruct, GtkWidget* object, OnSetFocusChildDelegateWrapper wrapper)
1013 	{
1014 		wrapper.dlg(ObjectG.getDObject!(Widget)(object), wrapper.outer);
1015 	}
1016 
1017 	extern(C) static void callBackSetFocusChildDestroy(OnSetFocusChildDelegateWrapper wrapper, GClosure* closure)
1018 	{
1019 		wrapper.remove(wrapper);
1020 	}
1021 }