### ----------------------------------------------------
### -- Gnome::Gtk3
### -- Licenses: Artistic-2.0
### -- Authors: Marcel Timmerman
### -- File: lib/Gnome/Gtk3/ListBox.rakumod
### ----------------------------------------------------
### -- Chunk 1 of 3
#TL:1:Gnome::Gtk3::ListBox:

use v6;
#-------------------------------------------------------------------------------
=begin pod

=head1 Gnome::Gtk3::ListBox

A list container

![](images/list-box.png)


=head1 Description

A B<Gnome::Gtk3::ListBox> is a vertical container that contains B<Gnome::Gtk3::ListBoxRow> children. These rows can be 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 B<Gnome::Gtk3::ListBox> is often an alternative to B<Gnome::Gtk3::TreeView>, especially when the list contents has a more complicated layout than what is allowed by a B<Gnome::Gtk3::CellRenderer>, or when the contents is interactive (i.e. has a button in it).

Although a B<Gnome::Gtk3::ListBox> must have only B<Gnome::Gtk3::ListBoxRow> children you can add any kind of widget to it via C<gtk_container_add()>, and a B<Gnome::Gtk3::ListBoxRow> widget will automatically be inserted between the list and the widget.

B<Gnome::Gtk3::ListBoxRows> can be marked as activatable or selectable. If a row is activatable, sig C<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.


=head2 B<Gnome::Gtk3::ListBox> as B<Gnome::Gtk3::Buildable>

The B<Gnome::Gtk3::ListBox> implementation of the B<Gnome::Gtk3::Buildable> interface supports setting a child as the placeholder by specifying “placeholder” as the “type” attribute of a <child> element. See C<set-placeholder()> for info.


=head2 Css Nodes

B<Gnome::Gtk3::ListBox> uses a single CSS node with name list. B<Gnome::Gtk3::ListBoxRow> uses a single CSS node with name row. The row nodes get the .activatable style class added when appropriate.


=head2 See Also

B<Gnome::Gtk3::ScrolledWindow>


=head1 Synopsis
=head2 Declaration

  unit class Gnome::Gtk3::ListBox;
  also is Gnome::Gtk3::Container;
  also does Gnome::Gtk3::Buildable;


=comment head2 Uml Diagram

=comment ![](plantuml/ListBox.svg)


=head2 Inheriting this class

Inheriting is done in a special way in that it needs a call from new() to get the native object created by the class you are inheriting from.

  use Gnome::Gtk3::ListBox:api<1>;

  unit class MyGuiClass;
  also is Gnome::Gtk3::ListBox;

  submethod new ( |c ) {
    # let the Gnome::Gtk3::ListBox class process the options
    self.bless( :GtkListBox, |c);
  }

  submethod BUILD ( ... ) {
    ...
  }



=head2 Example

Create a ListBox with one row. This row is a grid holding a CheckBox and Label.

  my Gnome::Gtk3::ListBox $lb .= new;

  # The widgets
  my Gnome::Gtk3::CheckButton $check .= new(:label('bold'));
  my Gnome::Gtk3::Label $label .= new(:text('Turn on bold font'));

  # Add the widgets to the Grid
  my Gnome::Gtk3::Grid $grid .= new;
  $grid.attach( $check, 0, 0, 1, 1);
  $grid.attach( $label, 1, 0, 1, 1);

  # Add the Grid to the ListBox
  $lb.add($grid);

To check its values one can register signals on each important widget (e.g. C<$check> in this case) or read the listbox entries.

  my Int $index = 0;
  while my $nw = $lb.get-row-at-index($index) {
    my Gnome::Gtk3::ListBoxRow() $row = $nw;
    my Gnome::Gtk3::Grid $grid() = $row.get-child;
    my Gnome::Gtk3::CheckButton() $check = $grid.get-child-at( 0, 0);
    if $check.get-active {
      ...
    }
  }

Every check in this list looks the same, so it is useful to set a name on each of the check widgets. This name can then be retrieved within the handler or the code example above. If it is simple, like above, on can use the label text instead.

=end pod

#-------------------------------------------------------------------------------
use NativeCall;

use Gnome::N::X:api<1>;
use Gnome::N::N-GObject:api<1>;
use Gnome::N::NativeLib:api<1>;
use Gnome::N::GlibToRakuTypes:api<1>;

