Class: Gtk::FlowBox
- Defined in:
- (unknown)
Overview
A GtkFlowBox puts child widgets in reflowing grid.
For instance, with the horizontal orientation, the widgets will be arranged from left to right, starting a new row under the previous row when necessary. Reducing the width in this case will require more rows, so a larger height will be requested.
Likewise, with the vertical orientation, the widgets will be arranged from top to bottom, starting a new column to the right when necessary. Reducing the height will require more columns, so a larger width will be requested.
The size request of a GtkFlowBox alone may not be what you expect;
if you need to be able to shrink it along both axes and dynamically
reflow its children, you may have to wrap it in a GtkScrolledWindow
to enable that.
The children of a GtkFlowBox can be dynamically sorted and filtered.
Although a GtkFlowBox must have only GtkFlowBoxChild children, you
can add any kind of widget to it via [methodGtk.FlowBox.insert], and a
GtkFlowBoxChild widget will automatically be inserted between the box
and the widget.
Also see [classGtk.ListBox].
CSS nodes
flowbox
├── flowboxchild
│ ╰── <child>
├── flowboxchild
│ ╰── <child>
┊
╰── [rubberband]
GtkFlowBox uses a single CSS node with name flowbox. GtkFlowBoxChild
uses a single CSS node with name flowboxchild. For rubberband selection,
a subnode with name rubberband is used.
Accessibility
GtkFlowBox uses the %GTK_ACCESSIBLE_ROLE_GRID role, and GtkFlowBoxChild
uses the %GTK_ACCESSIBLE_ROLE_GRID_CELL role.
Instance Method Summary collapse
- #accept_unpaired_release=(accept_unpaired_release) ⇒ Boolean
-
#accept_unpaired_release? ⇒ Boolean
Accept-unpaired-release.
-
#activate_on_single_click ⇒ Boolean
Returns whether children activate on single clicks.
-
#activate_on_single_click=(activate_on_single_click) ⇒ Boolean
Determines whether children can be activated with a single click, or require a double-click.
-
#activate_on_single_click? ⇒ Boolean
Determines whether children can be activated with a single click, or require a double-click.
-
#append(child) ⇒ nil
Adds child to the end of self.
-
#bind_model(model, create_widget_func, user_data, user_data_free_func) ⇒ nil
Binds model to box.
-
#column_spacing ⇒ Integer
The amount of horizontal space between two children.
-
#column_spacing=(column_spacing) ⇒ Integer
The amount of horizontal space between two children.
-
#get_child_at_index(idx) ⇒ Gtk::FlowBoxChild
Gets the nth child in the box.
-
#get_child_at_pos(x, y) ⇒ Gtk::FlowBoxChild
Gets the child in the (x, y) position.
-
#hadjustment=(adjustment) ⇒ nil
Hooks up an adjustment to focus handling in box.
-
#homogeneous ⇒ Boolean
Returns whether the box is homogeneous.
-
#homogeneous=(homogeneous) ⇒ Boolean
Determines whether all children should be allocated the same size.
-
#homogeneous? ⇒ Boolean
Determines whether all children should be allocated the same size.
-
#initialize ⇒ Gtk::Widget
constructor
Creates a
GtkFlowBox. -
#insert(widget, position) ⇒ nil
Inserts the widget into box at position.
-
#invalidate_filter ⇒ nil
Updates the filtering for all children.
-
#invalidate_sort ⇒ nil
Updates the sorting for all children.
-
#max_children_per_line ⇒ Integer
The maximum amount of children to request space for consecutively in the given orientation.
-
#max_children_per_line=(max_children_per_line) ⇒ Integer
The maximum amount of children to request space for consecutively in the given orientation.
-
#min_children_per_line ⇒ Integer
The minimum number of children to allocate consecutively in the given orientation.
-
#min_children_per_line=(min_children_per_line) ⇒ Integer
The minimum number of children to allocate consecutively in the given orientation.
-
#prepend(child) ⇒ nil
Adds child to the start of self.
-
#remove(widget) ⇒ nil
Removes a child from box.
-
#remove_all ⇒ nil
Removes all children from box.
-
#row_spacing ⇒ Integer
The amount of vertical space between two children.
-
#row_spacing=(row_spacing) ⇒ Integer
The amount of vertical space between two children.
-
#select_all ⇒ nil
Select all children of box, if the selection mode allows it.
-
#select_child(child) ⇒ nil
Selects a single child of box, if the selection mode allows it.
-
#selected_children ⇒ GLib::List<Gtk::FlowBoxChild>
Creates a list of all selected children.
-
#selected_foreach(func, data) ⇒ nil
Calls a function for each selected child.
-
#selection_mode ⇒ Gtk::SelectionMode
The selection mode used by the flow box.
-
#selection_mode=(selection_mode) ⇒ Gtk::SelectionMode
The selection mode used by the flow box.
-
#set_filter_func(filter_func, user_data, destroy) ⇒ nil
By setting a filter function on the box one can decide dynamically which of the children to show.
-
#set_sort_func(sort_func, user_data, destroy) ⇒ nil
By setting a sort function on the box, one can dynamically reorder the children of the box, based on the contents of the children.
-
#unselect_all ⇒ nil
Unselect all children of box, if the selection mode allows it.
-
#unselect_child(child) ⇒ nil
Unselects a single child of box, if the selection mode allows it.
-
#vadjustment=(adjustment) ⇒ nil
Hooks up an adjustment to focus handling in box.
Methods inherited from Widget
#accessible_role, #accessible_role=, #action_set_enabled, #activate, #activate_action, #activate_action_variant, #activate_default, #activate_signal, #activate_signal=, #activate_signal_from_name=, #add_binding, #add_binding_action, #add_binding_signal, #add_controller, #add_css_class, #add_mnemonic_label, #add_shortcut, #add_tick_callback, #allocate, #allocated_baseline, #allocated_height, #allocated_width, #baseline, #bind_template_callback_full, #bind_template_child, #bind_template_child_full, #can_focus, #can_focus=, #can_focus?, #can_target, #can_target=, #can_target?, #child_focus, #child_visible, #child_visible=, #children, #clipboard, #compute_bounds, #compute_expand, #compute_point, #compute_transform, #contains, #create_pango_context, #create_pango_layout, #css_classes, #css_classes=, #css_name, #css_name=, #cursor, #cursor=, #cursor_from_name=, default_direction, default_direction=, #direction, #direction=, #display, #dispose_template, #drag_check_threshold, #error_bell, #first_child, #focus_child, #focus_child=, #focus_on_click, #focus_on_click=, #focus_on_click?, #focusable, #focusable=, #focusable?, #font_map, #font_map=, #font_options, #font_options=, #frame_clock, #get_allocation, #get_ancestor, #get_color, #get_preferred_size, #get_size, #get_size_request, #get_template_child, #grab_focus, #halign, #halign=, #has_css_class, #has_default, #has_default=, #has_default?, #has_focus, #has_focus=, #has_focus?, #has_tooltip, #has_tooltip=, #has_tooltip?, #has_visible_focus, have_template?, #height, #height_request, #height_request=, #hexpand, #hexpand=, #hexpand?, #hexpand_set, #hexpand_set=, #hexpand_set?, #hide, #in_destruction, #init_template, #insert_action_group, #insert_action_group_raw, #insert_after, #insert_before, #install_action, #install_property_action, #is_ancestor, #is_drawable, #is_focus, #is_sensitive, #is_visible, #keynav_failed, #last_child, #layout_manager, #layout_manager=, #layout_manager_type, #layout_manager_type=, #list_mnemonic_labels, #map, #mapped, #margin_bottom, #margin_bottom=, #margin_end, #margin_end=, #margin_start, #margin_start=, #margin_top, #margin_top=, #measure, #mnemonic_activate, #name, #name=, #native, #next_sibling, #observe_children, #observe_controllers, #opacity, #opacity=, #overflow, #overflow=, #pango_context, #parent, #parent=, #pick, #prev_sibling, #primary_clipboard, #query_action, #queue_allocate, #queue_draw, #queue_resize, #realize, #realized, #receives_default, #receives_default=, #receives_default?, #remove_controller, #remove_css_class, #remove_mnemonic_label, #remove_tick_callback, #request_mode, #root, #root=, #scale_factor, #scale_factor=, #sensitive, #sensitive=, #sensitive?, #set_size_request, #set_size_request_raw, #set_state_flags, #set_template, #set_template_raw, #settings, #should_layout, #show, #size_allocate, #snapshot_child, #state_flags, #style_context, #style_context_raw, #template=, template_children, #template_from_resource=, #template_scope=, #tooltip_markup, #tooltip_markup=, #tooltip_text, #tooltip_text=, #translate_coordinates, #translate_coordinates_raw, #trigger_tooltip_query, #unmap, #unparent, #unrealize, #unset_state_flags, #valign, #valign=, #vexpand, #vexpand=, #vexpand?, #vexpand_set, #vexpand_set=, #vexpand_set?, #visible, #visible=, #visible?, #width, #width_request, #width_request=
Constructor Details
#initialize ⇒ Gtk::Widget
Creates a GtkFlowBox.
Instance Method Details
#accept_unpaired_release=(accept_unpaired_release) ⇒ Boolean
#accept_unpaired_release? ⇒ Boolean
Returns accept-unpaired-release.
#activate_on_single_click ⇒ Boolean
Returns whether children activate on single clicks.
#activate_on_single_click=(activate_on_single_click) ⇒ Boolean
Determines whether children can be activated with a single click, or require a double-click.
#activate_on_single_click? ⇒ Boolean
Determines whether children can be activated with a single click, or require a double-click.
#append(child) ⇒ nil
Adds child to the end of self.
If a sort function is set, the widget will actually be inserted at the calculated position.
See also: [methodGtk.FlowBox.insert].
#bind_model(model, create_widget_func, user_data, user_data_free_func) ⇒ nil
Binds model to box.
If box was already bound to a model, that previous binding is destroyed.
The contents of box are cleared and then filled with widgets that represent items from model. box is updated whenever model changes. If model is nil, box is left empty.
It is undefined to add or remove widgets directly (for example, with [methodGtk.FlowBox.insert]) while box is bound to a model.
Note that using a model is incompatible with the filtering and sorting
functionality in GtkFlowBox. When using a model, filtering and sorting
should be implemented by the model.
#column_spacing ⇒ Integer
The amount of horizontal space between two children.
#column_spacing=(column_spacing) ⇒ Integer
The amount of horizontal space between two children.
#get_child_at_index(idx) ⇒ Gtk::FlowBoxChild
Gets the nth child in the box.
#get_child_at_pos(x, y) ⇒ Gtk::FlowBoxChild
Gets the child in the (x, y) position.
Both x and y are assumed to be relative to the origin of box.
#hadjustment=(adjustment) ⇒ nil
Hooks up an adjustment to focus handling in box.
The adjustment is also used for autoscrolling during rubberband selection. See [methodGtk.ScrolledWindow.get_hadjustment] for a typical way of obtaining the adjustment, and [methodGtk.FlowBox.set_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 box.
#homogeneous ⇒ Boolean
Returns whether the box is homogeneous.
#homogeneous=(homogeneous) ⇒ Boolean
Determines whether all children should be allocated the same size.
#homogeneous? ⇒ Boolean
Determines whether all children should be allocated the same size.
#insert(widget, position) ⇒ nil
Inserts the widget into box at position.
If a sort function is set, the widget will actually be inserted at the calculated position.
If position is -1, or larger than the total number of children in the box, then the widget will be appended to the end.
#invalidate_filter ⇒ nil
Updates the filtering for all children.
Call this function when the result of the filter function on the box is changed due to an external factor. For instance, this would be used if the filter function just looked for a specific search term, and the entry with the string has changed.
#invalidate_sort ⇒ nil
Updates the sorting for all children.
Call this when the result of the sort function on box is changed due to an external factor.
#max_children_per_line ⇒ Integer
The maximum amount of children to request space for consecutively in the given orientation.
#max_children_per_line=(max_children_per_line) ⇒ Integer
The maximum amount of children to request space for consecutively in the given orientation.
#min_children_per_line ⇒ Integer
The minimum number of children to allocate consecutively in the given orientation.
Setting the minimum children per line ensures that a reasonably small height will be requested for the overall minimum width of the box.
#min_children_per_line=(min_children_per_line) ⇒ Integer
The minimum number of children to allocate consecutively in the given orientation.
Setting the minimum children per line ensures that a reasonably small height will be requested for the overall minimum width of the box.
#prepend(child) ⇒ nil
Adds child to the start of self.
If a sort function is set, the widget will actually be inserted at the calculated position.
See also: [methodGtk.FlowBox.insert].
#remove(widget) ⇒ nil
Removes a child from box.
#remove_all ⇒ nil
Removes all children from box.
This function does nothing if box is backed by a model.
#row_spacing ⇒ Integer
The amount of vertical space between two children.
#row_spacing=(row_spacing) ⇒ Integer
The amount of vertical space between two children.
#select_all ⇒ nil
Select all children of box, if the selection mode allows it.
#select_child(child) ⇒ nil
Selects a single child of box, if the selection mode allows it.
#selected_children ⇒ GLib::List<Gtk::FlowBoxChild>
Creates a list of all selected children.
#selected_foreach(func, data) ⇒ nil
Calls a function for each selected child.
Note that the selection cannot be modified from within this function.
#selection_mode ⇒ Gtk::SelectionMode
The selection mode used by the flow box.
#selection_mode=(selection_mode) ⇒ Gtk::SelectionMode
The selection mode used by the flow box.
#set_filter_func(filter_func, user_data, destroy) ⇒ nil
By setting a filter function on the box one can decide dynamically which of the children to show.
For instance, to implement a search function that only shows the children matching the search terms.
The filter_func will be called for each child after the call, and it will continue to be called each time a child changes (via [methodGtk.FlowBoxChild.changed]) or when [methodGtk.FlowBox.invalidate_filter] is called.
Note that using a filter function is incompatible with using a model (see [methodGtk.FlowBox.bind_model]).
#set_sort_func(sort_func, user_data, destroy) ⇒ nil
By setting a sort function on the box, one can dynamically reorder the children of the box, based on the contents of the children.
The sort_func will be called for each child after the call, and will continue to be called each time a child changes (via [methodGtk.FlowBoxChild.changed]) and when [methodGtk.FlowBox.invalidate_sort] is called.
Note that using a sort function is incompatible with using a model (see [methodGtk.FlowBox.bind_model]).
#unselect_all ⇒ nil
Unselect all children of box, if the selection mode allows it.
#unselect_child(child) ⇒ nil
Unselects a single child of box, if the selection mode allows it.
#vadjustment=(adjustment) ⇒ nil
Hooks up an adjustment to focus handling in box.
The adjustment is also used for autoscrolling during rubberband selection. See [methodGtk.ScrolledWindow.get_vadjustment] for a typical way of obtaining the adjustment, and [methodGtk.FlowBox.set_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 box.