A widget for displaying both trees and lists
Widget that displays any object that implements the GtkTreeModel interface.
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.
Derives from
<gtk-container>
.This class defines the following slots:
model
- The model for the tree view
hadjustment
- Horizontal Adjustment for the widget
vadjustment
- Vertical Adjustment for the widget
headers-visible
- Show the column header buttons
headers-clickable
- Column headers respond to click events
expander-column
- Set the column for the expander column
reorderable
- View is reorderable
rules-hint
- Set a hint to the theme engine to draw rows in alternating colors
enable-search
- View allows user to search through columns interactively
search-column
- Model column to search through when searching through code
fixed-height-mode
- Speeds up GtkTreeView by assuming that all rows have the same height
hover-selection
- Whether the selection should follow the pointer
hover-expand
- Whether rows should be expanded/collapsed when the pointer moves over them
show-expanders
- View has expanders
level-indentation
- Extra indentation for each level
rubber-banding
- Whether to enable selection of multiple items by dragging the mouse pointer
enable-grid-lines
- Whether grid lines should be drawn in the tree view
enable-tree-lines
- Whether tree lines should be drawn in the tree view
tooltip-column
- The column in the model containing the tooltip texts for the rows
<gtk-tree-path>
) (arg1 <gtk-tree-view-column>
)The "row-activated" signal is emitted when the method
gtk-tree-view-row-activated
is called or the user double clicks a treeview row. It is also emitted when a non-editable row is selected and one of the keys: Space, Shift+Space, Return or Enter is pressed.For selection handling refer to the tree widget conceptual overview as well as
<gtk-tree-selection>
.
<gtk-tree-iter>
) (arg1 <gtk-tree-path>
) ⇒ <gboolean>
The given row is about to be expanded (show its children nodes). Use this signal if you need to control the expandability of individual rows.
<gtk-tree-iter>
) (arg1 <gtk-tree-path>
) ⇒ <gboolean>
The given row is about to be collapsed (hide its children nodes). Use this signal if you need to control the collapsibility of individual rows.
<gtk-tree-iter>
) (arg1 <gtk-tree-path>
)The given row has been expanded (child nodes are shown).
<gtk-tree-iter>
) (arg1 <gtk-tree-path>
)The given row has been collapsed (child nodes are hidden).
<gboolean>
) (arg1 <gboolean>
) (arg2 <gboolean>
) ⇒ <gboolean>
<gtk-widget>
)Creates a new
<gtk-tree-view>
widget.
- ret
- A newly created
<gtk-tree-view>
widget.
<gtk-tree-model>
) ⇒ (ret <gtk-widget>
)Creates a new
<gtk-tree-view>
widget with the model initialized to model.
- model
- the model.
- ret
- A newly created
<gtk-tree-view>
widget.
<gtk-tree-view>
) ⇒ (ret <gtk-tree-model>
)Returns the model the
<gtk-tree-view>
is based on. Returns ‘#f
’ if the model is unset.
- tree-view
- a
<gtk-tree-view>
- ret
- A
<gtk-tree-model>
, or ‘#f
’ if none is currently being used.
<gtk-tree-view>
) (model <gtk-tree-model>
)Sets the model for a
<gtk-tree-view>
. If the tree-view already has a model set, it will remove it before setting the new model. If model is ‘#f
’, then it will unset the old model.
- tree-view
- A
<gtk-tree-node>
.- model
- The model.
<gtk-tree-view>
) ⇒ (ret <gtk-tree-selection>
)Gets the
<gtk-tree-selection>
associated with tree-view.
- tree-view
- A
<gtk-tree-view>
.- ret
- A
<gtk-tree-selection>
object.
<gtk-tree-view>
) ⇒ (ret <gtk-adjustment>
)Gets the
<gtk-adjustment>
currently being used for the horizontal aspect.
- tree-view
- A
<gtk-tree-view>
- ret
- A
<gtk-adjustment>
object, or ‘#f
’ if none is currently being used.
<gtk-tree-view>
) (adjustment <gtk-adjustment>
)Sets the
<gtk-adjustment>
for the current horizontal aspect.
- tree-view
- A
<gtk-tree-view>
- adjustment
- The
<gtk-adjustment>
to set, or ‘#f
’
<gtk-tree-view>
) ⇒ (ret <gtk-adjustment>
)Gets the
<gtk-adjustment>
currently being used for the vertical aspect.
- tree-view
- A
<gtk-tree-view>
- ret
- A
<gtk-adjustment>
object, or ‘#f
’ if none is currently being used.
<gtk-tree-view>
) (adjustment <gtk-adjustment>
)Sets the
<gtk-adjustment>
for the current vertical aspect.
- tree-view
- A
<gtk-tree-view>
- adjustment
- The
<gtk-adjustment>
to set, or ‘#f
’
<gtk-tree-view>
) ⇒ (ret bool
)Returns ‘
#t
’ if the headers on the tree-view are visible.
- tree-view
- A
<gtk-tree-view>
.- ret
- Whether the headers are visible or not.
<gtk-tree-view>
) (headers_visible bool
)Sets the visibility state of the headers.
- tree-view
- A
<gtk-tree-view>
.- headers-visible
- ‘
#t
’ if the headers are visible
<gtk-tree-view>
)Resizes all columns to their optimal width. Only works after the treeview has been realized.
- tree-view
- A
<gtk-tree-view>
.
<gtk-tree-view>
) ⇒ (ret bool
)Returns whether all header columns are clickable.
- tree-view
- A
<gtk-tree-view>
.- ret
- ‘
#t
’ if all header columns are clickable, otherwise ‘#f
’Since 2.10
<gtk-tree-view>
) (setting bool
)Allow the column title buttons to be clicked.
- tree-view
- A
<gtk-tree-view>
.- setting
- ‘
#t
’ if the columns are clickable.
<gtk-tree-view>
) (setting bool
)This function tells GTK+ that the user interface for your application requires users to read across tree rows and associate cells with one another. By default, GTK+ will then render the tree with alternating row colors. Do not use it just because you prefer the appearance of the ruled tree; that's a question for the theme. Some themes will draw tree rows in alternating colors even when rules are turned off, and users who prefer that appearance all the time can choose those themes. You should call this function only as a semantic hint to the theme engine that your tree makes alternating colors useful from a functional standpoint (since it has lots of columns, generally).
- tree-view
- a
<gtk-tree-view>
- setting
- ‘
#t
’ if the tree requires reading across rows
<gtk-tree-view>
) ⇒ (ret bool
)Gets the setting set by
gtk-tree-view-set-rules-hint
.
- tree-view
- a
<gtk-tree-view>
- ret
- ‘
#t
’ if rules are useful for the user of this tree
<gtk-tree-view>
) (column <gtk-tree-view-column>
) ⇒ (ret int
)Appends column to the list of columns. If tree-view has "fixed_height" mode enabled, then column must have its "sizing" property set to be GTK_TREE_VIEW_COLUMN_FIXED.
- tree-view
- A
<gtk-tree-view>
.- column
- The
<gtk-tree-view-column>
to add.- ret
- The number of columns in tree-view after appending.
<gtk-tree-view>
) (column <gtk-tree-view-column>
) ⇒ (ret int
)Removes column from tree-view.
- tree-view
- A
<gtk-tree-view>
.- column
- The
<gtk-tree-view-column>
to remove.- ret
- The number of columns in tree-view after removing.
<gtk-tree-view>
) (column <gtk-tree-view-column>
) (position int
) ⇒ (ret int
)This inserts the column into the tree-view at position. If position is -1, then the column is inserted at the end. If tree-view has "fixed_height" mode enabled, then column must have its "sizing" property set to be GTK_TREE_VIEW_COLUMN_FIXED.
- tree-view
- A
<gtk-tree-view>
.- column
- The
<gtk-tree-view-column>
to be inserted.- position
- The position to insert column in.
- ret
- The number of columns in tree-view after insertion.
<gtk-tree-view>
) (n int
) ⇒ (ret <gtk-tree-view-column>
)Gets the
<gtk-tree-view-column>
at the given position in the<tree-view>
.
- tree-view
- A
<gtk-tree-view>
.- n
- The position of the column, counting from 0.
- ret
- The
<gtk-tree-view-column>
, or ‘#f
’ if the position is outside the range of columns.
<gtk-tree-view>
) ⇒ (ret glist-of
)Returns a
<g-list>
of all the<gtk-tree-view-column>
s currently in tree-view. The returned list must be freed withg-list-free
.
- tree-view
- A
<gtk-tree-view>
- ret
- A list of
<gtk-tree-view-column>
s
<gtk-tree-view>
) (column <gtk-tree-view-column>
) (base_column <gtk-tree-view-column>
)Moves column to be after to base-column. If base-column is ‘
#f
’, then column is placed in the first position.
- tree-view
- A
<gtk-tree-view>
- column
- The
<gtk-tree-view-column>
to be moved.- base-column
- The
<gtk-tree-view-column>
to be moved relative to, or ‘#f
’.
<gtk-tree-view>
) (column <gtk-tree-view-column>
)Sets the column to draw the expander arrow at. It must be in tree-view. If column is ‘
#f
’, then the expander arrow is always at the first visible column.If you do not want expander arrow to appear in your tree, set the expander column to a hidden column.
- tree-view
- A
<gtk-tree-view>
- column
- ‘
#f
’, or the column to draw the expander arrow at.
<gtk-tree-view>
) ⇒ (ret <gtk-tree-view-column>
)Returns the column that is the current expander column. This column has the expander arrow drawn next to it.
- tree-view
- A
<gtk-tree-view>
- ret
- The expander column.
<gtk-tree-view>
) (tree_x int
) (tree_y int
)Scrolls the tree view such that the top-left corner of the visible area is tree-x, tree-y, where tree-x and tree-y are specified in tree window coordinates. The tree-view must be realized before this function is called. If it isn't, you probably want to be using
gtk-tree-view-scroll-to-cell
.If either tree-x or tree-y are -1, then that direction isn't scrolled.
- tree-view
- a
<gtk-tree-view>
- tree-x
- X coordinate of new top-left pixel of visible area, or -1
- tree-y
- Y coordinate of new top-left pixel of visible area, or -1
<gtk-tree-view>
) (path <gtk-tree-path>
) (column <gtk-tree-view-column>
) (use_align bool
) (row_align float
) (col_align float
)Moves the alignments of tree-view to the position specified by column and path. If column is ‘
#f
’, then no horizontal scrolling occurs. Likewise, if path is ‘#f
’ no vertical scrolling occurs. At a minimum, one of column or path need to be non-‘#f
’. row-align determines where the row is placed, and col-align determines where column is placed. Both are expected to be between 0.0 and 1.0. 0.0 means left/top alignment, 1.0 means right/bottom alignment, 0.5 means center.If use-align is ‘
#f
’, then the alignment arguments are ignored, and the tree does the minimum amount of work to scroll the cell onto the screen. This means that the cell will be scrolled to the edge closest to its current position. If the cell is currently visible on the screen, nothing is done.This function only works if the model is set, and path is a valid row on the model. If the model changes before the tree-view is realized, the centered path will be modified to reflect this change.
- tree-view
- A
<gtk-tree-view>
.- path
- The path of the row to move to, or ‘
#f
’.- column
- The
<gtk-tree-view-column>
to move horizontally to, or ‘#f
’.- use-align
- whether to use alignment arguments, or ‘
#f
’.- row-align
- The vertical alignment of the row specified by path.
- col-align
- The horizontal alignment of the column specified by column.
<gtk-tree-view>
) (path <gtk-tree-path>
) (focus_column <gtk-tree-view-column>
) (start_editing bool
)Sets the current keyboard focus to be at path, and selects it. This is useful when you want to focus the user's attention on a particular row. If focus-column is not ‘
#f
’, then focus is given to the column specified by it. Additionally, if focus-column is specified, and start-editing is ‘#t
’, then editing should be started in the specified cell. This function is often followed by gtk-widget-grab-focus (tree-view) in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.
- tree-view
- A
<gtk-tree-view>
- path
- A
<gtk-tree-path>
- focus-column
- A
<gtk-tree-view-column>
, or ‘#f
’- start-editing
- ‘
#t
’ if the specified cell should start being edited.
<gtk-tree-view>
) (path <gtk-tree-path>
) (focus_column <gtk-tree-view-column>
) (focus_cell <gtk-cell-renderer>
) (start_editing bool
)Sets the current keyboard focus to be at path, and selects it. This is useful when you want to focus the user's attention on a particular row. If focus-column is not ‘
#f
’, then focus is given to the column specified by it. If focus-column and focus-cell are not ‘#f
’, and focus-column contains 2 or more editable or activatable cells, then focus is given to the cell specified by focus-cell. Additionally, if focus-column is specified, and start-editing is ‘#t
’, then editing should be started in the specified cell. This function is often followed by gtk-widget-grab-focus (tree-view) in order to give keyboard focus to the widget. Please note that editing can only happen when the widget is realized.
- tree-view
- A
<gtk-tree-view>
- path
- A
<gtk-tree-path>
- focus-column
- A
<gtk-tree-view-column>
, or ‘#f
’- focus-cell
- A
<gtk-cell-renderer>
, or ‘#f
’- start-editing
- ‘
#t
’ if the specified cell should start being edited.Since 2.2
<gtk-tree-view>
) (path <gtk-tree-path>
) (column <gtk-tree-view-column>
)Activates the cell determined by path and column.
- tree-view
- A
<gtk-tree-view>
- path
- The
<gtk-tree-path>
to be activated.- column
- The
<gtk-tree-view-column>
to be activated.
<gtk-tree-view>
)Recursively expands all nodes in the tree-view.
- tree-view
- A
<gtk-tree-view>
.
<gtk-tree-view>
)Recursively collapses all visible, expanded nodes in tree-view.
- tree-view
- A
<gtk-tree-view>
.
<gtk-tree-view>
) (path <gtk-tree-path>
)Expands the row at path. This will also expand all parent rows of path as necessary.
- tree-view
- A
<gtk-tree-view>
.- path
- path to a row.
Since 2.2
<gtk-tree-view>
) (path <gtk-tree-path>
) (open_all bool
) ⇒ (ret bool
)Opens the row so its children are visible.
- tree-view
- a
<gtk-tree-view>
- path
- path to a row
- open-all
- whether to recursively expand, or just expand immediate children
- ret
- ‘
#t
’ if the row existed and had children
<gtk-tree-view>
) (path <gtk-tree-path>
) ⇒ (ret bool
)Collapses a row (hides its child rows, if they exist).
- tree-view
- a
<gtk-tree-view>
- path
- path to a row in the tree-view
- ret
- ‘
#t
’ if the row was collapsed.
<gtk-tree-view>
) (path <gtk-tree-path>
) ⇒ (ret bool
)Returns ‘
#t
’ if the node pointed to by path is expanded in tree-view.
- tree-view
- A
<gtk-tree-view>
.- path
- A
<gtk-tree-path>
to test expansion state.- ret
- ‘
#t
’ if<path>
is expanded.
<gtk-tree-view>
) (reorderable bool
)This function is a convenience function to allow you to reorder models that support the
<gtk-drag-source-iface>
and the<gtk-drag-dest-iface>
. Both<gtk-tree-store>
and<gtk-list-store>
support these. If reorderable is ‘#t
’, then the user can reorder the model by dragging and dropping rows. The developer can listen to these changes by connecting to the model's row_inserted and row_deleted signals.This function does not give you any degree of control over the order – any reordering is allowed. If more control is needed, you should probably handle drag and drop manually.
- tree-view
- A
<gtk-tree-view>
.- reorderable
- ‘
#t
’, if the tree can be reordered.
<gtk-tree-view>
) ⇒ (ret bool
)Retrieves whether the user can reorder the tree via drag-and-drop. See
gtk-tree-view-set-reorderable
.
- tree-view
- a
<gtk-tree-view>
- ret
- ‘
#t
’ if the tree can be reordered.
<gtk-tree-view>
) ⇒ (ret <gdk-window>
)Returns the window that tree-view renders to. This is used primarily to compare to ‘event->window’ to confirm that the event on tree-view is on the right window.
- tree-view
- A
<gtk-tree-view>
- ret
- A
<gdk-window>
, or ‘#f
’ when tree-view hasn't been realized yet
<gtk-tree-view>
) (wx int
) (wy int
) ⇒ (tx int
) (ty int
)Converts widget coordinates to coordinates for the tree window (the full scrollable area of the tree).
- tree-view
- a
<gtk-tree-view>
- wx
- widget X coordinate
- wy
- widget Y coordinate
- tx
- return location for tree X coordinate
- ty
- return location for tree Y coordinate
<gtk-tree-view>
) (tx int
) (ty int
) ⇒ (wx int
) (wy int
)Converts tree coordinates (coordinates in full scrollable area of the tree) to widget coordinates.
- tree-view
- a
<gtk-tree-view>
- tx
- tree X coordinate
- ty
- tree Y coordinate
- wx
- return location for widget X coordinate
- wy
- return location for widget Y coordinate
<gtk-tree-view>
)Undoes the effect of
gtk-tree-view-enable-model-drag-dest
.
- tree-view
- a
<gtk-tree-view>
<gtk-tree-view>
) (path <gtk-tree-path>
) (pos <gtk-tree-view-drop-position>
)Sets the row that is highlighted for feedback.
- tree-view
- a
<gtk-tree-view>
- path
- The path of the row to highlight, or ‘
#f
’.- pos
- Specifies whether to drop before, after or into the row
<gtk-tree-view>
) (path <gtk-tree-path>
) ⇒ (ret <gdk-pixmap>
)Creates a
<gdk-pixmap>
representation of the row at path. This image is used for a drag icon.
- tree-view
- a
<gtk-tree-view>
- path
- a
<gtk-tree-path>
in tree-view- ret
- a newly-allocated pixmap of the drag icon.
<gtk-tree-view>
) (enable_search bool
)If enable-search is set, then the user can type in text to search through the tree interactively (this is sometimes called "typeahead find").
Note that even if this is ‘
#f
’, the user can still initiate a search using the "start-interactive-search" key binding.
- tree-view
- A
<gtk-tree-view>
- enable-search
- ‘
#t
’, if the user can search interactively
<gtk-tree-view>
) ⇒ (ret bool
)Returns whether or not the tree allows to start interactive searching by typing in text.
- tree-view
- A
<gtk-tree-view>
- ret
- whether or not to let the user search interactively
<gtk-tree-view>
) ⇒ (ret int
)Gets the column searched on by the interactive search code.
- tree-view
- A
<gtk-tree-view>
- ret
- the column the interactive search code searches in.
<gtk-tree-view>
) (column int
)Sets column as the column where the interactive search code should search in.
If the sort column is set, users can use the "start-interactive-search" key binding to bring up search popup. The enable-search property controls whether simply typing text will also start an interactive search.
Note that column refers to a column of the model.
- tree-view
- A
<gtk-tree-view>
- column
- the column of the model to search in, or -1 to disable searching
<gtk-tree-view>
) ⇒ (ret <gtk-entry>
)Returns the GtkEntry which is currently in use as interactive search entry for tree-view. In case the built-in entry is being used, ‘
#f
’ will be returned.
- tree-view
- A
<gtk-tree-view>
- ret
- the entry currently in use as search entry.
Since 2.10
<gtk-tree-view>
) (entry <gtk-entry>
)Sets the entry which the interactive search code will use for this tree-view. This is useful when you want to provide a search entry in our interface at all time at a fixed position. Passing ‘
#f
’ for entry will make the interactive search code use the built-in popup entry again.
- tree-view
- A
<gtk-tree-view>
- entry
- the entry the interactive search code of tree-view should use or ‘
#f
’Since 2.10
<gtk-tree-view>
) ⇒ (ret bool
)Returns whether fixed height mode is turned on for tree-view.
- tree-view
- a
<gtk-tree-view>
- ret
- ‘
#t
’ if tree-view is in fixed height modeSince 2.6
<gtk-tree-view>
) (enable bool
)Enables or disables the fixed height mode of tree-view. Fixed height mode speeds up
<gtk-tree-view>
by assuming that all rows have the same height. Only enable this option if all rows are the same height and all columns are of type ‘GTK_TREE_VIEW_COLUMN_FIXED’.
- tree-view
- a
<gtk-tree-view>
- enable
- ‘
#t
’ to enable fixed height modeSince 2.6
<gtk-tree-view>
) ⇒ (ret bool
)Returns whether hover selection mode is turned on for tree-view.
- tree-view
- a
<gtk-tree-view>
- ret
- ‘
#t
’ if tree-view is in hover selection modeSince 2.6
<gtk-tree-view>
) (hover bool
)Enables of disables the hover selection mode of tree-view. Hover selection makes the selected row follow the pointer. Currently, this works only for the selection modes ‘GTK_SELECTION_SINGLE’ and ‘GTK_SELECTION_BROWSE’.
- tree-view
- a
<gtk-tree-view>
- hover
- ‘
#t
’ to enable hover selection modeSince 2.6
<gtk-tree-view>
) ⇒ (ret bool
)Returns whether hover expansion mode is turned on for tree-view.
- tree-view
- a
<gtk-tree-view>
- ret
- ‘
#t
’ if tree-view is in hover expansion modeSince 2.6
<gtk-tree-view>
) (expand bool
)Enables of disables the hover expansion mode of tree-view. Hover expansion makes rows expand or collaps if the pointer moves over them.
- tree-view
- a
<gtk-tree-view>
- expand
- ‘
#t
’ to enable hover selection modeSince 2.6
<gtk-tree-view>
) ⇒ (ret bool
)Returns whether rubber banding is turned on for tree-view. If the selection mode is
<gtk-selection-multiple>
, rubber banding will allow the user to select multiple rows by dragging the mouse.
- tree-view
- a
<gtk-tree-view>
- ret
- ‘
#t
’ if rubber banding in tree-view is enabled.Since 2.10
<gtk-tree-view>
) (enable bool
)Enables or disables rubber banding in tree-view. If the selection mode is
<gtk-selection-multiple>
, rubber banding will allow the user to select multiple rows by dragging the mouse.
- tree-view
- a
<gtk-tree-view>
- enable
- ‘
#t
’ to enable rubber bandingSince 2.10
<gtk-tree-view>
) ⇒ (ret bool
)Returns whether or not tree lines are drawn in tree-view.
- tree-view
- a
<gtk-tree-view>
.- ret
- ‘
#t
’ if tree lines are drawn in tree-view, ‘#f
’ otherwise.Since 2.10
<gtk-tree-view>
) (enabled bool
)Sets whether to draw lines interconnecting the expanders in tree-view. This does not have any visible effects for lists.
- tree-view
- a
<gtk-tree-view>
- enabled
- ‘
#t
’ to enable tree line drawing, ‘#f
’ otherwise.Since 2.10