class Gtk::TreeView

Overview

A widget for displaying both trees and lists

Widget that displays any object that implements the Gtk::TreeModel 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.

Coordinate systems in Gtk::TreeView API

Several different coordinate systems are exposed in the Gtk::TreeView API. These are:

Several functions are available for converting between the different coordinate systems. The most common translations are between widget and bin window coordinates and between bin window and tree coordinates. For the former you can use Gtk::TreeView#convert_widget_to_bin_window_coords (and vice versa), for the latter Gtk::TreeView#convert_bin_window_to_tree_coords (and vice versa).

Gtk::TreeView as Gtk::Buildable

The Gtk::TreeView implementation of the Gtk::Buildable interface accepts Gtk::TreeViewColumn objects as <child> elements and exposes the internal Gtk::TreeSelection in UI definitions.

An example of a UI definition fragment with Gtk::TreeView:

WARNING ⚠️ The following code is in xml ⚠️

<object class="Gtk::TreeView" id="treeview">
  <property name="model">liststore1</property>
  <child>
    <object class="Gtk::TreeViewColumn" id="test-column">
      <property name="title">Test</property>
      <child>
        <object class="Gtk::CellRendererText" id="test-renderer"/>
        <attributes>
          <attribute name="text">1</attribute>
        </attributes>
      </child>
    </object>
  </child>
  <child internal-child="selection">
    <object class="Gtk::TreeSelection" id="selection">
      <signal name="changed" handler="on_treeview_selection_changed"/>
    </object>
  </child>
</object>

CSS nodes

treeview.view
├── header
│ ├── button
│ │ ╰── [sort - indicator]
┊ ┊
│ ╰── button
│ ╰── [sort - indicator]
│
├── [rubberband]
╰── [dndtarget]

Gtk::TreeView has a main CSS node with name treeview and style class .view. It has a subnode with name header, which is the parent for all the column header widgets' CSS nodes.

Each column header consists of a button, which among other content, has a child with name sort-indicator, which carries the .ascending or .descending style classes when the column header should show a sort indicator. The CSS is expected to provide a suitable image using the -gtk-icon-source property.

For rubberband selection, a subnode with name rubberband is used.

For the drop target location during DND, a subnode with name dndtarget is used.

Included Modules

Defined in:

lib/gi-crystal/src/auto/gtk-4.0/tree_view.cr
lib/gtk4/src/bindings/gtk/tree_view.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gtk::Scrollable

border : Gtk::Border border, hadjustment : Gtk::Adjustment? hadjustment, hadjustment=(hadjustment : Gtk::Adjustment?) : Nil hadjustment=, hscroll_policy : Gtk::ScrollablePolicy hscroll_policy, hscroll_policy=(policy : Gtk::ScrollablePolicy) : Nil hscroll_policy=, to_unsafe to_unsafe, vadjustment : Gtk::Adjustment? vadjustment, vadjustment=(vadjustment : Gtk::Adjustment?) : Nil vadjustment=, vscroll_policy : Gtk::ScrollablePolicy vscroll_policy, vscroll_policy=(policy : Gtk::ScrollablePolicy) : Nil vscroll_policy=

Class methods inherited from module Gtk::Scrollable

g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Class methods inherited from module Gtk::ConstraintTarget

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Class methods inherited from module Gtk::Buildable

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Class methods inherited from module Gtk::Accessible

g_type : UInt64 g_type

Instance methods inherited from class Gtk::Widget

