Class: Gtk::ListBox

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

Instance Method Summary collapse

Instance Method Details

#activate_on_single_clickTrueClass

Returns whether rows activate on single clicks.

Returns:

  • (TrueClass)

    true if rows are activated on single click, false otherwise

#activate_on_single_click=(activate_on_single_click) ⇒ TrueClass

Parameters:

  • activate_on_single_click (TrueClass)

Returns:

  • (TrueClass)

    activate-on-single-click

  • (TrueClass)

    activate-on-single-click

#activate_on_single_click?TrueClass

Returns activate-on-single-click.

Returns:

  • (TrueClass)

    activate-on-single-click

#adjustmentGtk::Adjustment

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

Returns:

#adjustment=(adjustment) ⇒ nil

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.

Parameters:

Returns:

  • (nil)

#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 gtk_list_box_insert() or gtk_container_add()) while 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.

Parameters:

  • model (Gio::ListModel)

    the GList::Model to be bound to box

  • create_widget_func (Gtk::ListBoxCreateWidgetFunc)

    a function that creates widgets for items or nil in case you also passed nil as model

  • user_data (GObject)

    user data passed to create_widget_func

  • user_data_free_func (GLib::DestroyNotify)

    function for freeing user_data

Returns:

  • (nil)

#drag_highlight_row(row) ⇒ nil

This is a helper function for implementing DnD onto a Gtk::ListBox. The passed in row will be highlighted via 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.

Parameters:

Returns:

  • (nil)

#drag_unhighlight_rownil

If a row has previously been highlighted via gtk_list_box_drag_highlight_row() it will have the highlight removed.

Returns:

  • (nil)

#get_row_at_index(index_) ⇒ Gtk::ListBoxRow

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.

Parameters:

  • index_ (Integer)

    the index of the row

Returns:

#get_row_at_y(y) ⇒ Gtk::ListBoxRow

Gets the row at the y position.

Parameters:

  • y (Integer)

    position

Returns:

  • (Gtk::ListBoxRow)

    the row or nil in case no row exists for the given y coordinate.

#insert(child, position) ⇒ nil

Insert the child into the box at 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 gtk_container_add().

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

Parameters:

  • child (Gtk::Widget)

    the Gtk::Widget to add

  • position (Integer)

    the position to insert child in

Returns:

  • (nil)

#invalidate_filternil

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.

Returns:

  • (nil)

#invalidate_headersnil

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

Returns:

  • (nil)

#invalidate_sortnil

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

Returns:

  • (nil)

#newGtk::Widget

Creates a new Gtk::ListBox container.

Returns:

#placeholder=(placeholder) ⇒ nil

Sets the placeholder widget that is shown in the list when it doesn’t display any visible children.

Parameters:

Returns:

  • (nil)

#prepend(child) ⇒ nil

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 gtk_container_add().

Parameters:

Returns:

  • (nil)

#select_allnil

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

Returns:

  • (nil)

#select_row(row) ⇒ nil

Make row the currently selected row.

Parameters:

Returns:

  • (nil)

#selected_foreach(func, data) ⇒ nil

Calls a function for each selected child.

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

Parameters:

  • func (Gtk::ListBoxForeachFunc)

    the function to call for each selected child

  • data (GObject)

    user data to pass to the function

Returns:

  • (nil)

#selected_rowGtk::ListBoxRow

Gets the selected row.

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

Returns:

#selected_rowsGLib::List

Creates a list of all selected children.

Returns:

  • (GLib::List)

    A #GList containing the Gtk::Widget for each selected child. Free with g_list_free() when done.

#selection_modeGtk::SelectionMode

Returns selection-mode.

Returns:

#selection_mode=(selection_mode) ⇒ Gtk::SelectionMode

Parameters:

Returns:

#set_filter_func(filter_func, user_data, destroy) ⇒ nil

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_list_box_row_changed()) or when gtk_list_box_invalidate_filter() is called.

Note that using a filter function is incompatible with using a model (see gtk_list_box_bind_model()).

Parameters:

  • filter_func (Gtk::ListBoxFilterFunc)

    callback that lets you filter which rows to show

  • user_data (GObject)

    user data passed to filter_func

  • destroy (GLib::DestroyNotify)

    destroy notifier for user_data

Returns:

  • (nil)

#set_header_func(update_header, user_data, destroy) ⇒ nil

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_list_box_row_get_header() and either update the state of the widget as needed, or set a new one using gtk_list_box_row_set_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_list_box_row_changed()) and when the row before changes (either by gtk_list_box_row_changed() on the previous row, or when the previous row becomes a different row). It is also called for all rows when gtk_list_box_invalidate_headers() is called.

Parameters:

  • update_header (Gtk::ListBoxUpdateHeaderFunc)

    callback that lets you add row headers

  • user_data (GObject)

    user data passed to update_header

  • destroy (GLib::DestroyNotify)

    destroy notifier for user_data

Returns:

  • (nil)

#set_sort_func(sort_func, user_data, destroy) ⇒ nil

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_list_box_row_changed()) and when gtk_list_box_invalidate_sort() is called.

Note that using a sort function is incompatible with using a model (see gtk_list_box_bind_model()).

Parameters:

  • sort_func (Gtk::ListBoxSortFunc)

    the sort function

  • user_data (GObject)

    user data passed to sort_func

  • destroy (GLib::DestroyNotify)

    destroy notifier for user_data

Returns:

  • (nil)

#unselect_allnil

Unselect all children of box, if the selection mode allows it.

Returns:

  • (nil)

#unselect_row(row) ⇒ nil

Unselects a single row of box, if the selection mode allows it.

Parameters:

Returns:

  • (nil)