use Gnome::Glib::List:api<1>;

use Gnome::Gtk3::ListBoxRow:api<1>;
use Gnome::Gtk3::Container:api<1>;
use Gnome::Gtk3::Enums:api<1>;

#-------------------------------------------------------------------------------
# See /usr/include/gtk-3.0/gtk/gtklistbox.h
# https://developer.gnome.org/gtk3/stable/GtkListBox.html
unit class Gnome::Gtk3::ListBox:auth<github:MARTIMM>:api<1>;
also is Gnome::Gtk3::Container;

#-------------------------------------------------------------------------------
my Bool $signals-added = False;
#-------------------------------------------------------------------------------
=begin pod
=head1 Methods
=head2 new

Create a new plain object.

  multi method new ( )

Create an object using a native object from elsewhere. See also B<Gnome::GObject::Object>.

  multi method new ( N-GObject :$native-object! )

Create an object using a native object from a builder. See also B<Gnome::GObject::Object>.

  multi method new ( Str :$build-id! )
=end pod

#TM:0:new():inheriting
#TM:1:new():
#TM:4:new(:native-object):Gnome::N::TopLevelClassSupport
#TM:4:new(:build-id):Gnome::GObject::Object
submethod BUILD ( *%options ) {

  # add signal info in the form of group<signal-name>.
  # groups are e.g. signal, event, nativeobject etc
  $signals-added = self.add-signal-types( $?CLASS.^name,
    :w0<selected-rows-changed select-all unselect-all activate-cursor-row toggle-cursor-row activate>, :w1<row-selected row-activated>, :w2<move-cursor>,
  ) unless $signals-added;


  # prevent creating wrong native-objects
  if self.^name eq 'Gnome::Gtk3::ListBox' or %options<GtkListBox> {

    # check if native object is set by a parent class
    if self.is-valid { }

    # check if common options are handled by some parent
    elsif %options<native-object>:exists { }
    elsif %options<build-id>:exists { }

    # process all other options
    else {
      my N-GObject() $no;
      if ? %options<___x___> {
        #$no = %options<___x___>;
        #$no .= _get-native-object-no-reffing unless $no ~~ N-GObject;
        #$no = _gtk_list_box_new___x___($no);
      }

      #`{{ use this when the module is not made inheritable
      # check if there are unknown options
      elsif %options.elems {
        die X::Gnome.new(
          :message(
            'Unsupported, undefined, incomplete or wrongly typed options for ' ~
            self.^name ~ ': ' ~ %options.keys.join(', ')
          )
        );
      }
      }}

      #`{{ when there are no defaults use this
      # check if there are any options
      elsif %options.elems == 0 {
        die X::Gnome.new(:message('No options specified ' ~ self.^name));
      }
      }}

      ##`{{ when there are defaults use this instead
      # create default object
      else {
        $no = _gtk_list_box_new();
      }
      #}}

      self.set-native-object($no);
    }

    # only after creating the native-object, the gtype is known
    self._set-class-info('GtkListBox');
  }
}

#-------------------------------------------------------------------------------
method _fallback ( $native-sub is copy --> Callable ) {

  my Str $new-patt = $native-sub.subst( '_', '-', :g);

  my Callable $s;
  try { $s = &::("gtk_list_box_$native-sub"); };
  if ?$s {
    Gnome::N::deprecate(
      "gtk_list_box_$native-sub", $new-patt, '0.47.4', '0.50.0'
    );
  }

  else {
    try { $s = &::("gtk_$native-sub"); } unless ?$s;
    if ?$s {
      Gnome::N::deprecate(
        "gtk_$native-sub", $new-patt.subst('list-box-'),
        '0.47.4', '0.50.0'
      );
    }

    else {
      try { $s = &::($native-sub); } if !$s and $native-sub ~~ m/^ 'gtk_' /;
      if ?$s {
        Gnome::N::deprecate(
          $native-sub, $new-patt.subst('gtk-list-box-'),
          '0.47.4', '0.50.0'
        );
      }
    }
  }

  self._set-class-name-of-sub('GtkListBox');
  $s = callsame unless ?$s;

  $s;
}

#`{{
#-------------------------------------------------------------------------------
#TM:0:bind-model:
=begin pod
=head2 bind-model