action_set_enabled(action_name : String, enabled : Bool) : Nil action_set_enabled, activate : Bool activate, activate_action(name : String, args : _?) : Bool activate_action, activate_default : Nil activate_default, add_controller(controller : Gtk::EventController) : Nil add_controller, add_css_class(css_class : String) : Nil add_css_class, add_mnemonic_label(label : Gtk::Widget) : Nil add_mnemonic_label, add_tick_callback(callback : Gtk::TickCallback) : UInt32 add_tick_callback, allocate(width : Int32, height : Int32, baseline : Int32, transform : Gsk::Transform?) : Nil allocate, allocated_baseline : Int32 allocated_baseline, allocated_height : Int32 allocated_height, allocated_width : Int32 allocated_width, allocation : Gdk::Rectangle allocation, ancestor(widget_type : UInt64) : Gtk::Widget? ancestor, can_focus : Bool can_focus, can_focus=(can_focus : Bool) : Nil can_focus=, can_focus? : Bool can_focus?, can_target : Bool can_target, can_target=(can_target : Bool) : Nil can_target=, can_target? : Bool can_target?, child_focus(direction : Gtk::DirectionType) : Bool child_focus, child_visible : Bool child_visible, child_visible=(child_visible : Bool) : Nil child_visible=, clipboard : Gdk::Clipboard clipboard, compute_bounds(target : Gtk::Widget) : Graphene::Rect compute_bounds, compute_expand(orientation : Gtk::Orientation) : Bool compute_expand, compute_point(target : Gtk::Widget, point : Graphene::Point) : Graphene::Point compute_point, compute_transform(target : Gtk::Widget) : Graphene::Matrix compute_transform, contains(x : Float64, y : Float64) : Bool contains, create_pango_context : Pango::Context create_pango_context, create_pango_layout(text : String?) : Pango::Layout create_pango_layout, css_classes : Enumerable(String) css_classes, css_classes=(classes : Enumerable(String)) : Nil css_classes=, css_name : String css_name, css_name=(value : String) : String css_name=, cursor : Gdk::Cursor? cursor, cursor=(cursor : Gdk::Cursor?) : Nil cursor=, cursor_from_name=(name : String?) : Nil cursor_from_name=, destroy_signal destroy_signal, direction : Gtk::TextDirection direction, direction=(dir : Gtk::TextDirection) : Nil direction=, direction_changed_signal direction_changed_signal, display : Gdk::Display display, dispose_template(widget_type : UInt64) : Nil dispose_template, drag_check_threshold(start_x : Int32, start_y : Int32, current_x : Int32, current_y : Int32) : Bool drag_check_threshold, error_bell : Nil error_bell, first_child : Gtk::Widget? first_child, focus_child : Gtk::Widget? focus_child, focus_child=(child : Gtk::Widget?) : Nil focus_child=, focus_on_click : Bool focus_on_click, focus_on_click=(focus_on_click : Bool) : Nil focus_on_click=, focus_on_click? : Bool focus_on_click?, focusable : Bool focusable, focusable=(focusable : Bool) : Nil focusable=, focusable? : Bool focusable?, font_map : Pango::FontMap? font_map, font_map=(font_map : Pango::FontMap?) : Nil font_map=, font_options : Cairo::FontOptions? font_options, font_options=(options : Cairo::FontOptions?) : Nil font_options=, frame_clock : Gdk::FrameClock? frame_clock, grab_focus : Bool grab_focus, halign : Gtk::Align halign, halign=(align : Gtk::Align) : Nil halign=, has_css_class(css_class : String) : Bool has_css_class, has_default : Bool has_default, has_default? : Bool has_default?, has_focus : Bool has_focus, has_focus? : Bool has_focus?, has_tooltip : Bool has_tooltip, has_tooltip=(has_tooltip : Bool) : Nil has_tooltip=, has_tooltip? : Bool has_tooltip?, has_visible_focus : Bool has_visible_focus, height : Int32 height, height_request : Int32 height_request, height_request=(value : Int32) : Int32 height_request=, hexpand : Bool hexpand, hexpand=(expand : Bool) : Nil hexpand=, hexpand? : Bool hexpand?, hexpand_set : Bool hexpand_set, hexpand_set=(set : Bool) : Nil hexpand_set=, hexpand_set? : Bool hexpand_set?, hide : Nil hide, hide_signal hide_signal, in_destruction : Bool in_destruction, init_template : Nil init_template, insert_action_group(name : String, group : Gio::ActionGroup?) : Nil insert_action_group, insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget?) : Nil insert_after, insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget?) : Nil insert_before, is_ancestor(ancestor : Gtk::Widget) : Bool is_ancestor, is_drawable : Bool is_drawable, is_focus : Bool is_focus, is_sensitive : Bool is_sensitive, is_visible : Bool is_visible, keynav_failed(direction : Gtk::DirectionType) : Bool keynav_failed, keynav_failed_signal keynav_failed_signal, last_child : Gtk::Widget? last_child, layout_manager : Gtk::LayoutManager? layout_manager, layout_manager=(layout_manager : Gtk::LayoutManager?) : Nil layout_manager=, list_mnemonic_labels : GLib::List list_mnemonic_labels, map : Nil map, map_signal map_signal, mapped : Bool mapped, margin_bottom : Int32 margin_bottom, margin_bottom=(margin : Int32) : Nil margin_bottom=, margin_end : Int32 margin_end, margin_end=(margin : Int32) : Nil margin_end=, margin_start : Int32 margin_start, margin_start=(margin : Int32) : Nil margin_start=, margin_top : Int32 margin_top, margin_top=(margin : Int32) : Nil margin_top=, measure(orientation : Gtk::Orientation, for_size : Int32) : Nil measure, mnemonic_activate(group_cycling : Bool) : Bool mnemonic_activate, mnemonic_activate_signal mnemonic_activate_signal, move_focus_signal move_focus_signal, name : String name, name=(name : String) : Nil name=, native : Gtk::Native? native, next_sibling : Gtk::Widget? next_sibling, observe_children : Gio::ListModel observe_children, observe_controllers : Gio::ListModel observe_controllers, opacity : Float64 opacity, opacity=(opacity : Float64) : Nil opacity=, overflow : Gtk::Overflow overflow, overflow=(overflow : Gtk::Overflow) : Nil overflow=, pango_context : Pango::Context pango_context, parent : Gtk::Widget? parent, parent=(parent : Gtk::Widget) : Nil parent=, pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget? pick, preferred_size : Gtk::Requisition preferred_size, prev_sibling : Gtk::Widget? prev_sibling, primary_clipboard : Gdk::Clipboard primary_clipboard, query_tooltip_signal query_tooltip_signal, queue_allocate : Nil queue_allocate, queue_draw : Nil queue_draw, queue_resize : Nil queue_resize, realize : Nil realize, realize_signal realize_signal, realized : Bool realized, receives_default : Bool receives_default, receives_default=(receives_default : Bool) : Nil receives_default=, receives_default? : Bool receives_default?, remove_controller(controller : Gtk::EventController) : Nil remove_controller, remove_css_class(css_class : String) : Nil remove_css_class, remove_mnemonic_label(label : Gtk::Widget) : Nil remove_mnemonic_label, remove_tick_callback(id : UInt32) : Nil remove_tick_callback, request_mode : Gtk::SizeRequestMode request_mode, root : Gtk::Root? root, scale_factor : Int32 scale_factor, sensitive : Bool sensitive, sensitive=(sensitive : Bool) : Nil sensitive=, sensitive? : Bool sensitive?, set_size_request(width : Int32, height : Int32) : Nil set_size_request, set_state_flags(flags : Gtk::StateFlags, clear : Bool) : Nil set_state_flags, settings : Gtk::Settings settings, should_layout : Bool should_layout, show : Nil show, show_signal show_signal, size(orientation : Gtk::Orientation) : Int32 size, size_allocate(allocation : Gdk::Rectangle, baseline : Int32) : Nil size_allocate, size_request : Nil size_request, snapshot_child(child : Gtk::Widget, snapshot : Gtk::Snapshot) : Nil snapshot_child, state_flags : Gtk::StateFlags state_flags, state_flags_changed_signal state_flags_changed_signal, style_context : Gtk::StyleContext style_context, tooltip_markup : String? tooltip_markup, tooltip_markup=(value : String) : String
tooltip_markup=(markup : String?) : Nil
tooltip_markup=
, tooltip_text : String? tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(text : String?) : Nil
tooltip_text=
, translate_coordinates(dest_widget : Gtk::Widget, src_x : Float64, src_y : Float64) : Bool translate_coordinates, trigger_tooltip_query : Nil trigger_tooltip_query, unmap : Nil unmap, unmap_signal unmap_signal, unparent : Nil unparent, unrealize : Nil unrealize, unrealize_signal unrealize_signal, unset_state_flags(flags : Gtk::StateFlags) : Nil unset_state_flags, valign : Gtk::Align valign, valign=(align : Gtk::Align) : Nil valign=, vexpand : Bool vexpand, vexpand=(expand : Bool) : Nil vexpand=, vexpand? : Bool vexpand?, vexpand_set : Bool vexpand_set, vexpand_set=(set : Bool) : Nil vexpand_set=, vexpand_set? : Bool vexpand_set?, visible : Bool visible, visible=(visible : Bool) : Nil visible=, visible? : Bool visible?, width : Int32 width, width_request : Int32 width_request, width_request=(value : Int32) : Int32 width_request=

