Class: Gtk::Container

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Overview

Base class for containers.

Instance Method Summary collapse

Instance Method Details

#add(widget) ⇒ nil

Adds widget to container. Typically used for simple containers such as Gtk::Window, #GtkFrame, or #GtkButton; for more complicated layout containers such as Gtk::Box or #GtkGrid, this function will pick default packing parameters that may not be correct. So consider functions such as gtk_box_pack_start() and gtk_grid_attach() as an alternative to gtk_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 Gtk::ScrolledWindow or #GtkListBox, may add intermediate children between the added widget and the container.

Parameters:

  • widget (Gtk::Widget)

    a widget to be placed inside container

Returns:

  • (nil)

#add_with_properties(widget, first_prop_name, array) ⇒ nil

Adds widget to container, setting child properties at the same time. See gtk_container_add() and gtk_container_child_set() for more details.

Parameters:

  • widget (Gtk::Widget)

    a widget to be placed inside container

  • first_prop_name (String)

    the name of the first child property to set

  • array (Array)

    a nil-terminated list of property names and values, starting with first_prop_name

Returns:

  • (nil)

#border_widthInteger

Returns border-width.

Returns:

  • (Integer)

    border-width

#border_width=(border_width) ⇒ Integer

Parameters:

  • border_width (Integer)

Returns:

  • (Integer)

    border-width

  • (Integer)

    border-width

#check_resizenil

Returns:

  • (nil)

#child=(child) ⇒ Gtk::Widget

Returns child.

Parameters:

Returns:

#child_get(child, first_prop_name, array) ⇒ nil

Gets the values of one or more child properties for child and container.

Parameters:

  • child (Gtk::Widget)

    a widget which is a child of container

  • first_prop_name (String)

    the name of the first property to get

  • array (Array)

    return location for the first property, followed optionally by more name/return location pairs, followed by nil

Returns:

  • (nil)

#child_get_property(child, property_name, value) ⇒ nil

Gets the value of a child property for child and container.

Parameters:

  • child (Gtk::Widget)

    a widget which is a child of container

  • property_name (String)

    the name of the property to get

  • value (GObject::Value)

    a location to return the value

Returns:

  • (nil)

#child_get_valist(child, first_property_name, var_args) ⇒ nil

Gets the values of one or more child properties for child and container.

Parameters:

  • child (Gtk::Widget)

    a widget which is a child of container

  • first_property_name (String)

    the name of the first property to get

  • var_args (Gtk::va_list)

    return location for the first property, followed optionally by more name/return location pairs, followed by nil

Returns:

  • (nil)

#child_notify(child, child_property) ⇒ nil

Emits a Gtk::Widget::child-notify signal for the

