Description
This 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.
Types
-
type Data_Type is private;
-
type Data_Type_Access is access all Data_Type;
-
type Gtk_Tree_Store is access all Gtk_Tree_Store_Record'Class;
-
Subprograms
-
procedure Gtk_New
(Tree_Store : out Gtk_Tree_Store;
Types : GType_Array);
-
procedure Initialize
(Tree_Store : access Gtk_Tree_Store_Record'Class;
Types : GType_Array);
-
-
procedure Set_Column_Types
(Tree_Store : access Gtk_Tree_Store_Record;
Types : GType_Array);
-
procedure Set_Value
(Tree_Store :
access Gtk_Tree_Store_Record;
Iter :
Gtk.Tree_Model.Gtk_Tree_Iter;
Column : Gint;
Value : Glib.Values.GValue);
-
procedure Set
(Tree_Store :
access Gtk_Tree_Store_Record'Class;
Iter :
Gtk.Tree_Model.Gtk_Tree_Iter;
Column : Gint;
Value : Data_Type_Access);
-
-
-
-
-
-
-
-
procedure Remove
(Tree_Store : access Gtk_Tree_Store_Record;
Iter : in out Gtk.Tree_Model.Gtk_Tree_Iter);
-
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);
-
-
-
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);
-
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);
-
-
-
-
-
-
procedure Clear (Tree_Store : access Gtk_Tree_Store_Record);
-
-
Sorting Freeze / Thaw
-
-
Interfaces
This class implements several interfaces. See
Glib.Types
-
-
-
function "+"
(Model : access Gtk_Tree_Store_Record'Class)
return Gtk.Tree_Dnd.Gtk_Tree_Drag_Dest
renames Implements_Drag_Dest.To_Interface;
function "-"
(Drag_Dest : Gtk.Tree_Dnd.Gtk_Tree_Drag_Dest)
return Gtk_Tree_Store
renames Implements_Drag_Dest.To_Object;
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 Set_String
(Tree : System.Address;
Iter : Gtk.Tree_Model.Gtk_Tree_Iter;
Column : Gint; Value : UTF8_String);
pragma Import (C, Set_String, "ada_gtk_tree_store_set_ptr");
procedure Set_Int
(Tree : System.Address;
Iter : Gtk.Tree_Model.Gtk_Tree_Iter;
Column : Gint; Value : Gint);
pragma Import (C, Internal, "ada_gtk_tree_store_set_int");
begin
Internal
(Get_Object (Tree_Store), Iter, Column1, Value1 & ASCII.NUL);
Internal
(Get_Object (Tree_Store), Iter, Column2, Boolean'Pos (Value2));
end Set;