Constructor methods inherited from class Gtk::Widget

new
new(*, accessible_role : Gtk::AccessibleRole? = nil, can_focus : Bool? = nil, can_target : Bool? = nil, css_classes : Enumerable(String)? = nil, css_name : String? = nil, cursor : Gdk::Cursor? = nil, focus_on_click : Bool? = nil, focusable : Bool? = nil, halign : Gtk::Align? = nil, has_default : Bool? = nil, has_focus : Bool? = nil, has_tooltip : Bool? = nil, height_request : Int32? = nil, hexpand : Bool? = nil, hexpand_set : Bool? = nil, layout_manager : Gtk::LayoutManager? = nil, margin_bottom : Int32? = nil, margin_end : Int32? = nil, margin_start : Int32? = nil, margin_top : Int32? = nil, name : String? = nil, opacity : Float64? = nil, overflow : Gtk::Overflow? = nil, parent : Gtk::Widget? = nil, receives_default : Bool? = nil, root : Gtk::Root? = nil, scale_factor : Int32? = nil, sensitive : Bool? = nil, tooltip_markup : String? = nil, tooltip_text : String? = nil, valign : Gtk::Align? = nil, vexpand : Bool? = nil, vexpand_set : Bool? = nil, visible : Bool? = nil, width_request : Int32? = nil)
new

