Class: Gtk::TreeViewColumn

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

Overview

A visible column in a [classGtk.TreeView] widget

The GtkTreeViewColumn object represents a visible column in a GtkTreeView widget. It allows to set properties of the column header, and functions as a holding pen for the cell renderers which determine how the data in the column is displayed.

Please refer to the tree widget conceptual overview for an overview of all the objects and data types related to the tree widget and how they work together, and to the [classGtk.TreeView] documentation for specifics about the CSS node structure for treeviews and their headers.

Instance Method Summary collapse

Constructor Details

#initialize(title, cell, array) ⇒ Gtk::TreeViewColumn

Creates a new GtkTreeViewColumn with a number of default values. This is equivalent to calling gtk_tree_view_column_set_title(), gtk_tree_view_column_pack_start(), and gtk_tree_view_column_set_attributes() on the newly created GtkTreeViewColumn.

Here’s a simple example:

 enum { TEXT_COLUMN, COLOR_COLUMN, N_COLUMNS };
 // ...
 {
   GtkTreeViewColumn *column;
   GtkCellRenderer   *renderer = gtk_cell_renderer_text_new ();

   column = gtk_tree_view_column_new_with_attributes ("Title",
                                                      renderer,
                                                      "text", TEXT_COLUMN,
                                                      "foreground", COLOR_COLUMN,
                                                      NULL);
 }

Parameters:

  • title (String)

    The title to set the header to

  • cell (Gtk::CellRenderer)

    The GtkCellRenderer

  • array (Array)

    A nil-terminated list of attributes

Instance Method Details

#add_attribute(cell_renderer, attribute, column) ⇒ nil

Adds an attribute mapping to the list in tree_column.

The column is the column of the model to get a value from, and the attribute is the parameter on cell_renderer to be set from the value. So for example if column 2 of the model contains strings, you could have the “text” attribute of a GtkCellRendererText get its values from column 2.

Parameters:

  • cell_renderer (Gtk::CellRenderer)

    the GtkCellRenderer to set attributes on

  • attribute (String)

    An attribute on the renderer

  • column (Integer)

    The column position on the model to get the attribute from.

Returns:

  • (nil)

#alignmentGtk::gfloat

Returns alignment.

Returns:

  • (Gtk::gfloat)

    alignment

#alignment=(alignment) ⇒ Gtk::gfloat

Parameters:

  • alignment (Gtk::gfloat)

Returns:

  • (Gtk::gfloat)

    alignment

  • (Gtk::gfloat)

    alignment

#buttonGtk::Widget

Returns the button used in the treeview column header

Returns:

#cell_areaGtk::CellArea

The GtkCellArea used to layout cell renderers for this column.

If no area is specified when creating the tree view column with gtk_tree_view_column_new_with_area() a horizontally oriented GtkCellAreaBox will be used.

Returns:

#cell_area=(cell_area) ⇒ Gtk::CellArea

The GtkCellArea used to layout cell renderers for this column.

If no area is specified when creating the tree view column with gtk_tree_view_column_new_with_area() a horizontally oriented GtkCellAreaBox will be used.

Parameters:

Returns:

#cell_get_position(cell_renderer, x_offset, width) ⇒ Boolean

Obtains the horizontal position and size of a cell in a column.

If the cell is not found in the column, start_pos and width are not changed and false is returned.

Parameters:

  • cell_renderer (Gtk::CellRenderer)

    a GtkCellRenderer

  • x_offset (Integer)

    return location for the horizontal position of cell within tree_column

  • width (Integer)

    return location for the width of cell

Returns:

  • (Boolean)

    true if cell belongs to tree_column

#cell_get_size(x_offset, y_offset, width, height) ⇒ nil

Obtains the width and height needed to render the column. This is used primarily by the GtkTreeView.

Parameters:

  • x_offset (Integer)

    location to return x offset of a cell relative to cell_area

  • y_offset (Integer)

    location to return y offset of a cell relative to cell_area

  • width (Integer)

    location to return width needed to render a cell

  • height (Integer)

    location to return height needed to render a cell

Returns:

  • (nil)

#cell_is_visibleBoolean

Returns true if any of the cells packed into the tree_column are visible. For this to be meaningful, you must first initialize the cells with gtk_tree_view_column_cell_set_cell_data()

Returns:

  • (Boolean)

    true, if any of the cells packed into the tree_column are currently visible

#cell_set_cell_data(tree_model, iter, is_expander, is_expanded) ⇒ nil

