Next: , Previous: GtkTreeSelection, Up: Top


34 GtkTreeViewColumn

A visible column in a widget

34.1 Overview

The GtkTreeViewColumn object represents a visible column in a <gtk-tree-view> 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.

34.2 Usage

— Class: <gtk-tree-view-column>

Derives from <gtk-buildable>, <gtk-cell-layout>, <gtk-object>.

This class defines the following slots:

visible
Whether to display the column
resizable
Column is user-resizable
width
Current width of the column
spacing
Space which is inserted between cells
sizing
Resize mode of the column
fixed-width
Current fixed width of the column
min-width
Minimum allowed width of the column
max-width
Maximum allowed width of the column
title
Title to appear in column header
expand
Column gets share of extra width allocated to the widget
clickable
Whether the header can be clicked
widget
Widget to put in column header button instead of column title
alignment
X Alignment of the column header text or widget
reorderable
Whether the column can be reordered around the headers
sort-indicator
Whether to show a sort indicator
sort-order
Sort direction the sort indicator should indicate
— Signal on <gtk-tree-view-column>: clicked
— Function: gtk-tree-view-column-new ⇒  (ret <gtk-tree-view-column>)

Creates a new <gtk-tree-view-column>.

ret
A newly created <gtk-tree-view-column>.
— Function: gtk-tree-view-column-pack-start (self <gtk-tree-view-column>) (cell <gtk-cell-renderer>) (expand bool)
— Method: pack-start

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

tree-column
A <gtk-tree-view-column>.
cell
The <gtk-cell-renderer>.
expand
#t’ if cell is to be given extra space allocated to tree-column.
— Function: gtk-tree-view-column-pack-end (self <gtk-tree-view-column>) (cell <gtk-cell-renderer>) (expand bool)
— Method: pack-end

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

tree-column
A <gtk-tree-view-column>.
cell
The <gtk-cell-renderer>.
expand
#t’ if cell is to be given extra space allocated to tree-column.
— Function: gtk-tree-view-column-clear (self <gtk-tree-view-column>)
— Method: clear

Unsets all the mappings on all renderers on the tree-column.

tree-column
A <gtk-tree-view-column>
— Function: gtk-tree-view-column-add-attribute (self <gtk-tree-view-column>) (cell_renderer <gtk-cell-renderer>) (attribute mchars) (column int)
— Method: add-attribute

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 <gtk-cell-renderer-text> get its values from column 2.

tree-column
A <gtk-tree-view-column>.
cell-renderer
the <gtk-cell-renderer> to set attributes on
attribute
An attribute on the renderer
column
The column position on the model to get the attribute from.
— Function: gtk-tree-view-column-set-spacing (self <gtk-tree-view-column>) (spacing int)
— Method: set-spacing

Sets the spacing field of tree-column, which is the number of pixels to place between cell renderers packed into it.

tree-column
A <gtk-tree-view-column>.
spacing
distance between cell renderers in pixels.
— Function: gtk-tree-view-column-get-spacing (self <gtk-tree-view-column>) ⇒  (ret int)
— Method: get-spacing

Returns the spacing of tree-column.

tree-column
A <gtk-tree-view-column>.
ret
the spacing of tree-column.
— Function: gtk-tree-view-column-set-visible (self <gtk-tree-view-column>) (visible bool)
— Method: set-visible

Sets the visibility of tree-column.

tree-column
A <gtk-tree-view-column>.
visible
#t’ if the tree-column is visible.
— Function: gtk-tree-view-column-get-visible (self <gtk-tree-view-column>) ⇒  (ret bool)
— Method: get-visible

Returns ‘#t’ if tree-column is visible.

tree-column
A <gtk-tree-view-column>.
ret
whether the column is visible or not. If it is visible, then the tree will show the column.
— Function: gtk-tree-view-column-set-resizable (self <gtk-tree-view-column>) (resizable bool)
— Method: set-resizable