child property][child-properties

child_property on the child.

This is an analogue of g_object_notify() for child properties.

Also see gtk_widget_child_notify().

Parameters:

  • child (Gtk::Widget)

    the child widget

  • child_property (String)

    the name of a child property installed on the class of container

Returns:

  • (nil)

#child_notify_by_pspec(child, pspec) ⇒ nil

Emits a Gtk::Widget::child-notify signal for the

child property][child-properties

specified by

pspec on the child.

This is an analogue of g_object_notify_by_pspec() for child properties.

Parameters:

  • child (Gtk::Widget)

    the child widget

  • pspec (GObject::ParamSpec)

    the GParam::Spec of a child property instealled on the class of container

Returns:

  • (nil)

#child_set(child, first_prop_name, array) ⇒ nil

Sets one or more child properties for child and container.

Parameters:

  • child (Gtk::Widget)

    a widget which is a child of container

  • first_prop_name (String)

    the name of the first property to set

  • array (Array)

    a nil-terminated list of property names and values, starting with first_prop_name

Returns:

  • (nil)

#child_set_property(child, property_name, value) ⇒ nil

Sets a child property for child and container.

Parameters:

  • child (Gtk::Widget)

    a widget which is a child of container

  • property_name (String)

    the name of the property to set

  • value (GObject::Value)

    the value to set the property to

Returns:

  • (nil)

#child_set_valist(child, first_property_name, var_args) ⇒ nil

Sets one or more child properties for child and container.

Parameters:

  • child (Gtk::Widget)

    a widget which is a child of container

  • first_property_name (String)

    the name of the first property to set

  • var_args (Gtk::va_list)

    a nil-terminated list of property names and values, starting with first_prop_name

Returns:

  • (nil)

#child_typeGLib::Type

Returns 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 a Gtk::Paned which already has two children.

Returns:

#childrenGLib::List

Returns the container’s non-internal children. See gtk_container_forall() for details on what constitutes an “internal” child.

Returns:

  • (GLib::List)

    a newly-allocated list of the container’s non-internal children.

#find_child_property(property_name) ⇒ GObject::ParamSpec

Finds a child property of a container class by name.

Parameters:

  • property_name (String)

    the name of the child property to find

Returns:

  • (GObject::ParamSpec)

    the GParam::Spec of the child property or nil if class has no child property with that name.

#focus_chain=(focusable_widgets) ⇒ nil

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.

Parameters:

  • focusable_widgets (GLib::List)

    the new focus chain

Returns:

  • (nil)

#focus_childGtk::Widget

Returns the current focus child widget inside container. This is not the currently focused widget. That can be obtained by calling gtk_window_get_focus().

Returns:

  • (Gtk::Widget)

    The child widget which will receive the focus inside container when the container is focused, or nil if none is set.

#focus_child=(child) ⇒ nil

Sets, or unsets if child is nil, the focused child of container.

This function emits the GtkContainer::set_focus_child signal of container. Implementations of Gtk::Container 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.

Parameters:

Returns:

  • (nil)

#focus_hadjustmentGtk::Adjustment

Retrieves the horizontal focus adjustment for the container. See gtk_container_set_focus_hadjustment ().

Returns:

  • (Gtk::Adjustment)

    the horizontal focus adjustment, or nil if none has been set.

#focus_hadjustment=(adjustment) ⇒ nil

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 and gtk_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.

Parameters:

  • adjustment (Gtk::Adjustment)

    an adjustment which should be adjusted when the focus is moved among the descendents of container

Returns:

  • (nil)

#focus_vadjustmentGtk::Adjustment

Retrieves the vertical focus adjustment for the container. See gtk_container_set_focus_vadjustment().

Returns:

  • (Gtk::Adjustment)

    the vertical focus adjustment, or nil if none has been set.

#focus_vadjustment=(adjustment) ⇒ nil

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 and gtk_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.

Parameters:

  • adjustment (Gtk::Adjustment)

    an adjustment which should be adjusted when the focus is moved among the descendents of container

Returns:

  • (nil)

#forall(callback, callback_data) ⇒ nil

Invokes callback on each direct child of container, 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 than gtk_container_forall().

Parameters:

  • callback (Gtk::Callback)

    a callback

  • callback_data (GObject)

    callback user data

Returns:

  • (nil)

#foreach(callback, callback_data) ⇒ nil

Invokes callback on each non-internal child of container. See gtk_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 explicit add() calls.

It is permissible to remove the child from the callback handler.

Most applications should use gtk_container_foreach(), rather than gtk_container_forall().

Parameters:

  • callback (Gtk::Callback)

    a callback

  • callback_data (GObject)

    callback user data

Returns:

  • (nil)

#get_focus_chain(focusable_widgets) ⇒ TrueClass

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 in focusable_widgets and returns false. has been set explicitly.

Parameters:

  • focusable_widgets (GLib::List)

    location to store the focus chain of the container, or nil. You should free this list using g_list_free() when you are done with it, however no additional reference count is added to the individual widgets in the focus chain.

Returns:

  • (TrueClass)

    true if the focus chain of the container

#get_path_for_child(child) ⇒ Gtk::WidgetPath

Returns a newly created widget path representing all the widget hierarchy from the toplevel down to and including child.

Parameters:

Returns:

  • (Gtk::WidgetPath)

    A newly created Gtk::WidgetPath

#handle_border_widthnil

Modifies a subclass of Gtk::ContainerClass to automatically add and remove the border-width setting on GtkContainer. This allows the subclass to ignore the border width in its size request and allocate methods. The intent is for a subclass to invoke this in its class_init function.

gtk_container_class_handle_border_width() is necessary because it would break API too badly to make this behavior the default. So subclasses must “opt in” to the parent class handling border_width for them.

Returns:

  • (nil)

#install_child_properties(n_pspecs, pspecs) ⇒ nil

Installs child properties on a container class.

Parameters:

  • n_pspecs (Integer)

    the length of the GParam::Spec array

  • pspecs (Array<GObject::ParamSpec>)

    the GParam::Spec array defining the new child properties

Returns:

  • (nil)

#install_child_property(property_id, pspec) ⇒ nil

Installs a child property on a container class.

Parameters:

  • property_id (Integer)

    the id for the property

  • pspec (GObject::ParamSpec)

    the GParam::Spec for the property

Returns:

  • (nil)

#list_child_properties(n_properties) ⇒ Array<GObject::ParamSpec>

Returns all child properties of a container class.

Parameters:

  • n_properties (Integer)

    location to return the number of child properties found

Returns:

  • (Array<GObject::ParamSpec>)

    a newly allocated nil-terminated array of GParam::Spec*. The array must be freed with g_free().

#propagate_draw(child, cr) ⇒ nil

When a container receives a call to the draw function, it must send synthetic Gtk::Widget::draw calls to all children that don’t have their own Gdk::Windows. This function provides a convenient way of doing this. A container, when it receives a call to its Gtk::Widget::draw function, calls gtk_container_propagate_draw() once for each child, passing in the cr the container received.

gtk_container_propagate_draw() takes care of translating the origin of cr, 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 calling gtk_widget_draw() on the child directly.

In most cases, a container can simply either inherit the Gtk::Widget::draw implementation from #GtkContainer, or do some drawing and then chain to the ::draw implementation from Gtk::Container.

Parameters:

  • child (Gtk::Widget)

    a child of container

  • cr (cairo::Context)

    Cairo context as passed to the container. If you want to use cr in container’s draw function, consider using cairo_save() and cairo_restore() before calling this function.

Returns:

  • (nil)

#reallocate_redraws=(needs_redraws) ⇒ nil

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.

Parameters:

  • needs_redraws (TrueClass)

    the new value for the container’s reallocate_redraws flag

Returns:

  • (nil)

#remove(widget) ⇒ nil

Removes widget from container. widget must be inside container. Note that container will own a reference to widget, and that this may be the last reference held; so removing a widget from its container can destroy that widget. If you want to use widget again, you need to add a reference to it before removing it from a container, using g_object_ref(). If you don’t want to use widget again it’s usually more efficient to simply destroy it directly using gtk_widget_destroy() since this will remove it from the container and help break any circular reference count cycles.

Parameters:

  • widget (Gtk::Widget)

    a current child of container

Returns:

  • (nil)

#resize_childrennil

Returns:

  • (nil)

#resize_modeGtk::ResizeMode

Returns resize-mode.

Returns:

#resize_mode=(resize_mode) ⇒ Gtk::ResizeMode

Parameters:

Returns:

#unset_focus_chainnil

Removes a focus chain explicitly set with gtk_container_set_focus_chain().

Returns:

  • (nil)