Sets the cell renderer based on the tree_model and iter. That is, for every attribute mapping in tree_column, it will get a value from the set column on the iter, and use that value to set the attribute on the cell renderer. This is used primarily by the GtkTreeView.

Parameters:

  • tree_model (Gtk::TreeModel)

    The GtkTreeModel to get the cell renderers attributes from.

  • iter (Gtk::TreeIter)

    The GtkTreeIter to get the cell renderer’s attributes from.

  • is_expander (Boolean)

    true, if the row has children

  • is_expanded (Boolean)

    true, if the row has visible children

Returns:

  • (nil)

#clearnil

Unsets all the mappings on all renderers on the tree_column.

Returns:

  • (nil)

#clear_attributes(cell_renderer) ⇒ nil

Clears all existing attributes previously set with gtk_tree_view_column_set_attributes().

Parameters:

  • cell_renderer (Gtk::CellRenderer)

    a GtkCellRenderer to clear the attribute mapping on.

Returns:

  • (nil)

#clickableBoolean

Returns true if the user can click on the header for the column.

Returns:

  • (Boolean)

    true if user can click the column header.

#clickable=(clickable) ⇒ Boolean

Parameters:

  • clickable (Boolean)

Returns:

  • (Boolean)

    clickable

  • (Boolean)

    clickable

#clickable?Boolean

Returns clickable.

Returns:

  • (Boolean)

    clickable

#clickednil

Emits the “clicked” signal on the column. This function will only work if tree_column is clickable.

Returns:

  • (nil)

#expandBoolean

Returns true if the column expands to fill available space.

Returns:

  • (Boolean)

    true if the column expands to fill available space.

#expand=(expand) ⇒ Boolean

Parameters:

  • expand (Boolean)

Returns:

  • (Boolean)

    expand

  • (Boolean)

    expand

#expand?Boolean

Returns expand.

Returns:

  • (Boolean)

    expand

#fixed_widthInteger

Returns fixed-width.

Returns:

  • (Integer)

    fixed-width

#fixed_width=(fixed_width) ⇒ Integer

Parameters:

  • fixed_width (Integer)

Returns:

  • (Integer)

    fixed-width

  • (Integer)

    fixed-width

#focus_cell(cell) ⇒ nil

Sets the current keyboard focus to be at cell, if the column contains 2 or more editable and activatable cells.

Parameters:

Returns:

  • (nil)

#max_widthInteger

Returns max-width.

Returns:

  • (Integer)

    max-width

#max_width=(max_width) ⇒ Integer

Parameters:

  • max_width (Integer)

Returns:

  • (Integer)

    max-width

  • (Integer)

    max-width

#min_widthInteger

Returns min-width.

Returns:

  • (Integer)

    min-width

#min_width=(min_width) ⇒ Integer

Parameters:

  • min_width (Integer)

Returns:

  • (Integer)

    min-width

  • (Integer)

    min-width

#pack_end(cell, expand) ⇒ nil

Adds the cell to end of the column. If expand is false, then the cell is allocated no more space than it needs. Any unused space is divided evenly between cells for which expand is true.

Parameters:

  • cell (Gtk::CellRenderer)

    The GtkCellRenderer

  • expand (Boolean)

    true if cell is to be given extra space allocated to tree_column.

Returns:

  • (nil)

#pack_start(cell, expand) ⇒ nil

Packs the cell into the beginning of the column. If expand is false, then the cell is allocated no more space than it needs. Any unused space is divided evenly between cells for which expand is true.

Parameters:

  • cell (Gtk::CellRenderer)

    The GtkCellRenderer

  • expand (Boolean)

    true if cell is to be given extra space allocated to tree_column.

Returns:

  • (nil)

#queue_resizenil

Flags the column, and the cell renderers added to this column, to have their sizes renegotiated.

Returns:

  • (nil)

#reorderableBoolean

Returns true if the tree_column can be reordered by the user.

Returns:

  • (Boolean)

    true if the tree_column can be reordered by the user.

#reorderable=(reorderable) ⇒ Boolean

Parameters:

  • reorderable (Boolean)

Returns:

  • (Boolean)

    reorderable

  • (Boolean)

    reorderable

#reorderable?Boolean

Returns reorderable.

Returns:

  • (Boolean)

    reorderable

#resizableBoolean

Returns true if the tree_column can be resized by the end user.

Returns:

  • (Boolean)

    true, if the tree_column can be resized.

#resizable=(resizable) ⇒ Boolean