If resizable is ‘#t’, then the user can explicitly resize the column by grabbing the outer edge of the column button. If resizable is ‘#t’ and sizing mode of the column is <gtk-tree-view-column-autosize>, then the sizing mode is changed to <gtk-tree-view-column-grow-only>.

tree-column
A <gtk-tree-view-column>
resizable
#t’, if the column can be resized
— Function: gtk-tree-view-column-get-resizable (self <gtk-tree-view-column>) ⇒  (ret bool)
— Method: get-resizable

Returns ‘#t’ if the tree-column can be resized by the end user.

tree-column
A <gtk-tree-view-column>
ret
#t’, if the tree-column can be resized.
— Function: gtk-tree-view-column-set-sizing (self <gtk-tree-view-column>) (type <gtk-tree-view-column-sizing>)
— Method: set-sizing

Sets the growth behavior of tree-column to type.

tree-column
A <gtk-tree-view-column>.
type
The <gtk-tree-view-column-sizing>.
— Function: gtk-tree-view-column-get-sizing (self <gtk-tree-view-column>) ⇒  (ret <gtk-tree-view-column-sizing>)
— Method: get-sizing

Returns the current type of tree-column.

tree-column
A <gtk-tree-view-column>.
ret
The type of tree-column.
— Function: gtk-tree-view-column-get-width (self <gtk-tree-view-column>) ⇒  (ret int)
— Method: get-width

Returns the current size of tree-column in pixels.

tree-column
A <gtk-tree-view-column>.
ret
The current width of tree-column.
— Function: gtk-tree-view-column-set-min-width (self <gtk-tree-view-column>) (min_width int)
— Method: set-min-width

Sets the minimum width of the tree-column. If min-width is -1, then the minimum width is unset.

tree-column
A <gtk-tree-view-column>.
min-width
The minimum width of the column in pixels, or -1.
— Function: gtk-tree-view-column-get-min-width (self <gtk-tree-view-column>) ⇒  (ret int)
— Method: get-min-width

Returns the minimum width in pixels of the tree-column, or -1 if no minimum width is set.

tree-column
A <gtk-tree-view-column>.
ret
The minimum width of the tree-column.
— Function: gtk-tree-view-column-set-max-width (self <gtk-tree-view-column>) (max_width int)
— Method: set-max-width

Sets the maximum width of the tree-column. If max-width is -1, then the maximum width is unset. Note, the column can actually be wider than max width if it's the last column in a view. In this case, the column expands to fill any extra space.

tree-column
A <gtk-tree-view-column>.
max-width
The maximum width of the column in pixels, or -1.
— Function: gtk-tree-view-column-get-max-width (self <gtk-tree-view-column>) ⇒  (ret int)
— Method: get-max-width

Returns the maximum width in pixels of the tree-column, or -1 if no maximum width is set.

tree-column
A <gtk-tree-view-column>.
ret
The maximum width of the tree-column.
— Function: gtk-tree-view-column-clicked (self <gtk-tree-view-column>)
— Method: clicked

Emits the "clicked" signal on the column. This function will only work if tree-column is clickable.

tree-column
a <gtk-tree-view-column>
— Function: gtk-tree-view-column-set-title (self <gtk-tree-view-column>) (title mchars)
— Method: set-title

Sets the title of the tree-column. If a custom widget has been set, then this value is ignored.

tree-column
A <gtk-tree-view-column>.
title
The title of the tree-column.
— Function: gtk-tree-view-column-get-title (self <gtk-tree-view-column>) ⇒  (ret mchars)
— Method: get-title

Returns the title of the widget.

tree-column
A <gtk-tree-view-column>.
ret
the title of the column. This string should not be modified or freed.
— Function: gtk-tree-view-column-set-expand (self <gtk-tree-view-column>) (expand bool)
— Method: set-expand

Sets the column to take available extra space. This space is shared equally amongst all columns that have the expand set to ‘#t’. If no column has this option set, then the last column gets all extra space. By default, every column is created with this ‘#f’.