Class methods inherited from class Gtk::Widget

default_direction : Gtk::TextDirection default_direction, default_direction=(dir : Gtk::TextDirection) : Nil default_direction=, g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Class methods inherited from module Gtk::ConstraintTarget

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String? buildable_id, to_unsafe to_unsafe

Class methods inherited from module Gtk::Buildable

g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Class methods inherited from module Gtk::Accessible

g_type : UInt64 g_type

Constructor methods inherited from class GObject::InitiallyUnowned

new new

Class methods inherited from class GObject::InitiallyUnowned

g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void)? data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void)? qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void)?) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void)? steal_data, steal_qdata(quark : UInt32) : Pointer(Void)? steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, cast?(obj : GObject::Object) : self? cast?, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

compat_control(what : UInt64, data : Pointer(Void)?) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Constructor Detail

def self.new : self #

Creates a new Gtk::TreeView widget.


def self.new(*, accessible_role : Gtk::AccessibleRole? = nil, activate_on_single_click : Bool? = nil, can_focus : Bool? = nil, can_target : Bool? = nil, css_classes : Enumerable(String)? = nil, css_name : String? = nil, cursor : Gdk::Cursor? = nil, enable_grid_lines : Gtk::TreeViewGridLines? = nil, enable_search : Bool? = nil, enable_tree_lines : Bool? = nil, expander_column : Gtk::TreeViewColumn? = nil, fixed_height_mode : Bool? = nil, focus_on_click : Bool? = nil, focusable : Bool? = nil, hadjustment : Gtk::Adjustment? = nil, halign : Gtk::Align? = nil, has_default : Bool? = nil, has_focus : Bool? = nil, has_tooltip : Bool? = nil, headers_clickable : Bool? = nil, headers_visible : Bool? = nil, height_request : Int32? = nil, hexpand : Bool? = nil, hexpand_set : Bool? = nil, hover_expand : Bool? = nil, hover_selection : Bool? = nil, hscroll_policy : Gtk::ScrollablePolicy? = nil, layout_manager : Gtk::LayoutManager? = nil, level_indentation : Int32? = nil, margin_bottom : Int32? = nil, margin_end : Int32? = nil, margin_start : Int32? = nil, margin_top : Int32? = nil, model : Gtk::TreeModel? = nil, name : String? = nil, opacity : Float64? = nil, overflow : Gtk::Overflow? = nil, parent : Gtk::Widget? = nil, receives_default : Bool? = nil, reorderable : Bool? = nil, root : Gtk::Root? = nil, rubber_banding : Bool? = nil, scale_factor : Int32? = nil, search_column : Int32? = nil, sensitive : Bool? = nil, show_expanders : Bool? = nil, tooltip_column : Int32? = nil, tooltip_markup : String? = nil, tooltip_text : String? = nil, vadjustment : Gtk::Adjustment? = nil, valign : Gtk::Align? = nil, vexpand : Bool? = nil, vexpand_set : Bool? = nil, visible : Bool? = nil, vscroll_policy : Gtk::ScrollablePolicy? = nil, width_request : Int32? = nil) #

def self.new_with_model(model : Gtk::TreeModel) : self #

Creates a new Gtk::TreeView widget with the model initialized to @model.


Class Method Detail

def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


Instance Method Detail

def activate_on_single_click : Bool #

Gets the setting set by gtk_tree_view_set_activate_on_single_click().


def activate_on_single_click=(single : Bool) : Nil #

Cause the Gtk::TreeView::row-activated signal to be emitted on a single click instead of a double click.


def activate_on_single_click? : Bool #

def append_column(column : Gtk::TreeViewColumn) : Int32 #

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.


def background_area(path : Gtk::TreePath?, column : Gtk::TreeViewColumn?) : Gdk::Rectangle #

Fills the bounding rectangle in bin_window coordinates for the cell at the row specified by @path and the column specified by @column. If @path is nil, or points to a node not found in the tree, the @y and @height fields of the rectangle will be filled with 0. If @column is nil, the @x and @width fields will be filled with 0. The returned rectangle is equivalent to the @background_area passed to gtk_cell_renderer_render(). These background areas tile to cover the entire bin window. Contrast with the @cell_area, returned by gtk_tree_view_get_cell_area(), which returns only the cell itself, excluding surrounding borders and the tree expander area.


