Toc Gallery Index Tree Gtk.Tree_View

Screenshot

No screeshot

Hierarchy

Description

See extended documentation in Gtk.Tree_View_Column and Gtk.Tree_Store.

Types

  • type Gtk_Tree_View is access all Gtk_Tree_View_Record'Class;
  • type Gtk_Tree_View_Column_Drop_Func is access function (Tree_View : System.Address; -- Gtk_Tree_View Column : System.Address; -- Gtk_Tree_View_Column Prev_Column : System.Address; -- Gtk_Tree_View_Column Next_Column : System.Address; -- Gtk_Tree_View_Column User_Data : System.Address) return Gboolean;
  • type Gtk_Tree_View_Drop_Position is (Tree_View_Drop_Before, Tree_View_Drop_After, Tree_View_Drop_Into_Or_Before, Tree_View_Drop_Into_Or_After);
  • type Gtk_Tree_View_Mapping_Func is access procedure (Tree_View : System.Address; -- Gtk_Tree_View Path : Gtk.Tree_Model.Gtk_Tree_Path; User_Data : System.Address);
  • type Gtk_Tree_View_Record is new Gtk.Container.Gtk_Container_Record with private;
  • type Gtk_Tree_View_Row_Separator_Func is access function (Model : System.Address; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; User_Data : System.Address) return Gboolean;
  • type Gtk_Tree_View_Search_Equal_Func is access function (Model : System.Address; Column : Gint; Key : Interfaces.C.Strings.chars_ptr; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; User_Data : System.Address) return Gboolean;

