_
StoreThis package implements a specific model to store your data in. It is basically similar to a small database, in that each field can contain any number of columns.
Each column can contain a different type of data, specified when the model is created.
Adding new values in the model is done as in the example at the end.
Widget Hierarchy |
---|
GObject (see section Package Glib.Object) Gtk_Object (see section Package Gtk.Object) \___ Gtk_Tree_Model (see section Package Gtk.Tree |
Types |
---|
type Data_Type is private; | |
| |
type Data_Type_Access is access all Data_Type; | |
|
Subprograms |
---|
procedure Gtk_New (Tree_Store : out Gtk_Tree_Store; Types : GType_Array); | ||
Create a new tree store using Types to fill the columns.
| ||
function Get_Type return Glib.GType; | ||
Return the internal value associated with this widget.
| ||
procedure Set_Column_Types (Tree_Store : access Gtk_Tree_Store_Record; Types : GType_Array); | ||
This function is meant primarily for GObjects that inherit from | ||
procedure Set_Value (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column : Gint; Value : Glib.Values.GValue); | ||
Set a new value in the model. The value is added in the column Column, | ||
procedure Set (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column : Gint; Value : Data_Type_Access); | ||
Generic procedure used to store access objects in the model.
Please see the example at the end for more information on how to
create your own Set procedures adapted to your model.
| ||
procedure Set (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column : Gint; Value : UTF8_String); | ||
Same as Generic_Set, but tailored to use with a string.
| ||
procedure Set (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column : Gint; Value : Boolean); | ||
Same as Generic_Set, but tailored to use with a boolean.
| ||
procedure Set (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column : Gint; Value : Gint); | ||
Same as Generic_Set, but tailored to use with an integer.
| ||
procedure Set (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column : Gint; Value : Glib.C_Proxy); | ||
Same as Generic_Set, but tailored for Gdk types.
| ||
procedure Set (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column : Gint; Value : Glib.Object.GObject); | ||
Same as Generic_Set, but tailored to objects/widgets.
| ||
procedure Remove (Tree_Store : access Gtk_Tree_Store_Record; Iter : in out Gtk.Tree_Model.Gtk_Tree_Iter); | ||
Remove Iter from Tree_Store. | ||
procedure Insert (Tree_Store : access Gtk_Tree_Store_Record; Iter : in out Gtk.Tree_Model.Gtk_Tree_Iter; Parent : Gtk.Tree_Model.Gtk_Tree_Iter; Position : Gint); | ||
Create a new row at Position. | ||
procedure Insert_Before (Tree_Store : access Gtk_Tree_Store_Record; Iter : in out Gtk.Tree_Model.Gtk_Tree_Iter; Parent : Gtk.Tree_Model.Gtk_Tree_Iter; Sibling : Gtk.Tree_Model.Gtk_Tree_Iter); | ||
Insert a new row before Sibling. | ||
procedure Insert_After (Tree_Store : access Gtk_Tree_Store_Record; Iter : in out Gtk.Tree_Model.Gtk_Tree_Iter; Parent : Gtk.Tree_Model.Gtk_Tree_Iter; Sibling : Gtk.Tree_Model.Gtk_Tree_Iter); | ||
Insert a new row after Sibling. | ||
procedure Prepend (Tree_Store : access Gtk_Tree_Store_Record; Iter : in out Gtk.Tree_Model.Gtk_Tree_Iter; Parent : Gtk.Tree_Model.Gtk_Tree_Iter); | ||
Prepend a new row to Tree_Store. | ||
procedure Append (Tree_Store : access Gtk_Tree_Store_Record; Iter : in out Gtk.Tree_Model.Gtk_Tree_Iter; Parent : Gtk.Tree_Model.Gtk_Tree_Iter); | ||
Append a new row to Tree_Store. | ||
function Is_Ancestor (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Descendant : Gtk.Tree_Model.Gtk_Tree_Iter) return Boolean; | ||
Return True if Iter is an ancestor of Descendant. | ||
function Iter_Depth (Tree_Store : access Gtk_Tree_Store_Record; Iter : Gtk.Tree_Model.Gtk_Tree_Iter) return Gint; | ||
Returns the depth of Iter. | ||
procedure Clear (Tree_Store : access Gtk_Tree_Store_Record); | ||
Removes all rows from Tree_Store
| ||
Sorting Freeze / Thaw | ||
function Freeze_Sort (Tree : access Gtk.Tree_Store.Gtk_Tree_Store_Record'Class) return Gint; | ||
Freeze the sorting in the tree view, and returns the current | ||
procedure Thaw_Sort (Tree : access Gtk.Tree_Store.Gtk_Tree_Store_Record'Class; Column_Id : Gint); | ||
Thaw a frozen tree_view. Column_Id should be the value returned by |
Example |
---|
Adding a new line in the model: declare Iter : Gtk_Text_Iter; Value : Glib.Values.GValue; begin Append (Model, Iter, Null_Iter); -- First method: Init (Value, GType_String); Set_String (Value, "foo"); Set_Value (Model, Iter, 0, Value); Unref (Value); -- Second method: Set (Model, Iter, 0, "foo"); end; Defining your own Set function for your model: This can be done by directly importing the C function, with the appropriate number of parameters. Remember that you are passing data directly to C, thus you need to end strings with ASCII.NUL procedure My_Set (Tree_Store : access Gtk_Tree_Store_Record'Class; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column1 : Gint; Value1 : UTF8_String; Column2 : Gint; Value2 : Boolean) is procedure Internal (Tree : System.Address; Iter : Gtk.Tree_Model.Gtk_Tree_Iter; Column1 : Gint; Value1 : UTF8_String; Column2 : Gint; Value2 : Gint; Final : Gint := -1); pragma Import (C, Internal, "gtk_tree_store_set"); begin Internal (Get_Object (Tree_Store), Iter, Column1, Value1 & ASCII.NUL, Column2, Boolean'Pos (Value2)); end Set;