def cell_area(path : Gtk::TreePath?, column : Gtk::TreeViewColumn?) : Gdk::Rectangle #

Fills the bounding rectangle in bin_window coordinates for the cell at the row specified by @path and the column specified by @column. If @path is nil, or points to a path not currently displayed, the @y and @height fields of the rectangle will be filled with 0. If @column is nil, the @x and @width fields will be filled with 0. The sum of all cell rects does not cover the entire tree; there are extra pixels in between rows, for example. The returned rectangle is equivalent to the @cell_area passed to gtk_cell_renderer_render(). This function is only valid if @tree_view is realized.


def collapse_all : Nil #

Recursively collapses all visible, expanded nodes in @tree_view.


def collapse_row(path : Gtk::TreePath) : Bool #

Collapses a row (hides its child rows, if they exist).


def column(n : Int32) : Gtk::TreeViewColumn? #

Gets the Gtk::TreeViewColumn at the given position in the #tree_view.


def column_drag_function=(func : Gtk::TreeViewColumnDropFunc?) : Nil #

Sets a user function for determining where a column may be dropped when dragged. This function is called on every column pair in turn at the beginning of a column drag to determine where a drop can take place. The arguments passed to @func are: the @tree_view, the Gtk::TreeViewColumn being dragged, the two Gtk::TreeViewColumns determining the drop spot, and @user_data. If either of the Gtk::TreeViewColumn arguments for the drop spot are nil, then they indicate an edge. If @func is set to be nil, then @tree_view reverts to the default behavior of allowing all columns to be dropped everywhere.


def columns : GLib::List #

Returns a GList of all the Gtk::TreeViewColumns currently in @tree_view. The returned list must be freed with g_list_free ().


def columns_autosize : Nil #

Resizes all columns to their optimal width. Only works after the treeview has been realized.


def columns_changed_signal #

def convert_bin_window_to_tree_coords(bx : Int32, by : Int32, tx : Int32, ty : Int32) : Nil #

Converts bin_window coordinates to coordinates for the tree (the full scrollable area of the tree).


def convert_bin_window_to_widget_coords(bx : Int32, by : Int32, wx : Int32, wy : Int32) : Nil #

Converts bin_window coordinates to widget relative coordinates.


def convert_tree_to_bin_window_coords(tx : Int32, ty : Int32, bx : Int32, by : Int32) : Nil #

Converts tree coordinates (coordinates in full scrollable area of the tree) to bin_window coordinates.


def convert_tree_to_widget_coords(tx : Int32, ty : Int32, wx : Int32, wy : Int32) : Nil #

Converts tree coordinates (coordinates in full scrollable area of the tree) to widget coordinates.


def convert_widget_to_bin_window_coords(wx : Int32, wy : Int32, bx : Int32, by : Int32) : Nil #

Converts widget coordinates to coordinates for the bin_window.


def convert_widget_to_tree_coords(wx : Int32, wy : Int32, tx : Int32, ty : Int32) : Nil #

Converts widget coordinates to coordinates for the tree (the full scrollable area of the tree).


def create_row_drag_icon(path : Gtk::TreePath) : Gdk::Paintable? #

Creates a cairo_::surface_t representation of the row at @path. This image is used for a drag icon.


def cursor : Nil #

Fills in @path and @focus_column with the current path and focus column. If the cursor isn’t currently set, then *@path will be nil. If no column currently has focus, then *@focus_column will be nil.

The returned Gtk::TreePath must be freed with gtk_tree_path_free() when you are done with it.


def cursor_changed_signal #

def dest_row_at_pos(drag_x : Int32, drag_y : Int32) : Bool #

Determines the destination row for a given position. @drag_x and @drag_y are expected to be in widget coordinates. This function is only meaningful if @tree_view is realized. Therefore this function will always return false if @tree_view is not realized or does not have a model.


def drag_dest_row : Nil #

Gets information about the row that is highlighted for feedback.


def enable_grid_lines : Gtk::TreeViewGridLines #

def enable_grid_lines=(value : Gtk::TreeViewGridLines) : Gtk::TreeViewGridLines #

def enable_model_drag_dest(formats : Gdk::ContentFormats, actions : Gdk::DragAction) : Nil #

Turns @tree_view into a drop destination for automatic DND. Calling this method sets Gtk::TreeView:reorderable to false.


def enable_model_drag_source(start_button_mask : Gdk::ModifierType, formats : Gdk::ContentFormats, actions : Gdk::DragAction) : Nil #

Turns @tree_view into a drag source for automatic DND. Calling this method sets Gtk::TreeView:reorderable to false.


def enable_search : Bool #

Returns whether or not the tree allows to start interactive searching by typing in text.


