Gtk.TreeView

const Gtk = imports.gi.Gtk;

let tree_view = new Gtk.TreeView({
    activate_on_single_click: value,
    enable_grid_lines: value,
    enable_search: value,
    enable_tree_lines: value,
    expander_column: value,
    fixed_height_mode: value,
    headers_clickable: value,
    headers_visible: value,
    hover_expand: value,
    hover_selection: value,
    level_indentation: value,
    model: value,
    reorderable: value,
    rubber_banding: value,
    rules_hint: value,
    search_column: value,
    show_expanders: value,
    tooltip_column: value,
});
  

Widget that displays any object that implements the Gtk.TreeModel interface.

Please refer to the <link linkend="TreeWidget">tree widget conceptual overview</link> for an overview of all the objects and data types related to the tree widget and how they work together.

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

<inlinegraphic fileref="tree-view-coordinates.png" format="PNG"></inlinegraphic> <variablelist><title>Coordinate systems in GtkTreeView API</title> <varlistentry><term>Widget coordinates</term> <listitem> <para> Coordinates relative to the widget (usually <literal>widget->window</literal>). </para> </listitem> </varlistentry> <varlistentry><term>Bin window coordinates</term> <listitem> <para> Coordinates relative to the window that GtkTreeView renders to. </para> </listitem> </varlistentry> <varlistentry><term>Tree coordinates</term> <listitem> <para> Coordinates relative to the entire scrollable area of GtkTreeView. These coordinates start at (0, 0) for row 0 of the tree. </para> </listitem> </varlistentry> </variablelist>

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.convert_widget_to_bin_window_coords (and vice versa), for the latter Gtk.convert_bin_window_to_tree_coords (and vice versa).

<refsect2 id="GtkTreeView-BUILDER-UI"> <title>GtkTreeView as GtkBuildable</title> The GtkTreeView implementation of the GtkBuildable interface accepts Gtk.TreeViewColumn objects as &lt;child&gt; elements and exposes the internal Gtk.TreeSelection in UI definitions. <example> <title>A UI definition fragment with GtkTreeView</title> <programlisting><![CDATA[ <object class="GtkTreeView" id="treeview"> <property name="model">liststore1</property> <child> <object class="GtkTreeViewColumn" id="test-column"> <property name="title">Test</property> <child> <object class="GtkCellRendererText" id="test-renderer"/> <attributes> <attribute name="text">1</attribute> </attributes> </child> </object> </child> <child internal-child="selection"> <object class="GtkTreeSelection" id="selection"> <signal name="changed" handler="on_treeview_selection_changed"/> </object> </child> </object> ]]></programlisting> </example> </refsect2>

Hierarchy

  • GObject.Object
    • GObject.InitiallyUnowned
      • Gtk.Widget
        • Gtk.Container
          • Gtk.TreeView