Binds I<model> to I<box>.

If I<box> was already bound to a model, that previous binding is destroyed.

The contents of I<box> are cleared and then filled with widgets that represent items from I<model>. I<box> is updated whenever I<model> changes. If I<model> is C<undefined>, I<box> is left empty.

It is undefined to add or remove widgets directly (for example, with C<insert()> or C<gtk_container_add()>) while I<box> is bound to a model.

Note that using a model is incompatible with the filtering and sorting functionality in GtkListBox. When using a model, filtering and sorting should be implemented by the model.

  method bind-model ( N-GList $model, GtkListBoxCreateWidgetFunc $create_widget_func, Pointer $user_data, GDestroyNotify $user_data_free_func )

=item $model; the B<Gnome::Gio::ListModel> to be bound to I<box>
=item $create_widget_func; a function that creates widgets for items or C<undefined> in case you also passed C<undefined> as I<model>
=item $user_data; user data passed to I<create_widget_func>
=item $user_data_free_func; function for freeing I<user_data>
=end pod

method bind-model ( $model is copy, GtkListBoxCreateWidgetFunc $create_widget_func, Pointer $user_data, GDestroyNotify $user_data_free_func ) {
  $model .= _get-native-object-no-reffing unless $model ~~ N-GList;
  gtk_list_box_bind_model( self._get-native-object-no-reffing, $model, $create_widget_func, $user_data, $user_data_free_func);
}

sub gtk_list_box_bind_model (
  N-GObject $box, N-GList $model, GtkListBoxCreateWidgetFunc $create_widget_func, gpointer $user_data, GDestroyNotify $user_data_free_func
) is native(&gtk-lib)
  { * }
}}

#-------------------------------------------------------------------------------
#TM:0:drag-highlight-row:
=begin pod
=head2 drag-highlight-row

This is a helper function for implementing DnD onto a B<Gnome::Gtk3::ListBox>. The passed in I<row> will be highlighted via C<gtk_drag_highlight()>, and any previously highlighted row will be unhighlighted.

The row will also be unhighlighted when the widget gets a drag leave event.

  method drag-highlight-row ( N-GObject() $row )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=end pod

method drag-highlight-row ( N-GObject() $row ) {
  gtk_list_box_drag_highlight_row( self._get-native-object-no-reffing, $row);
}