def enable_search=(enable_search : Bool) : Nil #

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 false, the user can still initiate a search using the “start-interactive-search” key binding.


def enable_search? : Bool #

def enable_tree_lines : Bool #

Returns whether or not tree lines are drawn in @tree_view.


def enable_tree_lines=(enabled : Bool) : Nil #

Sets whether to draw lines interconnecting the expanders in @tree_view. This does not have any visible effects for lists.


def enable_tree_lines? : Bool #

def expand_all : Nil #

Recursively expands all nodes in the @tree_view.


def expand_collapse_cursor_row_signal #

def expand_row(path : Gtk::TreePath, open_all : Bool) : Bool #

Opens the row so its children are visible.


def expand_to_path(path : Gtk::TreePath) : Nil #

Expands the row at @path. This will also expand all parent rows of @path as necessary.


def expander_column : Gtk::TreeViewColumn? #

Returns the column that is the current expander column, or nil if none has been set. This column has the expander arrow drawn next to it.


def expander_column=(column : Gtk::TreeViewColumn?) : Nil #

Sets the column to draw the expander arrow at. It must be in @tree_view. If @column is nil, 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.


def fixed_height_mode : Bool #

Returns whether fixed height mode is turned on for @tree_view.


def fixed_height_mode=(enable : Bool) : Nil #

Enables or disables the fixed height mode of @tree_view. Fixed height mode speeds up Gtk::TreeView 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.


def fixed_height_mode? : Bool #

def grid_lines : Gtk::TreeViewGridLines #

Returns which grid lines are enabled in @tree_view.


def grid_lines=(grid_lines : Gtk::TreeViewGridLines) : Nil #

Sets which grid lines to draw in @tree_view.


def headers_clickable : Bool #

Returns whether all header columns are clickable.


def headers_clickable=(setting : Bool) : Nil #

Allow the column title buttons to be clicked.


def headers_clickable? : Bool #

def headers_visible : Bool #

Returns true if the headers on the @tree_view are visible.


def headers_visible=(headers_visible : Bool) : Nil #

Sets the visibility state of the headers.


def headers_visible? : Bool #

def hover_expand : Bool #

Returns whether hover expansion mode is turned on for @tree_view.


def hover_expand=(expand : Bool) : Nil #

Enables or disables the hover expansion mode of @tree_view. Hover expansion makes rows expand or collapse if the pointer moves over them.


def hover_expand? : Bool #

def hover_selection : Bool #

Returns whether hover selection mode is turned on for @tree_view.


def hover_selection=(hover : Bool) : Nil #

Enables or 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.


def hover_selection? : Bool #

def insert_column(column : Gtk::TreeViewColumn, position : Int32) : Int32 #

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.


def insert_column_with_data_func(position : Int32, title : String, cell : Gtk::CellRenderer, func : Gtk::TreeCellDataFunc) : Int32 #

Convenience function that inserts a new column into the Gtk::TreeView with the given cell renderer and a Gtk::TreeCellDataFunc to set cell renderer attributes (normally using data from the model). See also gtk_tree_view_column_set_cell_data_func(), gtk_tree_view_column_pack_start(). If @tree_view has “fixed_height” mode enabled, then the new column will have its “sizing” property set to be GTK_TREE_VIEW_COLUMN_FIXED.


def is_blank_at_pos(x : Int32, y : Int32) : Bool #

Determine whether the point (@x, @y) in @tree_view is blank, that is no cell content nor an expander arrow is drawn at the location. If so, the location can be considered as the background. You might wish to take special action on clicks on the background, such as clearing a current selection, having a custom context menu or starting rubber banding.

The @x and @y coordinate that are provided must be relative to bin_window coordinates. Widget-relative coordinates must be converted using gtk_tree_view_convert_widget_to_bin_window_coords().

For converting widget coordinates (eg. the ones you get from Gtk::Widget::query-tooltip), please see gtk_tree_view_convert_widget_to_bin_window_coords().

The @path, @column, @cell_x and @cell_y arguments will be filled in likewise as for gtk_tree_view_get_path_at_pos(). Please see gtk_tree_view_get_path_at_pos() for more information.


def is_rubber_banding_active : Bool #

Returns whether a rubber banding operation is currently being done in @tree_view.


def level_indentation : Int32 #

Returns the amount, in pixels, of extra indentation for child levels in @tree_view.


def level_indentation=(indentation : Int32) : Nil #

Sets the amount of extra indentation for child levels to use in @tree_view in addition to the default indentation. The value should be specified in pixels, a value of 0 disables this feature and in this case only the default indentation will be used. This does not have any visible effects for lists.


def map_expanded_rows(func : Gtk::TreeViewMappingFunc, data : Pointer(Void)?) : Nil #