tree-column
A <gtk-tree-view-column>
expand
#t’ if the column should take available extra space, ‘#f’ if not

Since 2.4

— Function: gtk-tree-view-column-get-expand (self <gtk-tree-view-column>) ⇒  (ret bool)
— Method: get-expand

Return ‘#t’ if the column expands to take any available space.

tree-column
a <gtk-tree-view-column>
ret
#t’, if the column expands

Since 2.4

— Function: gtk-tree-view-column-set-clickable (self <gtk-tree-view-column>) (clickable bool)
— Method: set-clickable

Sets the header to be active if active is ‘#t’. When the header is active, then it can take keyboard focus, and can be clicked.

tree-column
A <gtk-tree-view-column>.
clickable
#t’ if the header is active.
— Function: gtk-tree-view-column-get-clickable (self <gtk-tree-view-column>) ⇒  (ret bool)
— Method: get-clickable

Returns ‘#t’ if the user can click on the header for the column.

tree-column
a <gtk-tree-view-column>
ret
#t’ if user can click the column header.
— Function: gtk-tree-view-column-set-widget (self <gtk-tree-view-column>) (widget <gtk-widget>)
— Method: set-widget

Sets the widget in the header to be widget. If widget is ‘#f’, then the header button is set with a <gtk-label> set to the title of tree-column.

tree-column
A <gtk-tree-view-column>.
widget
A child <gtk-widget>, or ‘#f’.
— Function: gtk-tree-view-column-get-widget (self <gtk-tree-view-column>) ⇒  (ret <gtk-widget>)
— Method: get-widget

Returns the <gtk-widget> in the button on the column header. If a custom widget has not been set then ‘#f’ is returned.

tree-column
A <gtk-tree-view-column>.
ret
The <gtk-widget> in the column header, or ‘#f
— Function: gtk-tree-view-column-set-alignment (self <gtk-tree-view-column>) (xalign float)
— Method: set-alignment

Sets the alignment of the title or custom widget inside the column header. The alignment determines its location inside the button – 0.0 for left, 0.5 for center, 1.0 for right.

tree-column
A <gtk-tree-view-column>.
xalign
The alignment, which is between [0.0 and 1.0] inclusive.
— Function: gtk-tree-view-column-get-alignment (self <gtk-tree-view-column>) ⇒  (ret float)
— Method: get-alignment

Returns the current x alignment of tree-column. This value can range between 0.0 and 1.0.

tree-column
A <gtk-tree-view-column>.
ret
The current alignent of tree-column.
— Function: gtk-tree-view-column-set-sort-order (self <gtk-tree-view-column>) (order <gtk-sort-type>)
— Method: set-sort-order

Changes the appearance of the sort indicator.

This does not actually sort the model. Use gtk-tree-view-column-set-sort-column-id if you want automatic sorting support. This function is primarily for custom sorting behavior, and should be used in conjunction with gtk-tree-sortable-set-sort-column to do that. For custom models, the mechanism will vary.

The sort indicator changes direction to indicate normal sort or reverse sort. Note that you must have the sort indicator enabled to see anything when calling this function; see gtk-tree-view-column-set-sort-indicator.

tree-column
a <gtk-tree-view-column>
order
sort order that the sort indicator should indicate
— Function: gtk-tree-view-column-get-sort-order (self <gtk-tree-view-column>) ⇒  (ret <gtk-sort-type>)
— Method: get-sort-order

Gets the value set by gtk-tree-view-column-set-sort-order.

tree-column
a <gtk-tree-view-column>
ret
the sort order the sort indicator is indicating
— Function: gtk-tree-view-column-focus-cell (self <gtk-tree-view-column>) (cell <gtk-cell-renderer>)
— Method: focus-cell

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

tree-column
A <gtk-tree-view-column>
cell
A <gtk-cell-renderer>

Since 2.2

— Function: gtk-tree-view-column-queue-resize (self <gtk-tree-view-column>)
— Method: queue-resize

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

tree-column
A <gtk-tree-view-column>

Since 2.8