sub gtk_list_box_drag_highlight_row (
  N-GObject $box, N-GObject $row
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:drag-unhighlight-row:
=begin pod
=head2 drag-unhighlight-row

If a row has previously been highlighted via C<drag_highlight_row()> it will have the highlight removed.

  method drag-unhighlight-row ( )

=end pod

method drag-unhighlight-row ( ) {
  gtk_list_box_drag_unhighlight_row(self._get-native-object-no-reffing);
}

sub gtk_list_box_drag_unhighlight_row (
  N-GObject $box
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-activate-on-single-click:
=begin pod
=head2 get-activate-on-single-click

Returns whether rows activate on single clicks.

Returns: C<True> if rows are activated on single click, C<False> otherwise

  method get-activate-on-single-click ( --> Bool )

=end pod

method get-activate-on-single-click ( --> Bool ) {
  gtk_list_box_get_activate_on_single_click( self._get-native-object-no-reffing).Bool
}

sub gtk_list_box_get_activate_on_single_click (
  N-GObject $box --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-adjustment:
=begin pod
=head2 get-adjustment

Gets the adjustment (if any) that the widget uses to for vertical scrolling.

Returns: the adjustment

  method get-adjustment ( --> N-GObject )

=end pod

method get-adjustment ( --> N-GObject ) {
  gtk_list_box_get_adjustment( self._get-native-object-no-reffing)
}

sub gtk_list_box_get_adjustment (
  N-GObject $box --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:1:get-row-at-index:
=begin pod
=head2 get-row-at-index

Gets the n-th child in the list (not counting headers). If I<_index> is negative or larger than the number of items in the list, C<undefined> is returned.

Returns: the child B<Gnome::Gtk3::Widget> or C<undefined>

  method get-row-at-index ( Int() $index --> N-GObject )

=item $index; the index of the row
=end pod

method get-row-at-index ( Int() $index --> N-GObject ) {
  gtk_list_box_get_row_at_index( self._get-native-object-no-reffing, $index)
}

sub gtk_list_box_get_row_at_index (
  N-GObject $box, gint $index --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-row-at-y:
=begin pod
=head2 get-row-at-y

Gets the row at the I<y> position.

Returns: the row or C<undefined> in case no row exists for the given y coordinate.

  method get-row-at-y ( Int() $y --> N-GObject )

=item $y; position
=end pod

method get-row-at-y ( Int() $y --> N-GObject ) {
  gtk_list_box_get_row_at_y( self._get-native-object-no-reffing, $y)
}

sub gtk_list_box_get_row_at_y (
  N-GObject $box, gint $y --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-selected-row:
=begin pod
=head2 get-selected-row

Gets the selected row.

Note that the box may allow multiple selection, in which case you should use C<selected_foreach()> to find all selected rows.

Returns: the selected row

  method get-selected-row ( --> N-GObject )

=end pod

method get-selected-row ( --> N-GObject ) {
  gtk_list_box_get_selected_row( self._get-native-object-no-reffing)
}

sub gtk_list_box_get_selected_row (
  N-GObject $box --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-selected-rows:
=begin pod
=head2 get-selected-rows

Creates a list of all selected children.

Returns: A B<Gnome::Gio::List> containing the B<Gnome::Gtk3::Widget> for each selected child. Free with C<clear-object()> when done.

  method get-selected-rows ( --> N-GList )

=end pod

method get-selected-rows ( --> N-GList ) {
  gtk_list_box_get_selected_rows( self._get-native-object-no-reffing)
}

sub gtk_list_box_get_selected_rows (
  N-GObject $box --> N-GList
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:get-selection-mode:
=begin pod
=head2 get-selection-mode

Gets the selection mode of the listbox.

Returns: a B<Gnome::Gtk3::SelectionMode>

  method get-selection-mode ( --> GtkSelectionMode )

=end pod

method get-selection-mode ( --> GtkSelectionMode ) {
  GtkSelectionMode(
    gtk_list_box_get_selection_mode( self._get-native-object-no-reffing)
  )
}

sub gtk_list_box_get_selection_mode (
  N-GObject $box --> GEnum
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:insert:
=begin pod
=head2 insert

Insert the I<child> into the I<box> at I<position>. If a sort function is set, the widget will actually be inserted at the calculated position and this function has the same effect of C<gtk_container_add()>.

If I<position> is -1, or larger than the total number of items in the I<box>, then the I<child> will be appended to the end.

  method insert ( N-GObject() $child, Int() $position )

=item $child; the B<Gnome::Gtk3::Widget> to add
=item $position; the position to insert I<child> in
=end pod

method insert ( N-GObject() $child, Int() $position ) {
  gtk_list_box_insert( self._get-native-object-no-reffing, $child, $position);
}

sub gtk_list_box_insert (
  N-GObject $box, N-GObject $child, gint $position
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:invalidate-filter:
=begin pod
=head2 invalidate-filter

Update the filtering for all rows. Call this when result of the filter function on the I<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.

  method invalidate-filter ( )

=end pod

method invalidate-filter ( ) {
  gtk_list_box_invalidate_filter(self._get-native-object-no-reffing);
}

sub gtk_list_box_invalidate_filter (
  N-GObject $box
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:invalidate-headers:
=begin pod
=head2 invalidate-headers

Update the separators for all rows. Call this when result of the header function on the I<box> is changed due to an external factor.

  method invalidate-headers ( )

=end pod

method invalidate-headers ( ) {
  gtk_list_box_invalidate_headers(self._get-native-object-no-reffing);
}

sub gtk_list_box_invalidate_headers (
  N-GObject $box
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:invalidate-sort:
=begin pod
=head2 invalidate-sort

Update the sorting for all rows. Call this when result of the sort function on the I<box> is changed due to an external factor.

  method invalidate-sort ( )

=end pod

method invalidate-sort ( ) {
  gtk_list_box_invalidate_sort(self._get-native-object-no-reffing);
}

sub gtk_list_box_invalidate_sort (
  N-GObject $box
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:prepend:
=begin pod
=head2 prepend

Prepend a widget to the list. If a sort function is set, the widget will actually be inserted at the calculated position and this function has the same effect of C<gtk_container_add()>.

  method prepend ( N-GObject() $child )

=item $child; the B<Gnome::Gtk3::Widget> to add
=end pod

method prepend ( N-GObject() $child ) {
  gtk_list_box_prepend( self._get-native-object-no-reffing, $child);
}

sub gtk_list_box_prepend (
  N-GObject $box, N-GObject $child
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-changed:
=begin pod
=head2 row-changed

Marks I<row> as changed, causing any state that depends on this to be updated. This affects sorting, filtering and headers.

Note that calls to this method must be in sync with the data used for the row functions. For instance, if the list is mirroring some external data set, and *two* rows changed in the external data set then when you call C<row_changed()> on the first row the sort function must only read the new data for the first of the two changed rows, otherwise the resorting of the rows will be wrong.

This generally means that if you don’t fully control the data model you have to duplicate the data that affects the listbox row functions into the row widgets themselves. Another alternative is to call C<invalidate_sort()> on any model change, but that is more expensive.

  method row-changed ( N-GObject() $row )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=end pod

method row-changed ( N-GObject() $row ) {
  gtk_list_box_row_changed( self._get-native-object-no-reffing, $row);
}

sub gtk_list_box_row_changed (
  N-GObject $row
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-get-activatable:
=begin pod
=head2 row-get-activatable

Gets the value of the I<activatable from Gnome::Gtk3::ListBoxRow> property for this row.

Returns: C<True> if the row is activatable

  method row-get-activatable ( N-GObject() $row --> Bool )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=end pod

method row-get-activatable ( N-GObject() $row --> Bool ) {
  gtk_list_box_row_get_activatable( self._get-native-object-no-reffing, $row).Bool
}

sub gtk_list_box_row_get_activatable (
  N-GObject $row --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-get-header:
=begin pod
=head2 row-get-header

Returns the current header of the I<row>. This can be used in a B<Gnome::Gtk3::ListBoxUpdateHeaderFunc> to see if there is a header set already, and if so to update the state of it.

Returns: the current header, or C<undefined> if none

  method row-get-header ( N-GObject() $row --> N-GObject )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=end pod

method row-get-header ( N-GObject() $row --> N-GObject ) {
  gtk_list_box_row_get_header( self._get-native-object-no-reffing, $row)
}

sub gtk_list_box_row_get_header (
  N-GObject $row --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-get-index:
=begin pod
=head2 row-get-index

Gets the current index of the I<row> in its B<Gnome::Gtk3::ListBox> container.

Returns: the index of the I<row>, or -1 if the I<row> is not in a listbox

  method row-get-index ( N-GObject() $row --> Int )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=end pod

method row-get-index ( N-GObject() $row --> Int ) {
  gtk_list_box_row_get_index( self._get-native-object-no-reffing, $row)
}

sub gtk_list_box_row_get_index (
  N-GObject $row --> gint
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-get-selectable:
=begin pod
=head2 row-get-selectable

Gets the value of the I<selectable from Gnome::Gtk3::ListBoxRow> property for this row.

Returns: C<True> if the row is selectable

  method row-get-selectable ( N-GObject() $row --> Bool )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=end pod

method row-get-selectable ( N-GObject() $row --> Bool ) {
  gtk_list_box_row_get_selectable( self._get-native-object-no-reffing, $row).Bool
}

sub gtk_list_box_row_get_selectable (
  N-GObject $row --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-is-selected:
=begin pod
=head2 row-is-selected

Returns whether the child is currently selected in its B<Gnome::Gtk3::ListBox> container.

Returns: C<True> if I<row> is selected

  method row-is-selected ( N-GObject() $row --> Bool )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=end pod

method row-is-selected ( N-GObject() $row --> Bool ) {
  gtk_list_box_row_is_selected( self._get-native-object-no-reffing, $row).Bool
}

sub gtk_list_box_row_is_selected (
  N-GObject $row --> gboolean
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-new:
=begin pod
=head2 row-new

Creates a new B<Gnome::Gtk3::ListBoxRow>, to be used as a child of a B<Gnome::Gtk3::ListBox>.

Returns: a new B<Gnome::Gtk3::ListBoxRow>

  method row-new ( --> N-GObject )

=end pod

method row-new ( --> N-GObject ) {
  gtk_list_box_row_new( self._get-native-object-no-reffing)
}

sub gtk_list_box_row_new (
   --> N-GObject
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-set-activatable:
=begin pod
=head2 row-set-activatable

Set the I<activatable from Gnome::Gtk3::ListBoxRow> property for this row.

  method row-set-activatable ( N-GObject() $row, Bool $activatable )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=item $activatable; C<True> to mark the row as activatable
=end pod

method row-set-activatable ( N-GObject() $row, Bool $activatable ) {
  gtk_list_box_row_set_activatable( self._get-native-object-no-reffing, $row, $activatable);
}

sub gtk_list_box_row_set_activatable (
  N-GObject $row, gboolean $activatable
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-set-header:
=begin pod
=head2 row-set-header

Sets the current header of the I<row>. This is only allowed to be called from a B<Gnome::Gtk3::ListBoxUpdateHeaderFunc>. It will replace any existing header in the row, and be shown in front of the row in the listbox.

  method row-set-header ( N-GObject() $row, N-GObject() $header )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=item $header; the header, or C<undefined>
=end pod

method row-set-header ( N-GObject() $row, N-GObject() $header ) {
  gtk_list_box_row_set_header( self._get-native-object-no-reffing, $row, $header);
}

sub gtk_list_box_row_set_header (
  N-GObject $row, N-GObject $header
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:row-set-selectable:
=begin pod
=head2 row-set-selectable

Set the I<selectable from Gnome::Gtk3::ListBoxRow> property for this row.

  method row-set-selectable ( N-GObject() $row, Bool $selectable )

=item $row; a B<Gnome::Gtk3::ListBoxRow>
=item $selectable; C<True> to mark the row as selectable
=end pod

method row-set-selectable ( N-GObject() $row, Bool $selectable ) {
  gtk_list_box_row_set_selectable( self._get-native-object-no-reffing, $row, $selectable);
}

sub gtk_list_box_row_set_selectable (
  N-GObject $row, gboolean $selectable
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:select-all:
=begin pod
=head2 select-all

Select all children of I<box>, if the selection mode allows it.

  method select-all ( )

=end pod

method select-all ( ) {
  gtk_list_box_select_all( self._get-native-object-no-reffing);
}

sub gtk_list_box_select_all (
  N-GObject $box
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:select-row:
=begin pod
=head2 select-row

Make I<row> the currently selected row.

  method select-row ( N-GObject() $row )

=item $row; The row to select or C<undefined>
=end pod

method select-row ( N-GObject() $row ) {
  gtk_list_box_select_row( self._get-native-object-no-reffing, $row);
}

sub gtk_list_box_select_row (
  N-GObject $box, N-GObject $row
) is native(&gtk-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:selected-foreach:
=begin pod
=head2 selected-foreach

Calls a function for each selected child.

Note that the selection cannot be modified from within this function.

  method selected-foreach ( GtkListBoxForeachFunc $func, Pointer $data )

=item $func; (scope call): the function to call for each selected child
=item $data; user data to pass to the function
=end pod

method selected-foreach ( GtkListBoxForeachFunc $func, Pointer $data ) {
  gtk_list_box_selected_foreach( self._get-native-object-no-reffing, $func, $data);
}

sub gtk_list_box_selected_foreach (
  N-GObject $box, GtkListBoxForeachFunc $func, gpointer $data
) is native(&gtk-lib)
  { * }
}}


#-------------------------------------------------------------------------------
#TM:1:selected-foreach:
=begin pod
=head2 selected-foreach

Calls a function for each selected child. Note that the selection cannot be modified from within this function.

  method selected-foreach (
    $callback-object, Str $callback_name, *%user-options
  )

=item $callback-object; Object wherein the callback method is declared
=item $callback-name; Name of the callback method
=item %user-options; named arguments which will be provided to the callback

The callback method signature is

  method f (
    N-GObject $listbox, N-GObject $row, *%user-options
  )


=head3 Example

In the example below, the callback C<cb> has the native objects provided as C<N-GObject> coerced into B<Gnome::Gtk3::ListBox> and B<Gnome::Gtk3::ListBoxRow> using the C<()>.

  class X {
    method cb (
      Gnome::Gtk3::ListBox() $lbx, Gnome::Gtk3::ListBoxRow() $lbxr, :$test ) {
      is $lbx.widget-get-name(), 'GtkListBox', 'listbox';
      is $lbxr.widget-get-name(), 'N-GObject', 'listboxrow';
      is $test, 'abc', 'user option';
    }
  }

  $lb.selected-foreach( X.new, 'cb', :test<abc>);

=end pod

method selected-foreach (
  Any:D $func-object, Str:D $func-name, *%user-options
) {
  if $func-object.^can($func-name) {
    gtk_list_box_selected_foreach(
      self._f('GtkListBox'),
      sub ( $n-lb, $n-lbr, $d ) {
        CATCH { default { .message.note; .backtrace.concise.note } }

# TODO; after deprecation, the call to user function must be like
# $func-object."$func-name"( $n-lb, $n-lbr, |%user-options)
#
my Method $sh = $func-object.^lookup($func-name);
my @ps = $sh.signature.params;
#note 'foreach handler: ', @ps>>.type;
my ( $arg1, $arg2);
if @ps[1].type.^name ~~ /^ 'Gnome::Gtk3::ListBox(' .*? ')' $/ {
  $arg1 = $n-lb;
}

elsif @ps[1].type.^name ~~ /^ 'Gnome::Gtk3::ListBox' $/ {
  $arg1 = Gnome::Gtk3::ListBox.new(:native-object($n-lb));
  Gnome::N::deprecate(
    'arg type Gnome::Gtk3::ListBox in callback handler',
    'Gnome::Gtk3::ListBox()',
    '0.48.6', '0.50.0'
  );
}

else {
  $arg1 = $n-lb;
}


if @ps[2].type.^name ~~ /^ 'Gnome::Gtk3::ListBoxRow(' .*? ')' $/ {
  $arg2 = $n-lbr;
}

elsif @ps[2].type.^name ~~ /^ 'Gnome::Gtk3::ListBoxRow' $/ {
  $arg2 = Gnome::Gtk3::ListBoxRow.new(:native-object($n-lbr));
  Gnome::N::deprecate(
    'arg type Gnome::Gtk3::ListBoxRow in callback handler',
    'Gnome::Gtk3::ListBoxRow()',
    '0.48.6', '0.50.0'
  );
}

else {
  $arg2 = $n-lbr;
}

        $func-object."$func-name"(
          # $n-lb, $n-lbr,
          $arg1, $arg2,
          |%user-options
        )
      },
      OpaquePointer
    );
  }

  else {
    note "Method $func-name not found in object $func-object.perl()"
      if $Gnome::N::x-debug;
  }
}

sub gtk_list_box_selected_foreach (
  N-GObject $box,
  Callable $callback (
    N-GObject $n-listbox, N-GObject $n-listboxrow, OpaquePointer $d
  ),
  OpaquePointer $user_data
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:set-activate-on-single-click:
=begin pod
=head2 set-activate-on-single-click

If I<single> is C<True>, rows will be activated when you click on them, otherwise you need to double-click.

  method set-activate-on-single-click ( Bool $single )

=item $single; a boolean
=end pod

method set-activate-on-single-click ( Bool $single ) {
  gtk_list_box_set_activate_on_single_click( self._get-native-object-no-reffing, $single);
}

sub gtk_list_box_set_activate_on_single_click (
  N-GObject $box, gboolean $single
) is native(&gtk-lib)
  { * }

#-------------------------------------------------------------------------------
#TM:0:set-adjustment:
=begin pod
=head2 set-adjustment

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 I<box> is packed inside a B<Gnome::Gtk3::ScrolledWindow> the adjustment from that will be picked up automatically, so there is no need to manually do that.

  method set-adjustment ( N-GObject() $adjustment )

=item $adjustment; the adjustment, or C<undefined>
=end pod

method set-adjustment ( N-GObject() $adjustment ) {
  gtk_list_box_set_adjustment( self._get-native-object-no-reffing, $adjustment);
}

sub gtk_list_box_set_adjustment (
  N-GObject $box, N-GObject $adjustment
) is native(&gtk-lib)
  { * }

#`{{
#-------------------------------------------------------------------------------
#TM:0:set-filter-func:
=begin pod
=head2 set-filter-func

By setting a filter function on the I<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 I<filter_func> will be called for each row after the call, and it will continue to be called each time a row changes (via C<row_changed()>) or