Calls @func on all expanded rows.


def model : Gtk::TreeModel? #

Returns the model the Gtk::TreeView is based on. Returns nil if the model is unset.


def model=(model : Gtk::TreeModel?) : Nil #

Sets the model for a Gtk::TreeView. If the @tree_view already has a model set, it will remove it before setting the new model. If @model is nil, then it will unset the old model.


def move_column_after(column : Gtk::TreeViewColumn, base_column : Gtk::TreeViewColumn?) : Nil #

Moves @column to be after to @base_column. If @base_column is nil, then @column is placed in the first position.


def move_cursor_signal #

def n_columns : UInt32 #

Queries the number of columns in the given @tree_view.


def path_at_pos(x : Int32, y : Int32) : Bool #

Finds the path at the point (@x, @y), relative to bin_window coordinates. That is, @x and @y are relative to an events coordinates. Widget-relative coordinates must be converted using gtk_tree_view_convert_widget_to_bin_window_coords(). It is primarily for things like popup menus. If @path is non-nil, then it will be filled with the Gtk::TreePath at that point. This path should be freed with gtk_tree_path_free(). If @column is non-nil, then it will be filled with the column at that point. @cell_x and @cell_y return the coordinates relative to the cell background (i.e. the @background_area passed to gtk_cell_renderer_render()). This function is only meaningful if @tree_view is realized. Therefore this function will always return false if @tree_view is not realized or does not have a model.

For converting widget coordinates (eg. the ones you get from Gtk::Widget::query-tooltip), please see gtk_tree_view_convert_widget_to_bin_window_coords().


def remove_column(column : Gtk::TreeViewColumn) : Int32 #

Removes @column from @tree_view.


def reorderable : Bool #

Retrieves whether the user can reorder the tree via drag-and-drop. See gtk_tree_view_set_reorderable().


def reorderable=(reorderable : Bool) : Nil #

This function is a convenience function to allow you to reorder models that support the Gtk::TreeDragSourceIface and the Gtk::TreeDragDestIface. Both Gtk::TreeStore and Gtk::ListStore support these. If @reorderable is true, 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 Gtk::TreeModel::row-inserted and Gtk::TreeModel::row-deleted signals. The reordering is implemented by setting up the tree view as a drag source and destination. Therefore, drag and drop can not be used in a reorderable view for any other purpose.

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.


def reorderable? : Bool #

def row_activated(path : Gtk::TreePath, column : Gtk::TreeViewColumn?) : Nil #

Activates the cell determined by @path and @column.


def row_activated_signal #

def row_collapsed_signal #

def row_expanded(path : Gtk::TreePath) : Bool #

Returns true if the node pointed to by @path is expanded in @tree_view.


def row_expanded_signal #

def row_separator_func=(func : Gtk::TreeViewRowSeparatorFunc?) : Nil #

Sets the row separator function, which is used to determine whether a row should be drawn as a separator. If the row separator function is nil, no separators are drawn. This is the default value.


def rubber_banding : 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.


def rubber_banding=(enable : Bool) : Nil #

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.


def rubber_banding? : Bool #

def scroll_to_cell(path : Gtk::TreePath?, column : Gtk::TreeViewColumn?, use_align : Bool, row_align : Float32, col_align : Float32) : Nil #

Moves the alignments of @tree_view to the position specified by @column and @path. If @column is nil, then no horizontal scrolling occurs. Likewise, if @path is nil no vertical scrolling occurs. At a minimum, one of @column or @path need to be non-nil. @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 false, 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.


def scroll_to_point(tree_x : Int32, tree_y : Int32) : Nil #

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 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.


def search_column : Int32 #

Gets the column searched on by the interactive search code.


def search_column=(column : Int32) : Nil #

Sets @column as the column where the interactive search code should search in for the current model.

If the search 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 current model. The search column is reset to -1 when the model is changed.


def search_entry : Gtk::Editable? #

Returns the Gtk::Entry which is currently in use as interactive search entry for @tree_view. In case the built-in entry is being used, nil will be returned.


def search_entry=(entry : Gtk::Editable?) : Nil #

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 nil for @entry will make the interactive search code use the built-in popup entry again.


def search_equal_func=(search_equal_func : Gtk::TreeViewSearchEqualFunc) : Nil #

Sets the compare function for the interactive search capabilities; note that somewhat like strcmp() returning 0 for equality Gtk::TreeViewSearchEqualFunc returns false on matches.


def select_all_signal #

def select_cursor_parent_signal #

def select_cursor_row_signal #

def selection : Gtk::TreeSelection #

Gets the Gtk::TreeSelection associated with @tree_view.