Parameters:

  • resizable (Boolean)

Returns:

  • (Boolean)

    resizable

  • (Boolean)

    resizable

#resizable?Boolean

Returns resizable.

Returns:

  • (Boolean)

    resizable

#set_attributes(cell_renderer, array) ⇒ nil

Sets the attributes in the list as the attributes of tree_column.

The attributes should be in attribute/column order, as in gtk_tree_view_column_add_attribute(). All existing attributes are removed, and replaced with the new attributes.

Parameters:

  • cell_renderer (Gtk::CellRenderer)

    the GtkCellRenderer we’re setting the attributes of

  • array (Array)

    A nil-terminated list of attributes

Returns:

  • (nil)

#set_cell_data_func(cell_renderer, func, func_data, destroy) ⇒ nil

Sets the GtkTreeCellDataFunc to use for the column.

This function is used instead of the standard attributes mapping for setting the column value, and should set the value of tree_column's cell renderer as appropriate. func may be nil to remove an older one.

Parameters:

  • cell_renderer (Gtk::CellRenderer)

    A GtkCellRenderer

  • func (Gtk::TreeCellDataFunc)

    The GtkTreeCellDataFunc to use.

  • func_data (GObject)

    The user data for func.

  • destroy (GLib::DestroyNotify)

    The destroy notification for func_data

Returns:

  • (nil)

#sizingGtk::TreeViewColumnSizing

Returns sizing.

Returns:

#sizing=(sizing) ⇒ Gtk::TreeViewColumnSizing

Parameters:

Returns:

#sort_column_idInteger

Logical sort column ID this column sorts on when selected for sorting. Setting the sort column ID makes the column header clickable. Set to -1 to make the column unsortable.

Returns:

  • (Integer)

    sort-column-id

#sort_column_id=(sort_column_id) ⇒ Integer

Logical sort column ID this column sorts on when selected for sorting. Setting the sort column ID makes the column header clickable. Set to -1 to make the column unsortable.

Parameters:

  • sort_column_id (Integer)

Returns:

  • (Integer)

    sort-column-id

  • (Integer)

    sort-column-id

#sort_indicatorBoolean

Gets the value set by gtk_tree_view_column_set_sort_indicator().

Returns:

  • (Boolean)

    whether the sort indicator arrow is displayed

#sort_indicator=(sort_indicator) ⇒ Boolean

Parameters:

  • sort_indicator (Boolean)

Returns:

  • (Boolean)

    sort-indicator

  • (Boolean)

    sort-indicator

#sort_indicator?Boolean

Returns sort-indicator.

Returns:

  • (Boolean)

    sort-indicator

#sort_orderGtk::SortType

Returns sort-order.

Returns:

#sort_order=(sort_order) ⇒ Gtk::SortType

Parameters:

Returns:

#spacingInteger

Returns spacing.

Returns:

  • (Integer)

    spacing

#spacing=(spacing) ⇒ Integer

Parameters:

  • spacing (Integer)

Returns:

  • (Integer)

    spacing

  • (Integer)

    spacing

#titleString

Returns title.

Returns:

  • (String)

    title

#title=(title) ⇒ String

Parameters:

  • title (String)

Returns:

  • (String)

    title

  • (String)

    title

#tree_viewGtk::Widget

Returns the GtkTreeView wherein tree_column has been inserted. If column is currently not inserted in any tree view, nil is returned.

Returns:

  • (Gtk::Widget)

    The tree view wherein column has been inserted

#visibleBoolean

Returns true if tree_column is visible. the tree will show the column.

Returns:

  • (Boolean)

    whether the column is visible or not. If it is visible, then

#visible=(visible) ⇒ Boolean

Parameters:

  • visible (Boolean)

Returns:

  • (Boolean)

    visible

  • (Boolean)

    visible

#visible?Boolean

Returns visible.

Returns:

  • (Boolean)

    visible

#widgetGtk::Widget

Returns widget.

Returns:

#widget=(widget) ⇒ Gtk::Widget

Parameters:

Returns:

#widthInteger

Returns width.

Returns:

  • (Integer)

    width

#width=(width) ⇒ Integer

Parameters:

  • width (Integer)

Returns:

  • (Integer)

    width

  • (Integer)

    width

#x_offsetInteger

Returns x-offset.

Returns:

  • (Integer)

    x-offset

#x_offset=(x_offset) ⇒ Integer

Parameters:

  • x_offset (Integer)

Returns:

  • (Integer)

    x-offset

  • (Integer)

    x-offset