ContainerProtocol
public protocol ContainerProtocol : WidgetProtocol
A GTK+ user interface is constructed by nesting widgets inside widgets.
Container widgets are the inner nodes in the resulting tree of widgets:
they contain other widgets. So, for example, you might have a GtkWindow
containing a GtkFrame
containing a GtkLabel
. If you wanted an image instead
of a textual label inside the frame, you might replace the GtkLabel
widget
with a GtkImage
widget.
There are two major kinds of container widgets in GTK+. Both are subclasses of the abstract GtkContainer base class.
The first type of container widget has a single child widget and derives
from GtkBin
. These containers are decorators, which
add some kind of functionality to the child. For example, a GtkButton
makes
its child into a clickable button; a GtkFrame
draws a frame around its child
and a GtkWindow
places its child widget inside a top-level window.
The second type of container can have more than one child; its purpose is to
manage layout. This means that these containers assign
sizes and positions to their children. For example, a GtkHBox
arranges its
children in a horizontal row, and a GtkGrid
arranges the widgets it contains
in a two-dimensional grid.
For implementations of GtkContainer
the virtual method GtkContainerClass.forall
()
is always required, since it’s used for drawing and other internal operations
on the children.
If the GtkContainer
implementation expect to have non internal children
it’s needed to implement both GtkContainerClass.add
()
and GtkContainerClass.remove
()
.
If the GtkContainer implementation has internal children, they should be added
with gtk_widget_set_parent()
on init()
and removed with gtk_widget_unparent()
in the GtkWidgetClass.destroy
()
implementation.
See more about implementing custom widgets at https://wiki.gnome.org/HowDoI/CustomWidgets
Height for width geometry management
GTK+ uses a height-for-width (and width-for-height) geometry management system. Height-for-width means that a widget can change how much vertical space it needs, depending on the amount of horizontal space that it is given (and similar for width-for-height).
There are some things to keep in mind when implementing container widgets
that make use of GTK+’s height for width geometry management system. First,
it’s important to note that a container must prioritize one of its
dimensions, that is to say that a widget or container can only have a
GtkSizeRequestMode
that is GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH
or
GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT
. However, every widget and container
must be able to respond to the APIs for both dimensions, i.e. even if a
widget has a request mode that is height-for-width, it is possible that
its parent will request its sizes using the width-for-height APIs.
To ensure that everything works properly, here are some guidelines to follow when implementing height-for-width (or width-for-height) containers.
Each request mode involves 2 virtual methods. Height-for-width apis run
through gtk_widget_get_preferred_width()
and then through gtk_widget_get_preferred_height_for_width()
.
When handling requests in the opposite GtkSizeRequestMode
it is important that
every widget request at least enough space to display all of its content at all times.
When gtk_widget_get_preferred_height()
is called on a container that is height-for-width,
the container must return the height for its minimum width. This is easily achieved by
simply calling the reverse apis implemented for itself as follows:
(C Language Example):
static void
foo_container_get_preferred_height (GtkWidget *widget,
gint *min_height,
gint *nat_height)
{
if (i_am_in_height_for_width_mode)
{
gint min_width;
GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
&min_width,
NULL);
GTK_WIDGET_GET_CLASS (widget)->get_preferred_height_for_width
(widget,
min_width,
min_height,
nat_height);
}
else
{
... many containers support both request modes, execute the
real width-for-height request here by returning the
collective heights of all widgets that are stacked
vertically (or whatever is appropriate for this container)
...
}
}
Similarly, when gtk_widget_get_preferred_width_for_height()
is called for a container or widget
that is height-for-width, it then only needs to return the base minimum width like so:
(C Language Example):
static void
foo_container_get_preferred_width_for_height (GtkWidget *widget,
gint for_height,
gint *min_width,
gint *nat_width)
{
if (i_am_in_height_for_width_mode)
{
GTK_WIDGET_GET_CLASS (widget)->get_preferred_width (widget,
min_width,
nat_width);
}
else
{
... execute the real width-for-height request here based on
the required width of the children collectively if the
container were to be allocated the said height ...
}
}
Height for width requests are generally implemented in terms of a virtual allocation
of widgets in the input orientation. Assuming an height-for-width request mode, a container
would implement the get_preferred_height_for_width()
virtual function by first calling
gtk_widget_get_preferred_width()
for each of its children.
For each potential group of children that are lined up horizontally, the values returned by
gtk_widget_get_preferred_width()
should be collected in an array of GtkRequestedSize
structures.
Any child spacing should be removed from the input for_width
and then the collective size should be
allocated using the gtk_distribute_natural_allocation()
convenience function.
The container will then move on to request the preferred height for each child by using
gtk_widget_get_preferred_height_for_width()
and using the sizes stored in the GtkRequestedSize
array.
To allocate a height-for-width container, it’s again important
to consider that a container must prioritize one dimension over the other. So if
a container is a height-for-width container it must first allocate all widgets horizontally
using a GtkRequestedSize
array and gtk_distribute_natural_allocation()
and then add any
extra space (if and where appropriate) for the widget to expand.
After adding all the expand space, the container assumes it was allocated sufficient
height to fit all of its content. At this time, the container must use the total horizontal sizes
of each widget to request the height-for-width of each of its children and store the requests in a
GtkRequestedSize
array for any widgets that stack vertically (for tabular containers this can
be generalized into the heights and widths of rows and columns).
The vertical space must then again be distributed using gtk_distribute_natural_allocation()
while this time considering the allocated height of the widget minus any vertical spacing
that the container adds. Then vertical expand space should be added where appropriate and available
and the container should go on to actually allocating the child widgets.
See GtkWidget’s geometry management section to learn more about implementing height-for-width geometry management for widgets.
Child properties
GtkContainer introduces child properties.
These are object properties that are not specific
to either the container or the contained widget, but rather to their relation.
Typical examples of child properties are the position or pack-type of a widget
which is contained in a GtkBox
.
Use gtk_container_class_install_child_property()
to install child properties
for a container class and gtk_container_class_find_child_property()
or
gtk_container_class_list_child_properties()
to get information about existing
child properties.
To set the value of a child property, use gtk_container_child_set_property()
,
gtk_container_child_set()
or gtk_container_child_set_valist()
.
To obtain the value of a child property, use
gtk_container_child_get_property()
, gtk_container_child_get()
or
gtk_container_child_get_valist()
. To emit notification about child property
changes, use gtk_widget_child_notify()
.
GtkContainer as GtkBuildable
The GtkContainer implementation of the GtkBuildable interface supports a <packing> element for children, which can contain multiple <property> elements that specify child properties for the child.
Since 2.16, child properties can also be marked as translatable using the same “translatable”, “comments” and “context” attributes that are used for regular properties.
Since 3.16, containers can have a <focus-chain> element containing multiple <widget> elements, one for each child that should be added to the focus chain. The ”name” attribute gives the id of the widget.
An example of these properties in UI definitions:
<object class="GtkBox">
<child>
<object class="GtkEntry" id="entry1"/>
<packing>
<property name="pack-type">start</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="entry2"/>
</child>
<focus-chain>
<widget name="entry1"/>
<widget name="entry2"/>
</focus-chain>
</object>
The ContainerProtocol
protocol exposes the methods and properties of an underlying GtkContainer
instance.
The default implementation of these can be found in the protocol extension below.
For a concrete class that implements these methods and properties, see Container
.
Alternatively, use ContainerRef
as a lighweight, unowned
reference if you already have an instance you just want to use.
-
Untyped pointer to the underlying
GtkContainer
instance.Declaration
Swift
var ptr: UnsafeMutableRawPointer! { get }
-
container_ptr
Default implementationTyped pointer to the underlying
GtkContainer
instance.Default Implementation
Return the stored, untyped pointer as a typed pointer to the
GtkContainer
instance.Declaration
Swift
var container_ptr: UnsafeMutablePointer<GtkContainer>! { get }
-
Required Initialiser for types conforming to
ContainerProtocol
Declaration
Swift
init(raw: UnsafeMutableRawPointer)
-
set(child:
Extension methodproperty: value: ) Set a child widget property
Declaration
Swift
@discardableResult @inlinable func set<W, P, V>(child: W, property: P, value: V) -> Bool where W : WidgetProtocol, P : ParamSpecProtocol, V : ValueProtocol
Parameters
child
widget to set property for
property
ParamSpec
for propertyvalue
value to set
Return Value
true
if successful,false
if value cannot be transformed -
set(child:
Extension methodproperty: value: ) Set the property of a child widget
Declaration
Swift
@inlinable func set<W, P, V>(child widget: W, property: P, value: V) where W : WidgetProtocol, P : PropertyNameProtocol
Parameters
widget
child widget to set the property for
property
name of the property
value
the value to set the property to
-
set(child:
Extension methodproperties: ) Set the property of a child widget
Declaration
Swift
@inlinable func set<W, P>(child widget: W, properties: [(P, Any)]) where W : WidgetProtocol, P : PropertyNameProtocol
Parameters
child
widget to set property for
properties
array of
PropertyName
/value pairs for the properties to set -
set(child:
Extension methodproperties: ) Set up a child widget with the given list of properties
Declaration
Swift
@inlinable func set<W, P>(child widget: W, properties ps: (P, Any)...) where W : WidgetProtocol, P : PropertyNameProtocol
Parameters
widget
child widget to set properties for
properties
PropertyName
/ value pairs to set -
add(_:
Extension methodproperties: ) Add a child widget with a given list of properties
Declaration
Swift
@inlinable func add<W, P>(_ widget: W, properties ps: (P, Any)...) where W : WidgetProtocol, P : PropertyNameProtocol
Parameters
widget
child widget to add
properties
PropertyName
/ value pairs of properties to set -
add(_:
Extension methodproperty: value: ) Add a child widget with a given property
Declaration
Swift
@inlinable func add<W, P, V>(_ widget: W, property p: P, value v: V) where W : WidgetProtocol, P : PropertyNameProtocol
Parameters
widget
child widget to add
property
name of the property to set
value
value of the property to set
-
add(widgets:
Extension method) Add an array of widgets to the container
Declaration
Swift
@inlinable func add<W>(widgets: [W]) where W : WidgetProtocol
Parameters
widgets
the widgets to add
-
add(_:
Extension method) Add widgets to the container
Declaration
Swift
@inlinable func add<W>(_ widgets: W...) where W : WidgetProtocol
Parameters
widgets
the widgets to add
-
bind(property:
Extension methodto: _: flags: transformFrom: transformTo: ) Bind a
ContainerPropertyName
source property to a given target object.Declaration
Swift
@discardableResult @inlinable func bind<Q, T>(property source_property: ContainerPropertyName, to target: T, _ target_property: Q, flags f: BindingFlags = .default, transformFrom transform_from: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }, transformTo transform_to: @escaping GLibObject.ValueTransformer = { $0.transform(destValue: $1) }) -> BindingRef! where Q : PropertyNameProtocol, T : ObjectProtocol
Parameters
source_property
the source property to bind
target
the target object to bind to
target_property
the target property to bind to
flags
the flags to pass to the
Binding
transform_from
ValueTransformer
to use for forward transformationtransform_to
ValueTransformer
to use for backwards transformationReturn Value
binding reference or
nil
in case of an error -
get(property:
Extension method) Get the value of a Container property
Declaration
Swift
@inlinable func get(property: ContainerPropertyName) -> GLibObject.Value
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
set(property:
Extension methodvalue: ) Set the value of a Container property. Note that this will only have an effect on properties that are writable and not construct-only!
Declaration
Swift
@inlinable func set(property: ContainerPropertyName, value v: GLibObject.Value)
Parameters
property
the property to get the value for
Return Value
the value of the named property
-
connect(signal:
Extension methodflags: handler: ) Connect a Swift signal handler to the given, typed
ContainerSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ContainerSignalName, flags f: ConnectFlags = ConnectFlags(0), handler h: @escaping SignalHandler) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
handler
The Swift signal handler (function or callback) to invoke on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
connect(signal:
Extension methodflags: data: destroyData: signalHandler: ) Connect a C signal handler to the given, typed
ContainerSignalName
signalDeclaration
Swift
@discardableResult @inlinable func connect(signal s: ContainerSignalName, flags f: ConnectFlags = ConnectFlags(0), data userData: gpointer!, destroyData destructor: GClosureNotify? = nil, signalHandler h: @escaping GCallback) -> Int
Parameters
signal
The signal to connect
flags
The connection flags to use
data
A pointer to user data to provide to the callback
destroyData
A
GClosureNotify
C function to destroy the data pointed to byuserData
signalHandler
The C function to be called on the given signal
Return Value
The signal handler ID (always greater than 0 for successful connections)
-
onAdd(flags:
Extension methodhandler: ) Note
This represents the underlyingadd
signalDeclaration
Swift
@discardableResult @inlinable func onAdd(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ContainerRef, _ object: WidgetRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
object
none
handler
The signal handler to call Run the given callback whenever the
add
signal is emitted -
addSignal
Extension methodTyped
add
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var addSignal: ContainerSignalName { get }
-
onCheckResize(flags:
Extension methodhandler: ) Note
This represents the underlyingcheck-resize
signalDeclaration
Swift
@discardableResult @inlinable func onCheckResize(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ContainerRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
handler
The signal handler to call Run the given callback whenever the
checkResize
signal is emitted -
checkResizeSignal
Extension methodTyped
check-resize
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var checkResizeSignal: ContainerSignalName { get }
-
onRemove(flags:
Extension methodhandler: ) Note
This represents the underlyingremove
signalDeclaration
Swift
@discardableResult @inlinable func onRemove(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ContainerRef, _ object: WidgetRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
object
none
handler
The signal handler to call Run the given callback whenever the
remove
signal is emitted -
removeSignal
Extension methodTyped
remove
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var removeSignal: ContainerSignalName { get }
-
onSetFocusChild(flags:
Extension methodhandler: ) Note
This represents the underlyingset-focus-child
signalDeclaration
Swift
@discardableResult @inlinable func onSetFocusChild(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ContainerRef, _ object: WidgetRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
object
none
handler
The signal handler to call Run the given callback whenever the
setFocusChild
signal is emitted -
setFocusChildSignal
Extension methodTyped
set-focus-child
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var setFocusChildSignal: ContainerSignalName { get }
-
onNotifyBorderWidth(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::border-width
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyBorderWidth(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ContainerRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyBorderWidth
signal is emitted -
notifyBorderWidthSignal
Extension methodTyped
notify::border-width
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyBorderWidthSignal: ContainerSignalName { get }
-
onNotifyChild(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::child
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyChild(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ContainerRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyChild
signal is emitted -
notifyChildSignal
Extension methodTyped
notify::child
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyChildSignal: ContainerSignalName { get }
-
onNotifyResizeMode(flags:
Extension methodhandler: ) The notify signal is emitted on an object when one of its properties has its value set through
g_object_set_property()
,g_object_set()
, et al.Note that getting this signal doesn’t itself guarantee that the value of the property has actually changed. When it is emitted is determined by the derived GObject class. If the implementor did not create the property with
G_PARAM_EXPLICIT_NOTIFY
, then any call tog_object_set_property()
results innotify
being emitted, even if the new value is the same as the old. If they did passG_PARAM_EXPLICIT_NOTIFY
, then this signal is emitted only when they explicitly callg_object_notify()
org_object_notify_by_pspec()
, and common practice is to do that only when the value has actually changed.This signal is typically used to obtain change notification for a single property, by specifying the property name as a detail in the
g_signal_connect()
call, like this:(C Language Example):
g_signal_connect (text_view->buffer, "notify::paste-target-list", G_CALLBACK (gtk_text_view_target_list_notify), text_view)
It is important to note that you must use canonical parameter names as detail strings for the notify signal.
Note
This represents the underlyingnotify::resize-mode
signalDeclaration
Swift
@discardableResult @inlinable func onNotifyResizeMode(flags: ConnectFlags = ConnectFlags(0), handler: @escaping (_ unownedSelf: ContainerRef, _ pspec: ParamSpecRef) -> Void) -> Int
Parameters
flags
Flags
unownedSelf
Reference to instance of self
pspec
the
GParamSpec
of the property which changed.handler
The signal handler to call Run the given callback whenever the
notifyResizeMode
signal is emitted -
notifyResizeModeSignal
Extension methodTyped
notify::resize-mode
signal for using theconnect(signal:)
methodsDeclaration
Swift
static var notifyResizeModeSignal: ContainerSignalName { get }
-
add(widget:
Extension method) Adds
widget
tocontainer
. Typically used for simple containers such asGtkWindow
,GtkFrame
, orGtkButton
; for more complicated layout containers such asGtkBox
orGtkGrid
, this function will pick default packing parameters that may not be correct. So consider functions such asgtk_box_pack_start()
andgtk_grid_attach()
as an alternative togtk_container_add()
in those cases. A widget may be added to only one container at a time; you can’t place the same widget inside two different containers.Note that some containers, such as
GtkScrolledWindow
orGtkListBox
, may add intermediate children between the added widget and the container.Declaration
Swift
@inlinable func add<WidgetT>(widget: WidgetT) where WidgetT : WidgetProtocol
-
checkResize()
Extension methodUndocumented
Declaration
Swift
@inlinable func checkResize()
-
childGetProperty(child:
Extension methodpropertyName: value: ) Gets the value of a child property for
child
andcontainer
.Declaration
Swift
@inlinable func childGetProperty<ValueT, WidgetT>(child: WidgetT, propertyName: UnsafePointer<gchar>!, value: ValueT) where ValueT : ValueProtocol, WidgetT : WidgetProtocol
-
childGetValist(child:
Extension methodfirstPropertyName: varArgs: ) Gets the values of one or more child properties for
child
andcontainer
.Declaration
Swift
@inlinable func childGetValist<WidgetT>(child: WidgetT, firstPropertyName: UnsafePointer<gchar>!, varArgs: CVaListPointer) where WidgetT : WidgetProtocol
-
childNotify(child:
Extension methodchildProperty: ) Emits a
GtkWidget::child-notify
signal for the child propertychild_property
on the child.This is an analogue of
g_object_notify()
for child properties.Also see
gtk_widget_child_notify()
.Declaration
Swift
@inlinable func childNotify<WidgetT>(child: WidgetT, childProperty: UnsafePointer<gchar>!) where WidgetT : WidgetProtocol
-
childNotifyByPspec(child:
Extension methodpspec: ) Emits a
GtkWidget::child-notify
signal for the child property specified bypspec
on the child.This is an analogue of
g_object_notify_by_pspec()
for child properties.Declaration
Swift
@inlinable func childNotifyByPspec<ParamSpecT, WidgetT>(child: WidgetT, pspec: ParamSpecT) where ParamSpecT : ParamSpecProtocol, WidgetT : WidgetProtocol
-
childSetProperty(child:
Extension methodpropertyName: value: ) Sets a child property for
child
andcontainer
.Declaration
Swift
@inlinable func childSetProperty<ValueT, WidgetT>(child: WidgetT, propertyName: UnsafePointer<gchar>!, value: ValueT) where ValueT : ValueProtocol, WidgetT : WidgetProtocol
-
childSetValist(child:
Extension methodfirstPropertyName: varArgs: ) Sets one or more child properties for
child
andcontainer
.Declaration
Swift
@inlinable func childSetValist<WidgetT>(child: WidgetT, firstPropertyName: UnsafePointer<gchar>!, varArgs: CVaListPointer) where WidgetT : WidgetProtocol
-
childType()
Extension methodReturns the type of the children supported by the container.
Note that this may return
G_TYPE_NONE
to indicate that no more children can be added, e.g. for aGtkPaned
which already has two children.Declaration
Swift
@inlinable func childType() -> GType
-
forall(callback:
Extension methodcallbackData: ) Invokes
callback
on each direct child ofcontainer
, including children that are considered “internal” (implementation details of the container). “Internal” children generally weren’t added by the user of the container, but were added by the container implementation itself.Most applications should use
gtk_container_foreach()
, rather thangtk_container_forall()
.Declaration
Swift
@inlinable func forall(callback: GtkCallback?, callbackData: gpointer! = nil)
-
foreach(callback:
Extension methodcallbackData: ) Invokes
callback
on each non-internal child ofcontainer
. Seegtk_container_forall()
for details on what constitutes an “internal” child. For all practical purposes, this function should iterate over precisely those child widgets that were added to the container by the application with explicitadd()
calls.It is permissible to remove the child from the
callback
handler.Most applications should use
gtk_container_foreach()
, rather thangtk_container_forall()
.Declaration
Swift
@inlinable func foreach(callback: GtkCallback?, callbackData: gpointer! = nil)
-
getBorderWidth()
Extension methodRetrieves the border width of the container. See
gtk_container_set_border_width()
.Declaration
Swift
@inlinable func getBorderWidth() -> Int
-
getChildren()
Extension methodReturns the container’s non-internal children. See
gtk_container_forall()
for details on what constitutes an “internal” child.Declaration
Swift
@inlinable func getChildren() -> GLib.ListRef!
-
getFocusChain(focusableWidgets:
Extension method) Retrieves the focus chain of the container, if one has been set explicitly. If no focus chain has been explicitly set, GTK+ computes the focus chain based on the positions of the children. In that case, GTK+ stores
nil
infocusable_widgets
and returnsfalse
.get_focus_chain is deprecated: For overriding focus behavior, use the GtkWidgetClass::focus signal.
Declaration
Swift
@available(*, deprecated) @inlinable func getFocusChain(focusableWidgets: UnsafeMutablePointer<UnsafeMutablePointer<GList>?>!) -> Bool
-
getFocusChild()
Extension methodReturns the current focus child widget inside
container
. This is not the currently focused widget. That can be obtained by callinggtk_window_get_focus()
.Declaration
Swift
@inlinable func getFocusChild() -> WidgetRef!
-
getFocusHadjustment()
Extension methodRetrieves the horizontal focus adjustment for the container. See gtk_container_set_focus_hadjustment ().
Declaration
Swift
@inlinable func getFocusHadjustment() -> AdjustmentRef!
-
getFocusVadjustment()
Extension methodRetrieves the vertical focus adjustment for the container. See
gtk_container_set_focus_vadjustment()
.Declaration
Swift
@inlinable func getFocusVadjustment() -> AdjustmentRef!
-
getPathFor(child:
Extension method) Returns a newly created widget path representing all the widget hierarchy from the toplevel down to and including
child
.Declaration
Swift
@inlinable func getPathFor<WidgetT>(child: WidgetT) -> WidgetPathRef! where WidgetT : WidgetProtocol
-
getResizeMode()
Extension methodReturns the resize mode for the container. See gtk_container_set_resize_mode ().
get_resize_mode is deprecated: Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.
Declaration
Swift
@available(*, deprecated) @inlinable func getResizeMode() -> GtkResizeMode
-
propagateDraw(child:
Extension methodcr: ) When a container receives a call to the draw function, it must send synthetic
GtkWidget::draw
calls to all children that don’t have their ownGdkWindows
. This function provides a convenient way of doing this. A container, when it receives a call to itsGtkWidget::draw
function, callsgtk_container_propagate_draw()
once for each child, passing in thecr
the container received.gtk_container_propagate_draw()
takes care of translating the origin ofcr
, and deciding whether the draw needs to be sent to the child. It is a convenient and optimized way of getting the same effect as callinggtk_widget_draw()
on the child directly.In most cases, a container can simply either inherit the
GtkWidget::draw
implementation fromGtkContainer
, or do some drawing and then chain to thedraw
implementation fromGtkContainer
.Declaration
Swift
@inlinable func propagateDraw<ContextT, WidgetT>(child: WidgetT, cr: ContextT) where ContextT : ContextProtocol, WidgetT : WidgetProtocol
-
remove(widget:
Extension method) Removes
widget
fromcontainer
.widget
must be insidecontainer
. Note thatcontainer
will own a reference towidget
, and that this may be the last reference held; so removing a widget from its container can destroy that widget. If you want to usewidget
again, you need to add a reference to it before removing it from a container, usingg_object_ref()
. If you don’t want to usewidget
again it’s usually more efficient to simply destroy it directly usinggtk_widget_destroy()
since this will remove it from the container and help break any circular reference count cycles.Declaration
Swift
@inlinable func remove<WidgetT>(widget: WidgetT) where WidgetT : WidgetProtocol
-
resizeChildren()
Extension methodresize_children is deprecated: This method is deprecated.
Declaration
Swift
@available(*, deprecated) @inlinable func resizeChildren()
-
set(borderWidth:
Extension method) Sets the border width of the container.
The border width of a container is the amount of space to leave around the outside of the container. The only exception to this is
GtkWindow
; because toplevel windows can’t leave space outside, they leave the space inside. The border is added on all sides of the container. To add space to only one side, use a specificGtkWidget:margin
property on the child widget, for exampleGtkWidget:margin-top
.Declaration
Swift
@inlinable func set(borderWidth: Int)
-
setFocusChain(focusableWidgets:
Extension method) Sets a focus chain, overriding the one computed automatically by GTK+.
In principle each widget in the chain should be a descendant of the container, but this is not enforced by this method, since it’s allowed to set the focus chain before you pack the widgets, or have a widget in the chain that isn’t always packed. The necessary checks are done when the focus chain is actually traversed.
set_focus_chain is deprecated: For overriding focus behavior, use the GtkWidgetClass::focus signal.
Declaration
Swift
@available(*, deprecated) @inlinable func setFocusChain<ListT>(focusableWidgets: ListT) where ListT : ListProtocol
-
setFocus(child:
Extension method) Sets, or unsets if
child
isnil
, the focused child ofcontainer
.This function emits the GtkContainer
set_focus_child
signal ofcontainer
. Implementations ofGtkContainer
can override the default behaviour by overriding the class closure of this signal.This is function is mostly meant to be used by widgets. Applications can use
gtk_widget_grab_focus()
to manually set the focus to a specific widget.Declaration
Swift
@inlinable func setFocus(child: WidgetRef? = nil)
-
setFocus(child:
Extension method) Sets, or unsets if
child
isnil
, the focused child ofcontainer
.This function emits the GtkContainer
set_focus_child
signal ofcontainer
. Implementations ofGtkContainer
can override the default behaviour by overriding the class closure of this signal.This is function is mostly meant to be used by widgets. Applications can use
gtk_widget_grab_focus()
to manually set the focus to a specific widget.Declaration
Swift
@inlinable func setFocus<WidgetT>(child: WidgetT?) where WidgetT : WidgetProtocol
-
setFocusHadjustment(adjustment:
Extension method) Hooks up an adjustment to focus handling in a container, so when a child of the container is focused, the adjustment is scrolled to show that widget. This function sets the horizontal alignment. See
gtk_scrolled_window_get_hadjustment()
for a typical way of obtaining the adjustment andgtk_container_set_focus_vadjustment()
for setting the vertical adjustment.The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the container.
Declaration
Swift
@inlinable func setFocusHadjustment<AdjustmentT>(adjustment: AdjustmentT) where AdjustmentT : AdjustmentProtocol
-
setFocusVadjustment(adjustment:
Extension method) Hooks up an adjustment to focus handling in a container, so when a child of the container is focused, the adjustment is scrolled to show that widget. This function sets the vertical alignment. See
gtk_scrolled_window_get_vadjustment()
for a typical way of obtaining the adjustment andgtk_container_set_focus_hadjustment()
for setting the horizontal adjustment.The adjustments have to be in pixel units and in the same coordinate system as the allocation for immediate children of the container.
Declaration
Swift
@inlinable func setFocusVadjustment<AdjustmentT>(adjustment: AdjustmentT) where AdjustmentT : AdjustmentProtocol
-
setReallocateRedraws(needsRedraws:
Extension method) Sets the
reallocate_redraws
flag of the container to the given value.Containers requesting reallocation redraws get automatically redrawn if any of their children changed allocation.
set_reallocate_redraws is deprecated: Call gtk_widget_queue_draw() in your size_allocate handler.
Declaration
Swift
@available(*, deprecated) @inlinable func setReallocateRedraws(needsRedraws: Bool)
-
set(resizeMode:
Extension method) Sets the resize mode for the container.
The resize mode of a container determines whether a resize request will be passed to the container’s parent, queued for later execution or executed immediately.
set_resize_mode is deprecated: Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.
Declaration
Swift
@available(*, deprecated) @inlinable func set(resizeMode: GtkResizeMode)
-
unsetFocusChain()
Extension methodRemoves a focus chain explicitly set with
gtk_container_set_focus_chain()
.unset_focus_chain is deprecated: For overriding focus behavior, use the GtkWidgetClass::focus signal.
Declaration
Swift
@available(*, deprecated) @inlinable func unsetFocusChain()
-
borderWidth
Extension methodRetrieves the border width of the container. See
gtk_container_set_border_width()
.Declaration
Swift
@inlinable var borderWidth: Int { get nonmutating set }
-
children
Extension methodReturns the container’s non-internal children. See
gtk_container_forall()
for details on what constitutes an “internal” child.Declaration
Swift
@inlinable var children: GLib.ListRef! { get }
-
focusChild
Extension methodReturns the current focus child widget inside
container
. This is not the currently focused widget. That can be obtained by callinggtk_window_get_focus()
.Declaration
Swift
@inlinable var focusChild: WidgetRef! { get nonmutating set }
-
focusHadjustment
Extension methodRetrieves the horizontal focus adjustment for the container. See gtk_container_set_focus_hadjustment ().
Declaration
Swift
@inlinable var focusHadjustment: AdjustmentRef! { get nonmutating set }
-
focusVadjustment
Extension methodRetrieves the vertical focus adjustment for the container. See
gtk_container_set_focus_vadjustment()
.Declaration
Swift
@inlinable var focusVadjustment: AdjustmentRef! { get nonmutating set }
-
resizeMode
Extension methodReturns the resize mode for the container. See gtk_container_set_resize_mode ().
get_resize_mode is deprecated: Resize modes are deprecated. They aren’t necessary anymore since frame clocks and might introduce obscure bugs if used.
Declaration
Swift
@inlinable var resizeMode: GtkResizeMode { get nonmutating set }
-
widget
Extension methodUndocumented
Declaration
Swift
@inlinable var widget: GtkWidget { get }