File: glib-types.ads

package info (click to toggle)
libgtkada2 2.8.1-6lenny3
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,496 kB
  • ctags: 3,886
  • sloc: ada: 103,189; ansic: 45,411; perl: 5,500; sh: 2,812; makefile: 1,169; xml: 19
file content (96 lines) | stat: -rw-r--r-- 4,830 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
-----------------------------------------------------------------------
--              GtkAda - Ada95 binding for Gtk+/Gnome                --
--                                                                   --
--                Copyright (C) 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.                                       --
--                                                                   --
-----------------------------------------------------------------------

--  <description>
--  This package provides an interface to the type system in Glib. These types
--  provide an object-oriented framework (through inheritance and interfaces),
--  as well as reference-counting, signals and properties on these types.
--
--  See the other glib packages for more subprograms to manipulate these types.
--  In particular, Glib.Properties describes the properties system, that
--  provide the base for dynamic introspection. See also Glib itself, which
--  contains several general subprograms, and Glib.Object that provides the
--  root object for any type hierarchy based on glib.
--  </description>
--  <group>Glib, the general-purpose library</group>

with Glib.Object;
with System;

package Glib.Types is

   ----------------
   -- Interfaces --
   ----------------
   --  Interfaces are similar, in concept, to those found in Ada 2005 or in
   --  Java. They define a set of subprograms that any type implementing the
   --  interface must also define. They are different from standard inheritance
   --  since no implementation of these subprograms can be provided in the
   --  interface itself.
   --
   --  Whereas an object can only derive from one other object, it can
   --  implement any number of interfaces.
   --
   --  Some of the standard gtk+ objects implement interfaces. In this case,
   --  their Ada package contains one or more functions to convert from the
   --  object itself to the interface, for instance:
   --
   --      package Implements_Cell_Layout is new Glib.Types.Implements (...);
   --      function "+" (...) renames Implements_Cell_Layout.To_Interface;
   --      function "-" (...) renames Implements_Cell_Layout.To_Object;
   --
   --  The two unary operators "+" and "-" can be used to convert to and from
   --  the interface, for instance calling:
   --        View : Gtk_Cell_View;
   --        Gtk.Cell_Layout.Pack_Start (+View, Cell, Expand);

   type GType_Interface is private;

   --  <doc_ignore>
   generic
      type Interface_Type is new GType_Interface;
      type Object_Type_Record is new Glib.Object.GObject_Record with private;
      type Object_Type is access all Object_Type_Record'Class;
   package Implements is
      function To_Object (Interf : Interface_Type) return Object_Type;
      function To_Interface
        (Object : access Object_Type_Record'Class) return Interface_Type;
      --  These subprograms can be used to convert from an object to one of
      --  the interfaces it implements, and from an interface to the object
      --  itself.
   end Implements;
   --  </doc_ignore>

   function To_Object
     (Interf : GType_Interface) return Glib.Object.GObject;
   --  Return the object that the interface represents. This is slightly
   --  different from using Implements.To_Object, in the case when the object
   --  wasn't created through Ada. In such a case, GtkAda needs to create an
   --  Ada wrapper around the object, and will choose a different tagged type:
   --     - Implements.To_Object creates a tagged type of type Object_Type.
   --     - This function creates a GObject, which you cannot cast easily
   --       to some other tagged type afterward.
   --  Both behave the same when the object was created from Ada.

private
   type GType_Interface is new System.Address;
end Glib.Types;