class Gtk::ListBox
Overview
Gtk::ListBox
is a vertical list.
A Gtk::ListBox
only contains Gtk::ListBoxRow
children. These rows can
by dynamically sorted and filtered, and headers can be added dynamically
depending on the row content. It also allows keyboard and mouse navigation
and selection like a typical list.
Using Gtk::ListBox
is often an alternative to Gtk::TreeView
, especially
when the list contents has a more complicated layout than what is allowed
by a Gtk::CellRenderer
, or when the contents is interactive (i.e. has a
button in it).
Although a Gtk::ListBox
must have only Gtk::ListBoxRow
children, you can
add any kind of widget to it via Gtk::ListBox#prepend
,
Gtk::ListBox#append
and Gtk::ListBox#insert
and a
Gtk::ListBoxRow
widget will automatically be inserted between the list
and the widget.
Gtk::ListBoxRows
can be marked as activatable or selectable. If a row is
activatable, [signal@Gtk.ListBox::row-activated] will be emitted for it when
the user tries to activate it. If it is selectable, the row will be marked
as selected when the user tries to select it.
Gtk::ListBox as Gtk::Buildable
The Gtk::ListBox
implementation of the Gtk::Buildable
interface supports
setting a child as the placeholder by specifying “placeholder” as the “type”
attribute of a Gtk::ListBox#placeholder=
for info.
CSS nodes
|[ list[.separators][.rich-list][.navigation-sidebar] ╰── row[.activatable] ]|
Gtk::ListBox
uses a single CSS node named list. It may carry the .separators
style class, when the [property@Gtk.ListBox:show-separators] property is set.
Each Gtk::ListBoxRow
uses a single CSS node named row. The row nodes get the
.activatable style class added when appropriate.
The main list node may also carry style classes to select the style of list presentation: .rich-list, .navigation-sidebar or .data-table.
Accessibility
Gtk::ListBox
uses the %GTK_ACCESSIBLE_ROLE_LIST role and Gtk::ListBoxRow
uses
the %GTK_ACCESSIBLE_ROLE_LIST_ITEM role.
Included Modules
Defined in:
lib/gi-crystal/src/auto/gtk-4.0/list_box.crConstructors
-
.new : self
Creates a new
Gtk::ListBox
container. - .new(*, accept_unpaired_release : Bool? = nil, accessible_role : Gtk::AccessibleRole? = nil, activate_on_single_click : Bool? = nil, can_focus : Bool? = nil, can_target : Bool? = nil, css_classes : Enumerable(String)? = nil, css_name : String? = nil, cursor : Gdk::Cursor? = nil, focus_on_click : Bool? = nil, focusable : Bool? = nil, halign : Gtk::Align? = nil, has_default : Bool? = nil, has_focus : Bool? = nil, has_tooltip : Bool? = nil, height_request : Int32? = nil, hexpand : Bool? = nil, hexpand_set : Bool? = nil, layout_manager : Gtk::LayoutManager? = nil, margin_bottom : Int32? = nil, margin_end : Int32? = nil, margin_start : Int32? = nil, margin_top : Int32? = nil, name : String? = nil, opacity : Float64? = nil, overflow : Gtk::Overflow? = nil, parent : Gtk::Widget? = nil, receives_default : Bool? = nil, root : Gtk::Root? = nil, scale_factor : Int32? = nil, selection_mode : Gtk::SelectionMode? = nil, sensitive : Bool? = nil, show_separators : Bool? = nil, tooltip_markup : String? = nil, tooltip_text : String? = nil, valign : Gtk::Align? = nil, vexpand : Bool? = nil, vexpand_set : Bool? = nil, visible : Bool? = nil, width_request : Int32? = nil)
Class Method Summary
-
.g_type : UInt64
Returns the type id (GType) registered in GLib type system.
Instance Method Summary
- #accept_unpaired_release=(value : Bool) : Bool
- #accept_unpaired_release? : Bool
- #activate_cursor_row_signal
-
#activate_on_single_click : Bool
Returns whether rows activate on single clicks.
-
#activate_on_single_click=(single : Bool) : Nil
If @single is
true
, rows will be activated when you click on them, otherwise you need to double-click. - #activate_on_single_click? : Bool
-
#adjustment : Gtk::Adjustment?
Gets the adjustment (if any) that the widget uses to for vertical scrolling.
-
#adjustment=(adjustment : Gtk::Adjustment?) : Nil
Sets the adjustment (if any) that the widget uses to for vertical scrolling.
-
#append(child : Gtk::Widget) : Nil
Append a widget to the list.
-
#bind_model(model : Gio::ListModel?, create_widget_func : Gtk::ListBoxCreateWidgetFunc?) : Nil
Binds @model to @box.
-
#drag_highlight_row(row : Gtk::ListBoxRow) : Nil
Add a drag highlight to a row.
-
#drag_unhighlight_row : Nil
If a row has previously been highlighted via gtk_list_box_drag_highlight_row(), it will have the highlight removed.
-
#filter_func=(filter_func : Gtk::ListBoxFilterFunc?) : Nil
By setting a filter function on the @box one can decide dynamically which of the rows to show.
-
#header_func=(update_header : Gtk::ListBoxUpdateHeaderFunc?) : Nil
Sets a header function.
-
#insert(child : Gtk::Widget, position : Int32) : Nil
Insert the @child into the @box at @position.
-
#invalidate_filter : Nil
Update the filtering for all rows.
-
#invalidate_headers : Nil
Update the separators for all rows.
-
#invalidate_sort : Nil
Update the sorting for all rows.
- #move_cursor_signal
-
#placeholder=(placeholder : Gtk::Widget?) : Nil
Sets the placeholder widget that is shown in the list when it doesn't display any visible children.
-
#prepend(child : Gtk::Widget) : Nil
Prepend a widget to the list.
-
#remove(child : Gtk::Widget) : Nil
Removes a child from @box.
- #row_activated_signal
-
#row_at_index(index_ : Int32) : Gtk::ListBoxRow?
Gets the n-th child in the list (not counting headers).
-
#row_at_y(y : Int32) : Gtk::ListBoxRow?
Gets the row at the @y position.
- #row_selected_signal
-
#select_all : Nil
Select all children of @box, if the selection mode allows it.
- #select_all_signal
-
#select_row(row : Gtk::ListBoxRow?) : Nil
Make @row the currently selected row.
-
#selected_foreach(func : Gtk::ListBoxForeachFunc, data : Pointer(Void)?) : Nil
Calls a function for each selected child.
-
#selected_row : Gtk::ListBoxRow?
Gets the selected row, or
nil
if no rows are selected. -
#selected_rows : GLib::List
Creates a list of all selected children.
- #selected_rows_changed_signal
-
#selection_mode : Gtk::SelectionMode
Gets the selection mode of the listbox.
-
#selection_mode=(mode : Gtk::SelectionMode) : Nil
Sets how selection works in the listbox.
-
#show_separators : Bool
Returns whether the list box should show separators between rows.
-
#show_separators=(show_separators : Bool) : Nil
Sets whether the list box should show separators between rows.
- #show_separators? : Bool
-
#sort_func=(sort_func : Gtk::ListBoxSortFunc?) : Nil
Sets a sort function.
- #toggle_cursor_row_signal
-
#unselect_all : Nil
Unselect all children of @box, if the selection mode allows it.
- #unselect_all_signal
-
#unselect_row(row : Gtk::ListBoxRow) : Nil
Unselects a single row of @box, if the selection mode allows it.
Instance methods inherited from module Gtk::ConstraintTarget
to_unsafe
to_unsafe
Class methods inherited from module Gtk::ConstraintTarget
g_type : UInt64
g_type
Instance methods inherited from module Gtk::Buildable
buildable_id : String?
buildable_id,
to_unsafe
to_unsafe
Class methods inherited from module Gtk::Buildable
g_type : UInt64
g_type
Instance methods inherited from module Gtk::Accessible
accessible_role : Gtk::AccessibleRole
accessible_role,
accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole
accessible_role=,
reset_property(property : Gtk::AccessibleProperty) : Nil
reset_property,
reset_relation(relation : Gtk::AccessibleRelation) : Nil
reset_relation,
reset_state(state : Gtk::AccessibleState) : Nil
reset_state,
to_unsafe
to_unsafe,
update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil
update_property,
update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil
update_relation,
update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil
update_state
Class methods inherited from module Gtk::Accessible
g_type : UInt64
g_type
Instance methods inherited from class Gtk::Widget
action_set_enabled(action_name : String, enabled : Bool) : Nil
action_set_enabled,
activate : Bool
activate,
activate_action(name : String, args : _?) : Bool
activate_action,
activate_default : Nil
activate_default,
add_controller(controller : Gtk::EventController) : Nil
add_controller,
add_css_class(css_class : String) : Nil
add_css_class,
add_mnemonic_label(label : Gtk::Widget) : Nil
add_mnemonic_label,
add_tick_callback(callback : Gtk::TickCallback) : UInt32
add_tick_callback,
allocate(width : Int32, height : Int32, baseline : Int32, transform : Gsk::Transform?) : Nil
allocate,
allocated_baseline : Int32
allocated_baseline,
allocated_height : Int32
allocated_height,
allocated_width : Int32
allocated_width,
allocation : Gdk::Rectangle
allocation,
ancestor(widget_type : UInt64) : Gtk::Widget?
ancestor,
can_focus : Bool
can_focus,
can_focus=(can_focus : Bool) : Nil
can_focus=,
can_focus? : Bool
can_focus?,
can_target : Bool
can_target,
can_target=(can_target : Bool) : Nil
can_target=,
can_target? : Bool
can_target?,
child_focus(direction : Gtk::DirectionType) : Bool
child_focus,
child_visible : Bool
child_visible,
child_visible=(child_visible : Bool) : Nil
child_visible=,
clipboard : Gdk::Clipboard
clipboard,
compute_bounds(target : Gtk::Widget) : Graphene::Rect
compute_bounds,
compute_expand(orientation : Gtk::Orientation) : Bool
compute_expand,
compute_point(target : Gtk::Widget, point : Graphene::Point) : Graphene::Point
compute_point,
compute_transform(target : Gtk::Widget) : Graphene::Matrix
compute_transform,
contains(x : Float64, y : Float64) : Bool
contains,
create_pango_context : Pango::Context
create_pango_context,
create_pango_layout(text : String?) : Pango::Layout
create_pango_layout,
css_classes : Enumerable(String)
css_classes,
css_classes=(classes : Enumerable(String)) : Nil
css_classes=,
css_name : String
css_name,
css_name=(value : String) : String
css_name=,
cursor : Gdk::Cursor?
cursor,
cursor=(cursor : Gdk::Cursor?) : Nil
cursor=,
cursor_from_name=(name : String?) : Nil
cursor_from_name=,
destroy_signal
destroy_signal,
direction : Gtk::TextDirection
direction,
direction=(dir : Gtk::TextDirection) : Nil
direction=,
direction_changed_signal
direction_changed_signal,
display : Gdk::Display
display,
dispose_template(widget_type : UInt64) : Nil
dispose_template,
drag_check_threshold(start_x : Int32, start_y : Int32, current_x : Int32, current_y : Int32) : Bool
drag_check_threshold,
error_bell : Nil
error_bell,
first_child : Gtk::Widget?
first_child,
focus_child : Gtk::Widget?
focus_child,
focus_child=(child : Gtk::Widget?) : Nil
focus_child=,
focus_on_click : Bool
focus_on_click,
focus_on_click=(focus_on_click : Bool) : Nil
focus_on_click=,
focus_on_click? : Bool
focus_on_click?,
focusable : Bool
focusable,
focusable=(focusable : Bool) : Nil
focusable=,
focusable? : Bool
focusable?,
font_map : Pango::FontMap?
font_map,
font_map=(font_map : Pango::FontMap?) : Nil
font_map=,
font_options : Cairo::FontOptions?
font_options,
font_options=(options : Cairo::FontOptions?) : Nil
font_options=,
frame_clock : Gdk::FrameClock?
frame_clock,
grab_focus : Bool
grab_focus,
halign : Gtk::Align
halign,
halign=(align : Gtk::Align) : Nil
halign=,
has_css_class(css_class : String) : Bool
has_css_class,
has_default : Bool
has_default,
has_default? : Bool
has_default?,
has_focus : Bool
has_focus,
has_focus? : Bool
has_focus?,
has_tooltip : Bool
has_tooltip,
has_tooltip=(has_tooltip : Bool) : Nil
has_tooltip=,
has_tooltip? : Bool
has_tooltip?,
has_visible_focus : Bool
has_visible_focus,
height : Int32
height,
height_request : Int32
height_request,
height_request=(value : Int32) : Int32
height_request=,
hexpand : Bool
hexpand,
hexpand=(expand : Bool) : Nil
hexpand=,
hexpand? : Bool
hexpand?,
hexpand_set : Bool
hexpand_set,
hexpand_set=(set : Bool) : Nil
hexpand_set=,
hexpand_set? : Bool
hexpand_set?,
hide : Nil
hide,
hide_signal
hide_signal,
in_destruction : Bool
in_destruction,
init_template : Nil
init_template,
insert_action_group(name : String, group : Gio::ActionGroup?) : Nil
insert_action_group,
insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget?) : Nil
insert_after,
insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget?) : Nil
insert_before,
is_ancestor(ancestor : Gtk::Widget) : Bool
is_ancestor,
is_drawable : Bool
is_drawable,
is_focus : Bool
is_focus,
is_sensitive : Bool
is_sensitive,
is_visible : Bool
is_visible,
keynav_failed(direction : Gtk::DirectionType) : Bool
keynav_failed,
keynav_failed_signal
keynav_failed_signal,
last_child : Gtk::Widget?
last_child,
layout_manager : Gtk::LayoutManager?
layout_manager,
layout_manager=(layout_manager : Gtk::LayoutManager?) : Nil
layout_manager=,
list_mnemonic_labels : GLib::List
list_mnemonic_labels,
map : Nil
map,
map_signal
map_signal,
mapped : Bool
mapped,
margin_bottom : Int32
margin_bottom,
margin_bottom=(margin : Int32) : Nil
margin_bottom=,
margin_end : Int32
margin_end,
margin_end=(margin : Int32) : Nil
margin_end=,
margin_start : Int32
margin_start,
margin_start=(margin : Int32) : Nil
margin_start=,
margin_top : Int32
margin_top,
margin_top=(margin : Int32) : Nil
margin_top=,
measure(orientation : Gtk::Orientation, for_size : Int32) : Nil
measure,
mnemonic_activate(group_cycling : Bool) : Bool
mnemonic_activate,
mnemonic_activate_signal
mnemonic_activate_signal,
move_focus_signal
move_focus_signal,
name : String
name,
name=(name : String) : Nil
name=,
native : Gtk::Native?
native,
next_sibling : Gtk::Widget?
next_sibling,
observe_children : Gio::ListModel
observe_children,
observe_controllers : Gio::ListModel
observe_controllers,
opacity : Float64
opacity,
opacity=(opacity : Float64) : Nil
opacity=,
overflow : Gtk::Overflow
overflow,
overflow=(overflow : Gtk::Overflow) : Nil
overflow=,
pango_context : Pango::Context
pango_context,
parent : Gtk::Widget?
parent,
parent=(parent : Gtk::Widget) : Nil
parent=,
pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget?
pick,
preferred_size : Gtk::Requisition
preferred_size,
prev_sibling : Gtk::Widget?
prev_sibling,
primary_clipboard : Gdk::Clipboard
primary_clipboard,
query_tooltip_signal
query_tooltip_signal,
queue_allocate : Nil
queue_allocate,
queue_draw : Nil
queue_draw,
queue_resize : Nil
queue_resize,
realize : Nil
realize,
realize_signal
realize_signal,
realized : Bool
realized,
receives_default : Bool
receives_default,
receives_default=(receives_default : Bool) : Nil
receives_default=,
receives_default? : Bool
receives_default?,
remove_controller(controller : Gtk::EventController) : Nil
remove_controller,
remove_css_class(css_class : String) : Nil
remove_css_class,
remove_mnemonic_label(label : Gtk::Widget) : Nil
remove_mnemonic_label,
remove_tick_callback(id : UInt32) : Nil
remove_tick_callback,
request_mode : Gtk::SizeRequestMode
request_mode,
root : Gtk::Root?
root,
scale_factor : Int32
scale_factor,
sensitive : Bool
sensitive,
sensitive=(sensitive : Bool) : Nil
sensitive=,
sensitive? : Bool
sensitive?,
set_size_request(width : Int32, height : Int32) : Nil
set_size_request,
set_state_flags(flags : Gtk::StateFlags, clear : Bool) : Nil
set_state_flags,
settings : Gtk::Settings
settings,
should_layout : Bool
should_layout,
show : Nil
show,
show_signal
show_signal,
size(orientation : Gtk::Orientation) : Int32
size,
size_allocate(allocation : Gdk::Rectangle, baseline : Int32) : Nil
size_allocate,
size_request : Nil
size_request,
snapshot_child(child : Gtk::Widget, snapshot : Gtk::Snapshot) : Nil
snapshot_child,
state_flags : Gtk::StateFlags
state_flags,
state_flags_changed_signal
state_flags_changed_signal,
style_context : Gtk::StyleContext
style_context,
tooltip_markup : String?
tooltip_markup,
tooltip_markup=(value : String) : Stringtooltip_markup=(markup : String?) : Nil tooltip_markup=, tooltip_text : String? tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(text : String?) : Nil tooltip_text=, translate_coordinates(dest_widget : Gtk::Widget, src_x : Float64, src_y : Float64) : Bool translate_coordinates, trigger_tooltip_query : Nil trigger_tooltip_query, unmap : Nil unmap, unmap_signal unmap_signal, unparent : Nil unparent, unrealize : Nil unrealize, unrealize_signal unrealize_signal, unset_state_flags(flags : Gtk::StateFlags) : Nil unset_state_flags, valign : Gtk::Align valign, valign=(align : Gtk::Align) : Nil valign=, vexpand : Bool vexpand, vexpand=(expand : Bool) : Nil vexpand=, vexpand? : Bool vexpand?, vexpand_set : Bool vexpand_set, vexpand_set=(set : Bool) : Nil vexpand_set=, vexpand_set? : Bool vexpand_set?, visible : Bool visible, visible=(visible : Bool) : Nil visible=, visible? : Bool visible?, width : Int32 width, width_request : Int32 width_request, width_request=(value : Int32) : Int32 width_request=
Constructor methods inherited from class Gtk::Widget
newnew(*, accessible_role : Gtk::AccessibleRole? = nil, can_focus : Bool? = nil, can_target : Bool? = nil, css_classes : Enumerable(String)? = nil, css_name : String? = nil, cursor : Gdk::Cursor? = nil, focus_on_click : Bool? = nil, focusable : Bool? = nil, halign : Gtk::Align? = nil, has_default : Bool? = nil, has_focus : Bool? = nil, has_tooltip : Bool? = nil, height_request : Int32? = nil, hexpand : Bool? = nil, hexpand_set : Bool? = nil, layout_manager : Gtk::LayoutManager? = nil, margin_bottom : Int32? = nil, margin_end : Int32? = nil, margin_start : Int32? = nil, margin_top : Int32? = nil, name : String? = nil, opacity : Float64? = nil, overflow : Gtk::Overflow? = nil, parent : Gtk::Widget? = nil, receives_default : Bool? = nil, root : Gtk::Root? = nil, scale_factor : Int32? = nil, sensitive : Bool? = nil, tooltip_markup : String? = nil, tooltip_text : String? = nil, valign : Gtk::Align? = nil, vexpand : Bool? = nil, vexpand_set : Bool? = nil, visible : Bool? = nil, width_request : Int32? = nil) new
Class methods inherited from class Gtk::Widget
default_direction : Gtk::TextDirection
default_direction,
default_direction=(dir : Gtk::TextDirection) : Nil
default_direction=,
g_type : UInt64
g_type
Instance methods inherited from module Gtk::ConstraintTarget
to_unsafe
to_unsafe
Class methods inherited from module Gtk::ConstraintTarget
g_type : UInt64
g_type
Instance methods inherited from module Gtk::Buildable
buildable_id : String?
buildable_id,
to_unsafe
to_unsafe
Class methods inherited from module Gtk::Buildable
g_type : UInt64
g_type
Instance methods inherited from module Gtk::Accessible
accessible_role : Gtk::AccessibleRole
accessible_role,
accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole
accessible_role=,
reset_property(property : Gtk::AccessibleProperty) : Nil
reset_property,
reset_relation(relation : Gtk::AccessibleRelation) : Nil
reset_relation,
reset_state(state : Gtk::AccessibleState) : Nil
reset_state,
to_unsafe
to_unsafe,
update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil
update_property,
update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil
update_relation,
update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil
update_state
Class methods inherited from module Gtk::Accessible
g_type : UInt64
g_type
Constructor methods inherited from class GObject::InitiallyUnowned
new
new
Class methods inherited from class GObject::InitiallyUnowned
g_type : UInt64
g_type
Instance methods inherited from class GObject::Object
bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding
bind_property,
bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding
bind_property_full,
data(key : String) : Pointer(Void)?
data,
finalize
finalize,
freeze_notify : Nil
freeze_notify,
getv(names : Enumerable(String), values : Enumerable(_)) : Nil
getv,
notify(property_name : String) : Nil
notify,
notify_by_pspec(pspec : GObject::ParamSpec) : Nil
notify_by_pspec,
notify_signal
notify_signal,
property(property_name : String, value : _) : Nil
property,
qdata(quark : UInt32) : Pointer(Void)?
qdata,
ref_count : UInt32
ref_count,
run_dispose : Nil
run_dispose,
set_data(key : String, data : Pointer(Void)?) : Nil
set_data,
set_property(property_name : String, value : _) : Nil
set_property,
steal_data(key : String) : Pointer(Void)?
steal_data,
steal_qdata(quark : UInt32) : Pointer(Void)?
steal_qdata,
thaw_notify : Nil
thaw_notify,
to_unsafe : Pointer(Void)
to_unsafe,
watch_closure(closure : GObject::Closure) : Nil
watch_closure
Constructor methods inherited from class GObject::Object
cast(obj : GObject::Object) : self
cast,
cast?(obj : GObject::Object) : self?
cast?,
new(pointer : Pointer(Void), transfer : GICrystal::Transfer)new new, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv
Class methods inherited from class GObject::Object
compat_control(what : UInt64, data : Pointer(Void)?) : UInt64
compat_control,
g_type : UInt64
g_type,
interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec
interface_find_property,
interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec)
interface_list_properties
Constructor Detail
Class Method Detail
Instance Method Detail
If @single is true
, rows will be activated when you click on them,
otherwise you need to double-click.
Gets the adjustment (if any) that the widget uses to for vertical scrolling.
Sets the adjustment (if any) that the widget uses to for vertical scrolling.
For instance, this is used to get the page size for PageUp/Down key handling.
In the normal case when the @box is packed inside
a Gtk::ScrolledWindow
the adjustment from that will
be picked up automatically, so there is no need
to manually do that.
Append a widget to the list.
If a sort function is set, the widget will actually be inserted at the calculated position.
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
Gtk::ListBox#insert
) while @box is bound to a model.
Note that using a model is incompatible with the filtering and sorting
functionality in Gtk::ListBox
. When using a model, filtering and sorting
should be implemented by the model.
Add a drag highlight to a row.
This is a helper function for implementing DnD onto a Gtk::ListBox
.
The passed in @row will be highlighted by setting the
%GTK_STATE_FLAG_DROP_ACTIVE state and any previously highlighted
row will be unhighlighted.
The row will also be unhighlighted when the widget gets a drag leave event.
If a row has previously been highlighted via gtk_list_box_drag_highlight_row(), it will have the highlight removed.
By setting a filter function on the @box one can decide dynamically which of the rows to show.
For instance, to implement a search function on a list that filters the original list to only show the matching rows.
The @filter_func will be called for each row after the call, and
it will continue to be called each time a row changes (via
Gtk::ListBoxRow#changed
) or when Gtk::ListBox#invalidate_filter
is called.
Note that using a filter function is incompatible with using a model
(see Gtk::ListBox#bind_model
).
Sets a header function.
By setting a header function on the @box one can dynamically add headers in front of rows, depending on the contents of the row and its position in the list.
For instance, one could use it to add headers in front of the first item of a new kind, in a list sorted by the kind.
The @update_header can look at the current header widget using
Gtk::ListBoxRow#header
and either update the state of the widget
as needed, or set a new one using Gtk::ListBoxRow#header=
. If no
header is needed, set the header to nil
.
Note that you may get many calls @update_header to this for a particular row when e.g. changing things that don’t affect the header. In this case it is important for performance to not blindly replace an existing header with an identical one.
The @update_header function will be called for each row after the call,
and it will continue to be called each time a row changes (via
Gtk::ListBoxRow#changed
) and when the row before changes (either
by Gtk::ListBoxRow#changed
on the previous row, or when the previous
row becomes a different row). It is also called for all rows when
Gtk::ListBox#invalidate_headers
is called.
Insert the @child into the @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 items in the @box, then the @child will be appended to the end.
Update the filtering for all rows.
Call this when 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 string and the entry with the search string has changed.
Update the separators for all rows.
Call this when result of the header function on the @box is changed due to an external factor.
Update the sorting for all rows.
Call this when result of the sort function on the @box is changed due to an external factor.
Sets the placeholder widget that is shown in the list when it doesn't display any visible children.
Prepend a widget to the list.
If a sort function is set, the widget will actually be inserted at the calculated position.
Gets the n-th child in the list (not counting headers).
If @index_ is negative or larger than the number of items in the
list, nil
is returned.
Calls a function for each selected child.
Note that the selection cannot be modified from within this function.
Gets the selected row, or nil
if no rows are selected.
Note that the box may allow multiple selection, in which
case you should use Gtk::ListBox#selected_foreach
to
find all selected rows.
Sets whether the list box should show separators between rows.
Sets a sort function.
By setting a sort function on the @box one can dynamically reorder the rows of the list, based on the contents of the rows.
The @sort_func will be called for each row after the call, and will
continue to be called each time a row changes (via
Gtk::ListBoxRow#changed
) and when Gtk::ListBox#invalidate_sort
is called.
Note that using a sort function is incompatible with using a model
(see Gtk::ListBox#bind_model
).
Unselects a single row of @box, if the selection mode allows it.