def set_cursor(path : Gtk::TreePath, focus_column : Gtk::TreeViewColumn?, start_editing : Bool) : Nil #

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 nil, then focus is given to the column specified by it. Additionally, if @focus_column is specified, and @start_editing is true, 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.

If @path is invalid for @model, the current cursor (if any) will be unset and the function will return without failing.


def set_cursor_on_cell(path : Gtk::TreePath, focus_column : Gtk::TreeViewColumn?, focus_cell : Gtk::CellRenderer?, start_editing : Bool) : Nil #

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 nil, then focus is given to the column specified by it. If @focus_column and @focus_cell are not nil, 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 true, 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.

If @path is invalid for @model, the current cursor (if any) will be unset and the function will return without failing.


def set_drag_dest_row(path : Gtk::TreePath?, pos : Gtk::TreeViewDropPosition) : Nil #

Sets the row that is highlighted for feedback. If @path is nil, an existing highlight is removed.


def set_tooltip_cell(tooltip : Gtk::Tooltip, path : Gtk::TreePath?, column : Gtk::TreeViewColumn?, cell : Gtk::CellRenderer?) : Nil #

Sets the tip area of @tooltip to the area @path, @column and @cell have in common. For example if @path is nil and @column is set, the tip area will be set to the full area covered by @column. See also gtk_tooltip_set_tip_area().

Note that if @path is not specified and @cell is set and part of a column containing the expander, the tooltip might not show and hide at the correct position. In such cases @path must be set to the current node under the mouse cursor for this function to operate correctly.

See also gtk_tree_view_set_tooltip_column() for a simpler alternative.


def set_tooltip_row(tooltip : Gtk::Tooltip, path : Gtk::TreePath) : Nil #

Sets the tip area of @tooltip to be the area covered by the row at @path. See also gtk_tree_view_set_tooltip_column() for a simpler alternative. See also gtk_tooltip_set_tip_area().


def show_expanders : Bool #

Returns whether or not expanders are drawn in @tree_view.


def show_expanders=(enabled : Bool) : Nil #

Sets whether to draw and enable expanders and indent child rows in @tree_view. When disabled there will be no expanders visible in trees and there will be no way to expand and collapse rows by default. Also note that hiding the expanders will disable the default indentation. You can set a custom indentation in this case using gtk_tree_view_set_level_indentation(). This does not have any visible effects for lists.


def show_expanders? : Bool #

def start_interactive_search_signal #

def test_collapse_row_signal #

def test_expand_row_signal #

def toggle_cursor_row_signal #

def tooltip_column : Int32 #

Returns the column of @tree_view’s model which is being used for displaying tooltips on @tree_view’s rows.


def tooltip_column=(column : Int32) : Nil #

If you only plan to have simple (text-only) tooltips on full rows, you can use this function to have Gtk::TreeView handle these automatically for you. @column should be set to the column in @tree_view’s model containing the tooltip texts, or -1 to disable this feature.

When enabled, Gtk::Widget:has-tooltip will be set to true and @tree_view will connect a Gtk::Widget::query-tooltip signal handler.

Note that the signal handler sets the text with gtk_tooltip_set_markup(), so &, <, etc have to be escaped in the text.


def tooltip_context(x : Int32, y : Int32, keyboard_tip : Bool) : Gtk::TreeIter #

This function is supposed to be used in a ::query-tooltip signal handler for Gtk::TreeView. The @x, @y and @keyboard_tip values which are received in the signal handler, should be passed to this function without modification.

The return value indicates whether there is a tree view row at the given coordinates (true) or not (false) for mouse tooltips. For keyboard tooltips the row returned will be the cursor row. When true, then any of @model, @path and @iter which have been provided will be set to point to that row and the corresponding model. @x and @y will always be converted to be relative to @tree_view’s bin_window if @keyboard_tooltip is false.


def unselect_all_signal #

def unset_rows_drag_dest : Nil #

Undoes the effect of gtk_tree_view_enable_model_drag_dest(). Calling this method sets Gtk::TreeView:reorderable to false.


def unset_rows_drag_source : Nil #

Undoes the effect of gtk_tree_view_enable_model_drag_source(). Calling this method sets Gtk::TreeView:reorderable to false.


def visible_range : Bool #

Sets @start_path and @end_path to be the first and last visible path. Note that there may be invisible paths in between.

The paths should be freed with gtk_tree_path_free() after use.


def visible_rect : Gdk::Rectangle #

Fills @visible_rect with the currently-visible region of the buffer, in tree coordinates. Convert to bin_window coordinates with gtk_tree_view_convert_tree_to_bin_window_coords(). Tree coordinates start at 0,0 for row 0 of the tree, and cover the entire scrollable area of the tree.