Subprograms

  • procedure Gtk_New (Widget : out Gtk_Tree_View);
    procedure Initialize (Widget : access Gtk_Tree_View_Record'Class);
    Creates or initializes a new tree view
  • function Get_Type return Gtk.Gtk_Type;
    Return the internal value associated with this widget.
  • procedure Gtk_New (Widget : out Gtk_Tree_View; Model : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class);
  • procedure Initialize (Widget : access Gtk_Tree_View_Record'Class; Model : access Gtk.Tree_Model.Gtk_Tree_Model_Record'Class);
    Internal initialization function. See the section "Creating your own widgets" in the documentation.
  • procedure Set_Model (Tree_View : access Gtk_Tree_View_Record; Model : Gtk.Tree_Model.Gtk_Tree_Model);
    function Get_Model (Tree_View : access Gtk_Tree_View_Record) return Gtk.Tree_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 Null, then it will unset the old model.
  • function Get_Selection (Tree_View : access Gtk_Tree_View_Record) return Gtk.Tree_Selection.Gtk_Tree_Selection;
    Gets the Gtk_Tree_Selection associated with Tree_View.
  • procedure Set_Hadjustment (Tree_View : access Gtk_Tree_View_Record; Adjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class);
    function Get_Hadjustment (Tree_View : access Gtk_Tree_View_Record) return Gtk.Adjustment.Gtk_Adjustment;
    Sets or gets the Gtk_Adjustment for the current horizontal aspect.
  • procedure Set_Vadjustment (Tree_View : access Gtk_Tree_View_Record; Adjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class);
    function Get_Vadjustment (Tree_View : access Gtk_Tree_View_Record) return Gtk.Adjustment.Gtk_Adjustment;
    Sets or Gets the Gtk_Adjustment currently being used for the vertical aspect.
  • Column and header operations

  • procedure Set_Headers_Visible (Tree_View : access Gtk_Tree_View_Record; Headers_Visible : Boolean);
    function Get_Headers_Visible (Tree_View : access Gtk_Tree_View_Record) return Boolean;
    Returns True if the headers on the Tree_View are visible.
  • procedure Columns_Autosize (Tree_View : access Gtk_Tree_View_Record);
    Resizes all columns to their optimal width.
  • procedure Set_Headers_Clickable (Tree_View : access Gtk_Tree_View_Record; Setting : Boolean);
    Allow the column title buttons to be clicked.
  • procedure Set_Rules_Hint (Tree_View : access Gtk_Tree_View_Record; Setting : Boolean);
    function Get_Rules_Hint (Tree_View : access Gtk_Tree_View_Record) return Boolean;
    This function tells GtkAda that the user interface for your application requires users to read across tree rows and associate cells with one another. By default, GtkAda 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).
  • Public Column functions

  • function Append_Column (Tree_View : access Gtk_Tree_View_Record; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column) return Gint;
    Append Column to the list of columns.
  • function Remove_Column (Tree_View : access Gtk_Tree_View_Record; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column) return Gint;
    Remove Column from Tree_View. Return value: The number of columns in Tree_View after removing.
  • function Insert_Column (Tree_View : access Gtk_Tree_View_Record; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column; Position : Gint := -1) return Gint;
    Insert the Column into the Tree_View at Position. If Position is -1, then the column is inserted at the end. Return the number of columns in Tree_View after insertion.
  • function Insert_Column_With_Data_Func (Tree_View : access Gtk_Tree_View_Record; Position : Gint; Title : String; Cell : access Gtk.Cell_Renderer.Gtk_Cell_Renderer_Record'Class; Func : Gtk.Tree_View_Column.Cell_Data_Func) return Gint;
    Convenience function that inserts a new column into the tree view with the given cell renderer and a function to set cell renderer attributes (normally using data from the model). See also Gtk.Tree_View_Column.Set_Cell_Data_Func and Gtk.Tree_View_Column.Pack_Start. If Tree_View has "fixed_height" mode enabled, then Column must have its "sizing" property set to be TREE_VIEW_COLUMN_FIXED.

    Return value: number of columns in the tree view post-insert

  • function Get_Column (Tree_View : access Gtk_Tree_View_Record; N : Gint) return Gtk.Tree_View_Column.Gtk_Tree_View_Column;
    Gets the Gtk_Tree_ViewColumn at the given position in the Tree_View.
  • function Get_Columns (Tree_View : access Gtk_Tree_View_Record) return Gtk.Tree_View_Column.Column_List.Glist;
    Return a list of all the Gtk_Tree_View_Column s currently in Tree_View. The returned list must be freed with g_list_free ().
  • procedure Move_Column_After (Tree_View : access Gtk_Tree_View_Record; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column; Base_Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column);
    Move Column to be after to Base_Column. If Base_Column is Null, then Column is placed in the first position.
  • procedure Set_Expander_Column (Tree_View : access Gtk_Tree_View_Record; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column);
    Set the column to draw the expander arrow at. It must be in Tree_View. If Column is Null, then the expander arrow is fixed at the first column.
  • function Get_Expander_Column (Tree_View : access Gtk_Tree_View_Record) return Gtk.Tree_View_Column.Gtk_Tree_View_Column;
    Return the column that is the current expander column. This column has the expander arrow drawn next to it.
  • procedure Scroll_To_Point (Tree_View : access Gtk_Tree_View_Record; Tree_X : Gint; Tree_Y : Gint);
    Scroll 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 Scroll_To_Cell.
  • procedure Scroll_To_Cell (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column; Use_Align : Boolean; Row_Align : Gfloat; Col_Align : Gfloat);
    Move the alignments of Tree_View to the position specified by Column and Path. If Column is Null, then no horizontal scrolling occurs. Likewise, if Path is Null no vertical scrolling occurs. 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.
  • procedure Get_Visible_Range (Tree_View : access Gtk_Tree_View_Record; Start_Path : out Gtk.Tree_Model.Gtk_Tree_Path; End_Path : out Gtk.Tree_Model.Gtk_Tree_Path; Success : out Boolean);
    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 Free after use.
  • procedure Row_Activated (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column);
    Activate the cell determined by Path and Column.
  • procedure Expand_All (Tree_View : access Gtk_Tree_View_Record);
    Recursively expand all nodes in the Tree_View.
  • procedure Collapse_All (Tree_View : access Gtk_Tree_View_Record);
    Recursively collapse all visible, expanded nodes in Tree_View.
  • function Expand_Row (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path; Open_All : Boolean) return Boolean;
    Open the row so its children are visible Return True if the row existed and had children
  • procedure Expand_To_Path (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path);
    Expands the row at Path. This will also expand all parent rows of Path as necessary.
  • procedure Map_Expanded_Rows (Tree_View : access Gtk_Tree_View_Record; Func : Gtk_Tree_View_Mapping_Func; Data : System.Address);
    Calls Func on all expanded rows.
  • function Collapse_Row (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean;
    Collapse a row (hides its child rows, if they exist.)
  • function Row_Expanded (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path) return Boolean;
    Return True if the node pointed to by Path is expanded in Tree_View.
  • procedure Set_Fixed_Height_Mode (Tree_View : access Gtk_Tree_View_Record; Enable : Boolean);
    function Get_Fixed_Height_Mode (Tree_View : access Gtk_Tree_View_Record) return Boolean;
    Enables or disables the fixed height mode of tree_view. Fixed height mode speeds up the rendering 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 TREE_VIEW_COLUMN_FIXED.
  • procedure Set_Hover_Expand (Tree_View : access Gtk_Tree_View_Record; Expand : Boolean);
    function Get_Hover_Expand (Tree_View : access Gtk_Tree_View_Record) return Boolean;
    Enables of disables the hover expansion mode of Tree_view. Hover expansion makes rows expand or collaps if the pointer moves over them.
  • procedure Set_Hover_Selection (Tree_View : access Gtk_Tree_View_Record; Hover : Boolean);
    function Get_Hover_Selection (Tree_View : access Gtk_Tree_View_Record) return Boolean;
    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 SELECTION_SINGLE and SELECTION_BROWSE.
  • procedure Set_Cursor (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path; Focus_Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column; Start_Editing : Boolean);
    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 Column is not Null, then focus is given to that column. Additionally, if Column is specified, and Start_Editing is True, then editing should be started in the specified cell. Keyboard focus is given to the widget after this is called. Please note that editing can only happen when the widget is realized.
  • procedure Get_Cursor (Tree_View : access Gtk_Tree_View_Record; Path : out Gtk.Tree_Model.Gtk_Tree_Path; Focus_Column : out Gtk.Tree_View_Column.Gtk_Tree_View_Column);
    Fills in Path and Focus_Column with the current path and focus column. If the cursor isn't currently set, then *path will be Null. If no column currently has focus, then *focus_column will be Null.
  • procedure Set_Cursor_On_Cell (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path; Focus_Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column := null; Focus_Cell : Gtk.Cell_Renderer.Gtk_Cell_Renderer := null; Start_Editing : Boolean);
    Sets the current keyboard focus to be atPath, and selects it. This is useful when you want to focus the user's attention on a particular row. If Focus_Column is not null, then focus is given to the column specified by it. If Focus_Column and Focus_Cell are not null, 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.
  • function Get_Bin_Window (Tree_View : access Gtk_Tree_View_Record) return Gdk.Window.Gdk_Window;
    Return the window that Tree_View renders to. This is used primarily to compare to Get_Window (Event) to confirm that the event on Tree_View is on the right window.
  • procedure Set_Row_Separator_Func (Tree_View : access Gtk_Tree_View_Record; Func : Gtk_Tree_View_Row_Separator_Func; Data : System.Address; Destroy : Glib.G_Destroy_Notify_Address := null);
    function Get_Row_Separator_Func (Tree_View : access Gtk_Tree_View_Record) return Gtk_Tree_View_Row_Separator_Func;
    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 NULL, no separators are drawn. This is the default value.
  • procedure Get_Path_At_Pos (Tree_View : access Gtk_Tree_View_Record; X : Gint; Y : Gint; Path : out Gtk.Tree_Model.Gtk_Tree_Path; Column : out Gtk.Tree_View_Column.Gtk_Tree_View_Column; Cell_X : out Gint; Cell_Y : out Gint; Row_Found : out Boolean);
    Find the path at the point (X, Y) relative to Window. If Window is null, then the point is found relative to the widget coordinates. This function is expected to be called after an event. It is primarily for things like popup menus. Path will be filled with the Gtk_Tree_Path at that point. It should be freed with Tree_Path_Free. Column 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 only works if Tree_View is realized. Row_Found is set to True if a row exists at that coordinate.
  • procedure Get_Cell_Area (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column; Rect : out Gdk.Rectangle.Gdk_Rectangle);
    Fills the bounding rectangle in tree window coordinates for the cell at the row specified by Path and the column specified by Column. If Path is Null, or points to a path not currently displayed, the Y and Height fields of the rectangle will be filled with 0. If Column is Null, 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.
  • procedure Get_Background_Area (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column; Rect : out Gdk.Rectangle.Gdk_Rectangle);
    Fills the bounding rectangle in tree window coordinates for the cell at the row specified by Path and the column specified by Column. If Path is Null, 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 Null, 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 tree window (except for the area used for header buttons). 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.
  • procedure Get_Visible_Rect (Tree_View : access Gtk_Tree_View_Record; Visible_Rect : out Gdk.Rectangle.Gdk_Rectangle);
    Fills Visible_Rect with the currently-visible region of the buffer, in tree coordinates. Convert to widget coordinates with gtk_tree_view_tree_to_widget_coords(). Tree coordinates start at 0,0 for row 0 of the tree, and cover the entire scrollable area of the tree.
  • procedure Widget_To_Tree_Coords (Tree_View : access Gtk_Tree_View_Record; Wx : Gint; Wy : Gint; Tx : out Gint; Ty : out Gint);
    Converts widget coordinates to coordinates for the tree window (the full scrollable area of the tree).
  • procedure Tree_To_Widget_Coords (Tree_View : access Gtk_Tree_View_Record; Tx : Gint; Ty : Gint; Wx : out Gint; Wy : out Gint);
    Converts tree coordinates (coordinates in full scrollable area of the tree) to widget coordinates.
  • Searching

  • procedure Set_Enable_Search (Tree_View : access Gtk_Tree_View_Record; Enable_Search : Boolean);
    function Get_Enable_Search (Tree_View : access Gtk_Tree_View_Record) return Boolean;
    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.
  • procedure Set_Search_Column (Tree_View : access Gtk_Tree_View_Record; Column : Gint);
    function Get_Search_Column (Tree_View : access Gtk_Tree_View_Record) return Gint;
    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.
  • procedure Set_Search_Equal_Func (Tree_View : access Gtk_Tree_View_Record; Search_Equal_Func : Gtk_Tree_View_Search_Equal_Func; Search_User_Data : System.Address; Search_Destroy : G_Destroy_Notify_Address := null);
    function Get_Search_Equal_Func (Tree_View : access Gtk_Tree_View_Record) return Gtk_Tree_View_Search_Equal_Func;
    Sets the compare function for the interactive search capabilities
  • Columns reordering

  • procedure Set_Reorderable (Tree_View : access Gtk_Tree_View_Record; Reorderable : Boolean);
    function Get_Reorderable (Tree_View : access Gtk_Tree_View_Record) return Boolean;
    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 True, then the user can reorder the model by dragging and dropping columns. The developer can listen to these changes by connecting to the model's signals. This function does not give you any degree of control over the order - any reorderering is allowed. If more control is needed, you should probably handle drag and drop manually.
  • procedure Set_Column_Drag_Function (Tree_View : access Gtk_Tree_View_Record; Func : Gtk_Tree_View_Column_Drop_Func; User_Data : System.Address; Destroy : Glib.G_Destroy_Notify_Address);
    Sets a user function for determining where a column may be dropped. If Func is set to be %NULL, then Tree_View reverts to the default behavior of allowing all columns to be dropped everywhere.
  • Drag-and-drop

  • procedure Enable_Model_Drag_Dest (Tree_View : access Gtk_Tree_View_Record; Targets : Gtk.Selection.Target_Entry_Array; Actions : Gdk.Dnd.Drag_Action);
    Turns Tree_View into a drop destination for automatic drag-and-drop. Targets is the table of targets that the drag will support. Actions is a bitmask of possible actions for a drag to this widget.
  • procedure Enable_Model_Drag_Source (Tree_View : access Gtk_Tree_View_Record; Start_Button_Mask : Gdk.Types.Gdk_Modifier_Type; Targets : Gtk.Selection.Target_Entry_Array; Actions : Gdk.Dnd.Drag_Action);
    Turns Tree_View into a drag source for automatic DND. Targets is the list of targets that the drag will support. Actions is the bitmask of possible actions for a drag from this widget. Start_Button_Mask is the mask of allowed buttons to start the drag. You need to connect to the usual dnd signals (see gtk-dnd.ads) to provide the actual data upon request.
  • procedure Unset_Rows_Drag_Source (Tree_View : access Gtk_Tree_View_Record);
    Undoes the effect of Enable_Model_Drag_Source.
  • procedure Unset_Rows_Drag_Dest (Tree_View : access Gtk_Tree_View_Record);
    Undoes the effect of Enable_Model_Drag_Dest.
  • function Create_Row_Drag_Icon (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path) return Gdk.Pixmap.Gdk_Pixmap;
    Creates a Gdk_Pixmap representation of the row at path. This image is used for a drag icon. The returned pixmap must be freed by the user
  • procedure Get_Dest_Row_At_Pos (Tree_View : access Gtk_Tree_View_Record; Drag_X : Gint; Drag_Y : Gint; Path : out Gtk.Tree_Model.Gtk_Tree_Path; Pos : out Gtk_Tree_View_Drop_Position; Success : out Boolean);
    Determines the destination row for a given position. (Drag_X, Drag_Y) is the position to determine the destination row for.
  • procedure Set_Drag_Dest_Row (Tree_View : access Gtk_Tree_View_Record; Path : Gtk.Tree_Model.Gtk_Tree_Path; Pos : Gtk_Tree_View_Drop_Position);
    procedure Get_Drag_Dest_Row (Tree_View : access Gtk_Tree_View_Record; Path : out Gtk.Tree_Model.Gtk_Tree_Path; Pos : out Gtk_Tree_View_Drop_Position);
    Sets or gets information about the row that is highlighted for feedback.

Signals

  • columns_changed
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class);
  • expand_collapse_cursor_row
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class; Logical : Boolean; Expand : Boolean; Open_All : Boolean);
  • move_cursor
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class; Step : Gtk_Movement_Step; Count : Gint);
  • row_activated
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class; Path : Gtk.Tree_Model.Gtk_Tree_Path; Column : Gtk.Tree_View_Column.Gtk_Tree_View_Column);
  • row_collapsed
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class; Iter : access Gtk.Tree_Iter.Gtk_Tree_Iter_Record'Class; Path : Gtk.Tree_Model.Gtk_Tree_Path);
  • row_expanded
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class; Iter : access Gtk.Tree_Iter.Gtk_Tree_Iter_Record'Class; Path : Gtk.Tree_Model.Gtk_Tree_Path);
  • select_all
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class);
  • select_cursor_parent
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class);
  • select_cursor_row
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class; Start_Editing : Boolean);
  • set_scroll_adjustments
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class; Hadjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class; Vadjustment : access Gtk.Adjustment.Gtk_Adjustment_Record'Class);
  • start_interactive_search
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class);
  • test_collapse_row
    function Handler (Widget : access Gtk_Tree_View_Record'Class; Iter : access Gtk.Tree_Iter.Gtk_Tree_Iter_Record'Class; Path : Gtk.Tree_Model.Gtk_Tree_Path) return Gboolean;
  • test_expand_row
    function Handler (Widget : access Gtk_Tree_View_Record'Class; Iter : access Gtk.Tree_Iter.Gtk_Tree_Iter_Record'Class; Path : Gtk.Tree_Model.Gtk_Tree_Path) return Gboolean;
  • toggle_cursor_row
    procedure Handler (Widget : access Gtk_Tree_View_Record'Class);

Properties

  • Enable_Search_Property
    Boolean
    View allows user to search through columns interactively
  • Expander_Column_Property
    Object
    Set the column for the expander column
  • Fixed_Height_Mode_Property
    Boolean
    Speeds up GtkTreeView by assuming that all rows have the same
  • Hadjustment_Property
    Object
    Horizontal Adjustment for the widget
  • Headers_Clickable_Property
    Boolean
    Column headers respond to click events
  • Headers_Visible_Property
    Boolean
    Show the column header buttons
  • Hover_Expand_Property
    Boolean
    Whether rows should be expanded/collapsed when the pointer moves
  • Hover_Selection_Property
    Boolean
    Whether the selection should follow the pointer
  • Model_Property
    Object
    The model for the tree view
  • Reorderable_Property
    Boolean
    View is reorderable
  • Rules_Hint_Property
    Boolean
    Set a hint to the theme engine to draw rows in alternating colors
  • Search_Column_Property
    Int
    Model column to search through when searching through code
  • Vadjustment_Property
    Object
    Vertical Adjustment for the widget

Style Properties

  • Allow_Rules_Property
    Boolean
    Allow drawing of alternating color rows
  • Even_Row_Color_Property
    Boxed
    Color to use for even rows
  • Expander_Size_Property
    Int
    Size of the expander arrow
  • Horizontal_Separator_Property
    Int
    Horizontal space between cells. Must be an even number
  • Indent_Expanders_Property
    Boolean
    Make the expanders indented
  • Odd_Row_Color_Property
    Boxed
    Color to use for odd rows
  • Vertical_Separator_Property
    Int
    Vertical space between cells. Must be an even number

Testgtk source code

This code is part of testgtk, a demo application packaged with GtkAda. Testgtk demonstrates the various widgets of GtkAda
----------------------------------------------------------------------- -- GtkAda - Ada95 binding for the Gimp Toolkit -- -- -- -- Copyright (C) 2003 -- -- Emmanuel Briot, Joel Brobecker and Arnaud Charlet -- -- Copyright (C) 2004-2006 AdaCore -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- -- -- -- -- -- -- ----------------------------------------------------------------------- with Glib; use Glib; with Glib.Object; use Glib.Object; with Glib.Values; use Glib.Values; with Gtk; use Gtk; with Gtk.Enums; use Gtk.Enums; with Gtk.Scrolled_Window; use Gtk.Scrolled_Window; with Gtk.Cell_Renderer_Text; use Gtk.Cell_Renderer_Text; with Gtk.Cell_Renderer_Toggle; use Gtk.Cell_Renderer_Toggle; with Gtk.Tree_View; use Gtk.Tree_View; with Gtk.Tree_Model; use Gtk.Tree_Model; with Gtk.Tree_Sortable; use Gtk.Tree_Sortable; with Gtk.Tree_Store; use Gtk.Tree_Store; with Gtk.Tree_View_Column; use Gtk.Tree_View_Column; with Gtk.Frame; use Gtk.Frame; with Gtk.Handlers; use Gtk.Handlers; package body Create_Tree_View is package Object_Callback is new Gtk.Handlers.Callback (GObject_Record); Text_Column : constant := 0; Strike_Column : constant := 1; Editable_Column : constant := 2; Active_Column : constant := 3; Foreground_Column : constant := 4; function Add_Line (Model : access Gtk_Tree_Store_Record'Class; Text : String; Striken : Boolean := False; Editable : Boolean := False; Active : Boolean := False; Parent : Gtk_Tree_Iter := Null_Iter) return Gtk_Tree_Iter; -- Insert a new line in the tree, as a child of Parent (or as a root node -- if Parent is Null_Iter. procedure Edited_Callback (Model : access GObject_Record'Class; Params : Glib.Values.GValues); -- Called when the user clicks on a toggle button. This is used to reflect -- (or not) the change in the model. procedure Text_Edited_Callback (Model : access GObject_Record'Class; Params : Glib.Values.GValues); -- Same when a text cell is edited function Custom_Sort (Model : access Gtk_Tree_Model_Record'Class; A, B : Gtk_Tree_Iter) return Gint; -- Our own customer sort function for the tree ---------- -- Help -- ---------- function Help return String is begin return "A @bGtk_Tree_View@B is a widget used to display a number of" & " lines, organized either as a simple list or into a tree" & " hierarchy." & ASCII.LF & "Each line can contain multiple resizable column, each of which" & " can contain pixmaps, texts, or both. The columns can be sorted" & " interactively by the user by clicking on the column header." & ASCII.LF & "Like the @bGtk_Text_View@B, this widget is based on the model-" & "view-controller paradigm: data is stored in a non graphical" & " object (a @bGtk_Tree_Model@B), which is then associated with" & " one or many view. The model provides subprograms for inserting" & " or removing lines, as well as for traversing an existing tree." & ASCII.LF & "Cells in the tree can be defined as editable, as shown in this" & " example: in this case, the user needs to double click on the" & " cell, and an entry widget is then displayed in which the text" & " can be modified" & ASCII.LF & "The first column is sortable in this example. By default, gtk+" & " would use an alphabetical order on a text column, but here we have" & " defined our own sorting algorithm (striken first, then others," & " and alphabetical within)"; end Help; ----------------- -- Custom_Sort -- ----------------- function Custom_Sort (Model : access Gtk_Tree_Model_Record'Class; A, B : Gtk_Tree_Iter) return Gint is Text_A : constant String := Get_String (Model, A, Text_Column); Text_B : constant String := Get_String (Model, B, Text_Column); A_Not_Striken : constant Boolean := Text_A'Length > 11 and then Text_A (Text_A'Last - 10 .. Text_A'Last) = "not striken"; B_Not_Striken : constant Boolean := Text_B'Length > 11 and then Text_B (Text_B'Last - 10 .. Text_B'Last) = "not striken"; begin if not A_Not_Striken and then B_Not_Striken then return -1; -- A first, B second elsif A_Not_Striken and then not B_Not_Striken then return 1; -- B first, A second elsif Text_A < Text_B then return -1; -- A first elsif Text_A = Text_B then return 0; -- Same else return 1; -- B first end if; end Custom_Sort; -------------- -- Add_Line -- -------------- function Add_Line (Model : access Gtk_Tree_Store_Record'Class; Text : String; Striken : Boolean := False; Editable : Boolean := False; Active : Boolean := False; Parent : Gtk_Tree_Iter := Null_Iter) return Gtk_Tree_Iter is Iter : Gtk_Tree_Iter; begin -- The implementation here is not the most efficient: it is often easier -- to import yourself the function gtk_tree_store_set with the correct -- set of arguments, as shown in the example in gtk-tree_store.ads Append (Model, Iter, Parent); Set (Model, Iter, Text_Column, Text); Set (Model, Iter, Strike_Column, Striken); Set (Model, Iter, Active_Column, Active); Set (Model, Iter, Editable_Column, Editable); if Editable then Set (Model, Iter, Foreground_Column, "red"); else Set (Model, Iter, Foreground_Column, "black"); end if; return Iter; end Add_Line; --------------------- -- Edited_Callback -- --------------------- procedure Edited_Callback (Model : access GObject_Record'Class; Params : Glib.Values.GValues) is M : constant Gtk_Tree_Store := Gtk_Tree_Store (Model); Path_String : constant String := Get_String (Nth (Params, 1)); Iter : constant Gtk_Tree_Iter := Get_Iter_From_String (M, Path_String); Old_Value : Boolean; begin Old_Value := Get_Boolean (M, Iter, Active_Column); Set (M, Iter, Active_Column, not Old_Value); end Edited_Callback; -------------------------- -- Text_Edited_Callback -- -------------------------- procedure Text_Edited_Callback (Model : access GObject_Record'Class; Params : Glib.Values.GValues) is M : constant Gtk_Tree_Store := Gtk_Tree_Store (Model); Path_String : constant String := Get_String (Nth (Params, 1)); Text_Value : constant GValue := Nth (Params, 2); Iter : constant Gtk_Tree_Iter := Get_Iter_From_String (M, Path_String); begin Set_Value (M, Iter, Text_Column, Text_Value); end Text_Edited_Callback; --------- -- Run -- --------- procedure Run (Frame : access Gtk.Frame.Gtk_Frame_Record'Class) is Model : Gtk_Tree_Store; Tree : Gtk_Tree_View; Scrolled : Gtk_Scrolled_Window; Col : Gtk_Tree_View_Column; Num : Gint; Text_Render : Gtk_Cell_Renderer_Text; Toggle_Render : Gtk_Cell_Renderer_Toggle; Parent, Iter : Gtk_Tree_Iter; pragma Unreferenced (Num); begin -- Create the model that contains the actual data. In this example, -- we create this as a tree, although it could also be a simple list. -- -- Each data is in fact a line in the graphical widget, and can contain -- multiple columns, not all of which are visible at any time. Some can -- be used as flags to indicate how the rendering should be done. Gtk_New (Model, (Text_Column => GType_String, Strike_Column => GType_Boolean, Editable_Column => GType_Boolean, Active_Column => GType_Boolean, Foreground_Column => GType_String)); -- Create the view: it shows two columns, the first contains some text, -- the second contains a toggle button. In each column, a renderer is -- used to display the data graphically. In the future, it will be -- possible to create your own renderers with GtkAda. For now, we simply -- use two of the predefined renderers. The list of possible attributes -- for these is defined in their respective packages. Gtk_New (Tree, Model); Gtk_New (Text_Render); Gtk_New (Toggle_Render); Gtk_New (Col); Num := Append_Column (Tree, Col); Set_Sort_Column_Id (Col, Text_Column); Set_Title (Col, "First column"); Pack_Start (Col, Text_Render, True); Set_Sizing (Col, Tree_View_Column_Autosize); Add_Attribute (Col, Text_Render, "text", Text_Column); Add_Attribute (Col, Text_Render, "strikethrough", Strike_Column); Add_Attribute (Col, Text_Render, "editable", Editable_Column); Add_Attribute (Col, Text_Render, "foreground", Foreground_Column); Gtk_New (Col); Set_Sort_Column_Id (Col, -1); -- unsortable Num := Append_Column (Tree, Col); Set_Title (Col, "Second column"); Pack_Start (Col, Toggle_Render, False); Add_Attribute (Col, Toggle_Render, "active", Active_Column); Add_Attribute (Col, Toggle_Render, "activatable", Editable_Column); -- Make the tree sortable (see also calls to Set_Sort_Column_Id above). -- The default sort is alphabetical. For the fun of it, we implement -- our own sorting algorithm here. Set_Headers_Clickable (Tree, True); Set_Sort_Func (+Model, Text_Column, Custom_Sort'Access); -- By default, the toggle renderer doesn't react to clicks, ie the user -- cannot interactively change the value of the radio button. This needs -- a special callback for the "edited" signal. -- The same applies for text renderers. -- -- In both cases, the callback should be used for validation of the -- input. Object_Callback.Object_Connect (Toggle_Render, "toggled", Edited_Callback'Access, Slot_Object => Model); Object_Callback.Object_Connect (Text_Render, "edited", Text_Edited_Callback'Access, Slot_Object => Model); -- Insert some data in the tree Parent := Null_Iter; for Count in 1 .. 30 loop Iter := Add_Line (Model, "not-editable, not striken", Parent => Parent); Iter := Add_Line (Model, "editable, not striken", Editable => True, Parent => Parent); Iter := Add_Line (Model, "editable, striken", Editable => True, Striken => True, Parent => Parent); Iter := Add_Line (Model, "not-editable, striken", Striken => True, Parent => Parent); Iter := Add_Line (Model, "not-editable, not striken", Active => True, Parent => Parent); Iter := Add_Line (Model, "editable, not striken", Editable => True, Active => True, Parent => Parent); Iter := Add_Line (Model, "editable, striken", Editable => True, Striken => True, Active => True, Parent => Parent); Iter := Add_Line (Model, "not-editable, striken", Striken => True, Active => True, Parent => Parent); Parent := Iter; end loop; -- Insert the view in the frame Gtk_New (Scrolled); Set_Policy (Scrolled, Policy_Always, Policy_Always); Add (Scrolled, Tree); Show_All (Scrolled); Add (Frame, Scrolled); end Run; end Create_Tree_View;

Alphabetical Index