1. ------------------------------------------------------------------------------ 
  2. --                  GtkAda - Ada95 binding for Gtk+/Gnome                   -- 
  3. --                                                                          -- 
  4. --                     Copyright (C) 2001-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. -- 
  26. --  This package provides a minimal binding to the GObject type in Glib. 
  27. --  See Glib.Properties for information on how to manipulate properties 
  28. -- 
  29. --  </description> 
  30. --  <group>Glib, the general-purpose library</group> 
  31.  
  32. with Gtkada.Types; 
  33. with Glib.GSlist; 
  34. with Glib.Glist; 
  35. pragma Elaborate_All (Glib.GSlist); 
  36. pragma Elaborate_All (Glib.Glist); 
  37.  
  38. package Glib.Object is 
  39.  
  40.    type GObject_Record is tagged private; 
  41.    type GObject is access all GObject_Record'Class; 
  42.    pragma No_Strict_Aliasing (GObject); 
  43.    --  The base type for Glib/Gdk/Gtk objects. It basically gives access 
  44.    --  to an underlying C object. This is not a controlled type for 
  45.    --  efficiency reasons and because glib takes care of the memory 
  46.    --  management on its own. 
  47.  
  48.    function Is_Created (Object : GObject_Record'Class) return Boolean; 
  49.    --  Return True if the associated C object has been created, False if 
  50.    --  no C object is associated with Object. 
  51.    --  This is not the same as testing whether an access type (for instance 
  52.    --  any of the widgets) is "null", since this relates to the underlying 
  53.    --  C object. 
  54.  
  55.    function Get_Type (Object : access GObject_Record) return GType; 
  56.    --  Return the type of Object. 
  57.    --  This function is mostly used internally, since in Ada you can simply 
  58.    --  test whether an object belong to a class with a statement like: 
  59.    -- 
  60.    --     if Object in Gtk_Button_Record'Class then ... 
  61.    -- 
  62.    --  which is easier. 
  63.  
  64.    ---------------- 
  65.    -- Life cycle -- 
  66.    ---------------- 
  67.  
  68.    procedure Initialize (Object : access GObject_Record'Class); 
  69.    --  Internal initialization function. 
  70.    --  See the section "Creating your own widgets" in the documentation. 
  71.  
  72.    procedure Ref (Object : access GObject_Record); 
  73.    --  Increment the reference counter for Object. See Unref below. 
  74.    --  Since an object is not deleted while its reference count is not null, 
  75.    --  this is a way to keep an object in memory, in particular when you 
  76.    --  want to temporarily remove a widget from its parent. 
  77.  
  78.    procedure Unref (Object : access GObject_Record); 
  79.    --  Decrement the reference counter for Object. When this reaches 0, the 
  80.    --  object is effectively destroy, all the callbacks associated with it are 
  81.    --  disconnected. 
  82.  
  83.    type Weak_Notify is access procedure 
  84.      (Data                 : System.Address; 
  85.       Where_The_Object_Was : System.Address); 
  86.    pragma Convention (C, Weak_Notify); 
  87.    --  Called when Where_The_Object_Was is destroyed (although you can still 
  88.    --  use this to reset it). Data is the argument passed to Weak_Ref. 
  89.    --  You should destroy and free the memory occupied by Data 
  90.  
  91.    procedure Weak_Ref 
  92.      (Object : access GObject_Record'Class; 
  93.       Notify : Weak_Notify; 
  94.       Data   : System.Address := System.Null_Address); 
  95.    --  This kind of reference doesn't increment the object's reference 
  96.    --  counting. However, it can and should be used to monitor the object's 
  97.    --  life cycle, in particular to detect is destruction. 
  98.    --  When Object is destroyed, calls Notify 
  99.  
  100.    procedure Weak_Unref 
  101.      (Object : access GObject_Record'Class; 
  102.       Notify : Weak_Notify; 
  103.       Data   : System.Address := System.Null_Address); 
  104.    --  Cancels the settings of Weak_Ref. 
  105.  
  106.    procedure Deallocate (Object : access GObject_Record); 
  107.    --  This operation is used to deallocate Object. 
  108.    --  The default implementation assumes that the value passed in is an 
  109.    --  access value created by an allocator of the default pool, i.e. it 
  110.    --  will assume that an instance of 
  111.    --  Unchecked_Deallocation (GObject_Record'Class, GObject) 
  112.    --  can be used to deallocate the designated object. 
  113.    --  Types derived of GObject_Record can override this operation in order 
  114.    --  to cope with objects allocated on other pools or even objects allocated 
  115.    --  on the stack. 
  116.    --  This design is limited to support only one allocation strategy for each 
  117.    --  class, as the class tag is used to identify the applicable strategy. 
  118.  
  119.    procedure Ref_Sink (Object : access GObject_Record); 
  120.    --  Increase the reference count of Object, and possibly remove the 
  121.    --  floating reference, if Object has a floating reference. 
  122.    --  In other words, if the object is floating, then this call "assumes 
  123.    --  ownership" of the floating reference, converting it to a normal 
  124.    --  reference by clearing the floating flag while leaving the reference 
  125.    --  count unchanged.  If the object is not floating, then this call 
  126.    --  adds a new normal reference increasing the reference count by one. 
  127.  
  128.    ------------------------ 
  129.    -- Interfacing with C -- 
  130.    ------------------------ 
  131.    --  The following functions are made public so that one can easily create 
  132.    --  new objects outside the Glib or Gtk package hierarchy. 
  133.    --  Only experienced users should make use of these functions. 
  134.  
  135.    function Get_Object 
  136.      (Object : access GObject_Record'Class) return System.Address; 
  137.    --  Access the underlying C pointer. 
  138.  
  139.    function Get_Object_Or_Null (Object : GObject) return System.Address; 
  140.    --  Same as above, but passing "null" is valid. 
  141.  
  142.    procedure Set_Object 
  143.      (Object : access GObject_Record'Class; 
  144.       Value  : System.Address); 
  145.    --  Modify the underlying C pointer. 
  146.  
  147.    function Get_User_Data 
  148.      (Obj  : System.Address; 
  149.       Stub : GObject_Record'Class) return GObject; 
  150.    --  Return the Ada object matching the C object Obj. If Obj was created 
  151.    --  explicitely from GtkAda, this will be the exact same widget. If Obj was 
  152.    --  created implicitely by gtk+ (buttons in complex windows,...), a new Ada 
  153.    --  object of type Stub will be created. 
  154.  
  155.    function Get_User_Data_Fast 
  156.      (Obj  : System.Address; 
  157.       Stub : GObject_Record'Class) return GObject; 
  158.    --  Same as Get_User_Data, but does not try to guess the type of Obj, 
  159.    --  always default to Stub if Obj is unknown to GtkAda. 
  160.  
  161.    function Unchecked_Cast 
  162.      (Obj  : access GObject_Record'Class; 
  163.       Stub : GObject_Record'Class) return GObject; 
  164.    --  Cast Obj in an object of tag Stub'Class. 
  165.    --  Return the resulting object and free the memory pointed by Obj. 
  166.  
  167.    ------------- 
  168.    -- Signals -- 
  169.    ------------- 
  170.    --  Any child of GObject can be associated with any number of signals. The 
  171.    --  mechanism for signals is fully generic, and any number of arguments can 
  172.    --  be associated with signals. 
  173.    --  See the function Initialize_Class_Record for more information on how 
  174.    --  to create new signals for your own new widgets. 
  175.    --  The subprograms below are provided for introspection: they make it 
  176.    --  possible to query the list of signals defined for a specific widget, 
  177.    --  as well as their parameters and return types. 
  178.  
  179.    type Signal_Id_Array is array (Guint range <>) of Glib.Signal_Id; 
  180.  
  181.    type Signal_Query is private; 
  182.  
  183.    function Lookup 
  184.      (Object : Glib.GType; Signal : String) return Glib.Signal_Id; 
  185.    --  Returns the signal Id associated with a specific Object/Signal pair. 
  186.    --  Null_Signal_Id is returned if no such signal exists for Object. 
  187.    --  You can then use the Query procedure to get more information on the 
  188.    --  signal. 
  189.  
  190.    function List_Ids (Typ : Glib.GType) return Signal_Id_Array; 
  191.    --  Return the list of signals defined for Typ. You can get more information 
  192.    --  on each of this signals by using the Query function below. 
  193.    --  See also the function Get_Type above to convert from an object instance 
  194.    --  to its type. Using a GType as the parameter makes it easier to find the 
  195.    --  signals for a widget and its ancestors (using Glib.Parent). 
  196.  
  197.    procedure Query (Id : Glib.Signal_Id; Result : out Signal_Query); 
  198.    --  Return the description associated with the signal Id. You can get the 
  199.    --  various fields from Query with one of the functions below. 
  200.    --  Result is undefined if Id is Invalid_Signal_Id or Null_Signal_Id 
  201.  
  202.    function Id (Q : Signal_Query) return Glib.Signal_Id; 
  203.    --  Return the signal Id. Each Id is specific to a widget/signal name pair. 
  204.    --  These Ids can then be used to temporarily block a signal for instance, 
  205.    --  through the subprograms in Gtk.Handlers. 
  206.  
  207.    function Signal_Name (Q : Signal_Query) return Glib.Signal_Name; 
  208.    --  Return the name of the signal, as should be used in a call to Connect. 
  209.  
  210.    function Return_Type (Q : Signal_Query) return Glib.GType; 
  211.    --  Return the type of object returned by the handlers for this signal. 
  212.  
  213.    function Params (Q : Signal_Query) return GType_Array; 
  214.    --  Return the list of parameters for the handlers for this signal 
  215.  
  216.    -------------------------- 
  217.    -- Creating new widgets -- 
  218.    -------------------------- 
  219.    --  These types and functions are used only when creating new widget types 
  220.    --  directly in Ada. These functions initialize the classes so that they are 
  221.    --  correctly recognized by gtk+ itself 
  222.    --  See the GtkAda user's guide for more information on how to create your 
  223.    --  own widget types in Ada. 
  224.  
  225.    type Interface_Vtable is private; 
  226.    --  The virtual table of an interface (see Glib.Types). This is only useful 
  227.    --  when doing introspection. 
  228.  
  229.    type GObject_Class is new GType_Class; 
  230.    Null_GObject_Class : constant GObject_Class; 
  231.  
  232.    type Ada_GObject_Class is record 
  233.       The_Type     : GType := 0; 
  234.    end record; 
  235.    pragma Convention (C, Ada_GObject_Class); 
  236.    Uninitialized_Class : constant Ada_GObject_Class; 
  237.    --  This type encloses all the informations related to a specific type of 
  238.    --  object or widget. All instances of such an object have a pointer to this 
  239.    --  structure, that includes the definition of all the signals that exist 
  240.    --  for a given object, all its properties,... 
  241.    -- 
  242.    --  A GObject_Class can be retrieved from an Ada_GObject_Class by calling 
  243.    --  Glib.Types.Class_Ref. 
  244.  
  245.    type Signal_Parameter_Types is 
  246.      array (Natural range <>, Natural range <>) of GType; 
  247.    --  The description of the parameters for each event. These are the 
  248.    --  parameters that the application must provide when emitting the 
  249.    --  signal. The user can of course add his own parameters when connecting 
  250.    --  the signal in his application, through the use of 
  251.    --  Gtk.Handlers.User_Callback. 
  252.    -- 
  253.    --  Each event defined with Initialize_Class_Record below should have an 
  254.    --  entry in this table. If Gtk_Type_None is found in the table, it is 
  255.    --  ignored. For instance, a Signal_Parameter_Type like: 
  256.    --    (1 => (1 => Gdk_Type_Gdk_Event, 2 => GType_None), 
  257.    --     2 => (1 => GType_Int,          2 => GType_Int)); 
  258.    --  defines two signals, the first with a single Gdk_Event parameter, the 
  259.    --  second with two ints parameters. 
  260.  
  261.    No_Signals : constant Gtkada.Types.Chars_Ptr_Array := 
  262.       (1 .. 0 => Gtkada.Types.Null_Ptr); 
  263.    Null_Parameter_Types : constant Signal_Parameter_Types (1 .. 0, 1 .. 0) := 
  264.      (others => (others => GType_None)); 
  265.    --  An empty array, used as a default parameter in Initialize_Class_Record. 
  266.  
  267.    procedure Initialize_Class_Record 
  268.      (Ancestor     : GType; 
  269.       Class_Record : in out Ada_GObject_Class; 
  270.       Type_Name    : String; 
  271.       Signals      : Gtkada.Types.Chars_Ptr_Array := No_Signals; 
  272.       Parameters   : Signal_Parameter_Types := Null_Parameter_Types); 
  273.    function Initialize_Class_Record 
  274.      (Ancestor     : GType; 
  275.       Class_Record : not null access Ada_GObject_Class; 
  276.       Type_Name    : String; 
  277.       Signals      : Gtkada.Types.Chars_Ptr_Array := No_Signals; 
  278.       Parameters   : Signal_Parameter_Types := Null_Parameter_Types) 
  279.       return Boolean; 
  280.    --  Create the class record for a new object type. 
  281.    --  It is associated with Signals new signals. A pointer to the 
  282.    --  newly created structure is also returned in Class_Record. 
  283.    --  If Class_Record /= Uninitialized_Class, no memory allocation is 
  284.    --  performed, we just reuse it. As a result, each instantiation of an 
  285.    --  object will share the same GObject_Class, exactly as is done for gtk+. 
  286.    -- 
  287.    --  As a special case, if Parameters has its default value, all signals are 
  288.    --  created with no argument. This is done for backward compatibility 
  289.    --  mainly, and you should instead give it an explicit value. 
  290.    --  Type_Name should be a unique name identifying the name of the new type. 
  291.    -- 
  292.    --  Only the signals with no parameter can be connected from C code. 
  293.    --  However, any signal can be connected from Ada. This is due to the way 
  294.    --  we define default marshallers for the signals. 
  295.    -- 
  296.    --  The function returns True if the class record was just created (i.e. 
  297.    --  only the first time). This can be used to do further initialization 
  298.    --  at that point, like calling Gtk.Widget.Set_Default_Draw_Handler. 
  299.  
  300.    function Type_From_Class (Class_Record : GObject_Class) return GType; 
  301.    --  Return the internal gtk+ type that describes the newly created 
  302.    --  Class_Record. 
  303.    --  See the function Glib.Types.Class_Peek for the opposite function 
  304.    --  converting from a GType to a GObject_Class. 
  305.  
  306.    procedure G_New 
  307.       (Object : not null access GObject_Record'Class; 
  308.        Typ    : GType); 
  309.    procedure G_New 
  310.       (Object : not null access GObject_Record'Class; 
  311.        Typ    : Ada_GObject_Class); 
  312.    --  Create a new instance of Typ (at the C level). This has no effect if 
  313.    --  the C object has already been created (so that G_New can be called 
  314.    --  from Initialize (and you can call the parent's Initialize). 
  315.    -- 
  316.    --  Object must have been allocated first, but you should not have called 
  317.    --  any of the Gtk_New procedures yet. 
  318.    --  This procedure is meant to be used when you create your own object 
  319.    --  types with own signals, properties,... The code would thus be 
  320.    -- 
  321.    --   Klass : aliased Ada_GObject_Class := Uninitialized_Class; 
  322.    -- 
  323.    --   function Get_Type return GType is 
  324.    --   begin 
  325.    --      if Initialize_Class_Record 
  326.    --         (Ancestor     => Gtk.Button.Get_Type, 
  327.    --          Class_Record => Klass'Access, 
  328.    --          Type_Name    => "My_Widget") 
  329.    --      begin 
  330.    --         --  Add interfaces if needed 
  331.    --         Add_Interface (Klass, ..., new GInterface_Info'(...)); 
  332.    -- 
  333.    --         --  Override the inherited methods 
  334.    --         Gtk.Widget.Set_Default_Draw_Handler (...); 
  335.    -- 
  336.    --         --  Install properties 
  337.    --         Install_Style_Property 
  338.    --            (Glib.Types.Class_Ref (Klass), 
  339.    --             Gnew_Int (...)); 
  340.    --      end if; 
  341.    --      return Klass.The_Type; 
  342.    --   end Get_Type; 
  343.    -- 
  344.    --   procedure Gtk_New (Self : out My_Widget) is 
  345.    --   begin 
  346.    --      Self := new My_Widget_Record;  --  create the Ada wrapper 
  347.    --      Initialize (Self); 
  348.    --   end Gtk_New; 
  349.    -- 
  350.    --   procedure Initialize (Self : not null access My_Widget_Record'Class) is 
  351.    --   begin 
  352.    --      G_New (Self, Get_Type); --  allocate the C widget, unless done 
  353.    -- 
  354.    --      --  Initialize parent fields 
  355.    -- 
  356.    --      My_Widget_Parent.Initialize (Self); 
  357.    -- 
  358.    --      --  Initialization of the Ada types 
  359.    --      ... 
  360.    --   end Initialize; 
  361.  
  362.    ---------------- 
  363.    -- Interfaces -- 
  364.    ---------------- 
  365.  
  366.    type GInterfaceInitFunc is access procedure 
  367.       (Iface : System.Address; 
  368.        Data  : System.Address); 
  369.    pragma Convention (C, GInterfaceInitFunc); 
  370.    --  The interface initialization function. This function should initialize 
  371.    --  all internal data and allocate any resources required by the interface. 
  372.    --  Iface: the interface structure to initialize. It is allocated 
  373.    --    specifically for each class instance that implements the interface. 
  374.    --    The exact type depends on the interface that is implemented. This is 
  375.    --    in general a record that contains a number of access to procedures 
  376.    --    for the interface methods. See for instance Gtk.Tree_Model.Interfaces 
  377.    --  Data: the data supplied to the GInterface_Info. 
  378.  
  379.    type GInterfaceFinalizeFunc is access procedure 
  380.       (Iface : System.Address; 
  381.        Data  : System.Address); 
  382.    pragma Convention (C, GInterfaceFinalizeFunc); 
  383.    --  The interface finalization function. 
  384.    --  This function should destroy any internal data and release any resources 
  385.    --  allocated by the corresponding init func. 
  386.  
  387.    type GInterface_Info is record 
  388.       Interface_Init     : GInterfaceInitFunc := null; 
  389.       Interface_Finalize : GInterfaceFinalizeFunc := null; 
  390.       Interface_Data     : System.Address := System.Null_Address; 
  391.    end record; 
  392.    pragma Convention (C, GInterface_Info); 
  393.    --  A structure that provides information to the type system which is used 
  394.    --  specifically for managing interface types. 
  395.  
  396.    procedure Add_Interface 
  397.       (Klass : Ada_GObject_Class; 
  398.        Iface : GType; 
  399.        Info  : not null access GInterface_Info); 
  400.    --  State that Klass implements the given interface. It will need to 
  401.    --  override the inherited methods. This is low-level handling. 
  402.    --  Info should be allocated in this call, and is never freed in the 
  403.    --  lifetime of the application. 
  404.  
  405.    ------------------------------ 
  406.    -- Properties introspection -- 
  407.    ------------------------------ 
  408.    --  See glib.ads for more information on properties 
  409.  
  410.    function Interface_List_Properties 
  411.      (Vtable : Interface_Vtable) return Glib.Param_Spec_Array; 
  412.    --  Return the list of properties of an interface (see also Glib.Properties) 
  413.    --  from a Vtable from Default_Interface_Peek). 
  414.    --  See also Class_List_Properties for a similar function for objects. 
  415.  
  416.    function Class_List_Properties 
  417.      (Class : GObject_Class) return Glib.Param_Spec_Array; 
  418.    --  Return the list of all properties of the class. 
  419.  
  420.    ------------- 
  421.    -- Signals -- 
  422.    ------------- 
  423.    --  ??? This section is incomplete. 
  424.  
  425.    --  <signals> 
  426.    --  The following new signals are defined for this object: 
  427.    -- 
  428.    --  - "notify" 
  429.    --    procedure Handler 
  430.    --      (Object : access GObject_Record'Class; Name : String); 
  431.    -- 
  432.    --    Emitted when the property Name has been modified 
  433.    --  </signals> 
  434.  
  435.    procedure Notify 
  436.      (Object        : access GObject_Record; 
  437.       Property_Name : String); 
  438.    --  Emits the "notify" signal, to signal every listener that the property 
  439.    --  has been changed. 
  440.  
  441.    --------------- 
  442.    -- User_Data -- 
  443.    --------------- 
  444.    --  This package allow you to associate your own Data to the C widgets. No 
  445.    --  type verification is made to check if you are using the correct 
  446.    --  matching Get function. This is your own responsability. 
  447.    -- 
  448.    --  We recommend using this package only if you want your data to be 
  449.    --  available from your own C code. If you just want to access it from Ada, 
  450.    --  you should consider creating a new tagged type instead, that extends 
  451.    --  either GObject_Record or the specific widget type you need. 
  452.  
  453.    --  <doc_ignore> 
  454.  
  455.    generic 
  456.       type Data_Type (<>) is private; 
  457.    package User_Data is 
  458.       type On_Destroyed_Callback is access procedure (Data : Data_Type); 
  459.       --  On_Destroyed is called when the data is overriden in the object, by 
  460.       --  an other object with the same ID, or when the object itself is 
  461.       --  destroyed 
  462.  
  463.       function Is_Set 
  464.         (Object : access GObject_Record'Class; 
  465.          Id     : String := "user_data") return Boolean; 
  466.       --  Whether the given user data was set on the object. 
  467.  
  468.       function Get 
  469.         (Object : access GObject_Record'Class; 
  470.          Id     : String := "user_data") return Data_Type; 
  471.       --  Get the information associated with the key ID. 
  472.       --  Raise Gtkada.Types.Data_Error if there is none. 
  473.  
  474.       function Get 
  475.         (Object  : access GObject_Record'Class; 
  476.          Id      : String := "user_data"; 
  477.          Default : Data_Type) return Data_Type; 
  478.       --  Get the information associated with the key ID. 
  479.       --  Return Default instead of raising an exception if there is no such 
  480.       --  user data 
  481.  
  482.       procedure Set 
  483.         (Object : access GObject_Record'Class; 
  484.          Data   : Data_Type; 
  485.          Id     : String := "user_data"; 
  486.          On_Destroyed : On_Destroyed_Callback := null); 
  487.       --  Associate some new user data with the object. 
  488.       --  The strings starting with "gtkada_" are reserved for GtkAda's 
  489.       --  internal use, please avoid using them. 
  490.  
  491.       procedure Remove 
  492.         (Object : access GObject_Record'Class; Id : String := "user_data"); 
  493.       --  Remove some data from the object 
  494.  
  495.       function Get 
  496.         (Object : access GObject_Record'Class; 
  497.          Id     : Glib.GQuark) return Data_Type; 
  498.       function Get 
  499.         (Object  : access GObject_Record'Class; 
  500.          Id      : Glib.GQuark; 
  501.          Default : Data_Type) return Data_Type; 
  502.       --  Same function as Get above, but uses directly the Quark associated 
  503.       --  with the string, which speeds up the access time significantly. 
  504.  
  505.       procedure Set 
  506.         (Object : access GObject_Record'Class; 
  507.          Data   : Data_Type; 
  508.          Id     : Glib.GQuark; 
  509.          On_Destroyed : On_Destroyed_Callback := null); 
  510.       --  Same function as Set above, but uses directly the Quark associated 
  511.       --  with the string, which speeds up the access time significantly. 
  512.  
  513.       procedure Remove 
  514.         (Object : access GObject_Record'Class; Id : Glib.GQuark); 
  515.       --  Same function as Remove above, but uses directly the Quark associated 
  516.       --  with the string, which speeds up the access time significantly. 
  517.  
  518.    private 
  519.       --  <doc_ignore> 
  520.       procedure Free_Data (Data : System.Address); 
  521.       --  Internal procedure used to free user data in the package body 
  522.       pragma Convention (C, Free_Data); 
  523.       --  </doc_ignore> 
  524.    end User_Data; 
  525.  
  526.    --  </doc_ignore> 
  527.  
  528.    ----------- 
  529.    -- Lists -- 
  530.    ----------- 
  531.  
  532.    function Convert (W : GObject) return System.Address; 
  533.    function Convert (W : System.Address) return GObject; 
  534.  
  535.    package Object_List is new Glib.GSlist.Generic_SList (GObject); 
  536.    package Object_Simple_List is new Glib.Glist.Generic_List (GObject); 
  537.  
  538.    --  <doc_ignore> 
  539.  
  540.    generic 
  541.       type User_Data_Type (<>) is private; 
  542.       with procedure Destroy (Data : in out User_Data_Type); 
  543.    package User_Data_Closure is 
  544.       --  This package is meant for internal use in GtkAda application. 
  545.       --  It provides a convenient wrapper around user-provided data, to 
  546.       --  be passed to callbacks. 
  547.  
  548.       type Data_Access is access all User_Data_Type; 
  549.  
  550.       type Internal_Data is record 
  551.          Func       : System.Address;  --  The actual user callback 
  552.          Data       : Data_Access; 
  553.       end record; 
  554.       type Internal_Data_Access is access all Internal_Data; 
  555.  
  556.       function Convert is new Ada.Unchecked_Conversion 
  557.          (System.Address, Internal_Data_Access); 
  558.  
  559.       function Build 
  560.          (Func : System.Address; Data : User_Data_Type) 
  561.          return System.Address; 
  562.       pragma Inline (Build); 
  563.       --  Allocate a new user data. 
  564.       --  It returns an access to Internal_Data_Access, but in a form easier 
  565.       --  to pass to a C function. 
  566.  
  567.       procedure Free_Data (Data : System.Address); 
  568.       pragma Convention (C, Free_Data); 
  569.       --  Callback suitable for calling from C, to free user data 
  570.  
  571.    end User_Data_Closure; 
  572.  
  573.    --  </doc_ignore> 
  574.  
  575. private 
  576.  
  577.    type GObject_Record is tagged record 
  578.       Ptr : System.Address := System.Null_Address; 
  579.    end record; 
  580.  
  581.    type Interface_Vtable is new Glib.C_Proxy; 
  582.  
  583.    Null_GObject_Class : constant GObject_Class := 
  584.       GObject_Class (System.Null_Address); 
  585.    Uninitialized_Class : constant Ada_GObject_Class := (The_Type => 0); 
  586.  
  587.    type Signal_Query is record 
  588.       Signal_Id    : Guint; 
  589.       Signal_Name  : System.Address;  --  const gchar* 
  590.       IType        : GType; 
  591.       Signal_Flags : Gint;            --  enum GSignalFlags 
  592.       Return_Type  : GType; 
  593.       N_Params     : Guint; 
  594.       Param_Types  : System.Address;  --  const gtype* 
  595.    end record; 
  596.    pragma Convention (C, Signal_Query); 
  597.  
  598.    --  <doc_ignore> 
  599.  
  600.    --  Note: the following functions and types should only be used 
  601.    --  for internal usage, not in the user's applications. 
  602.    --  If you use type inheritance for new widgets, you should not need 
  603.    --  these functions. 
  604.  
  605.    GtkAda_String : constant String := "_GtkAda" & ASCII.NUL; 
  606.    GtkAda_String_Quark : Glib.GQuark := Glib.Unknown_Quark; 
  607.    --  The name for the user data that we set in the objects. 
  608.    --  The Quark version is to speed up the string lookup (this is done 
  609.    --  only once). 
  610.  
  611.    --  </doc_ignore> 
  612.  
  613.    pragma Inline (Get_Object); 
  614.    pragma Inline (Set_Object); 
  615.    pragma Import (C, Type_From_Class, "ada_type_from_class"); 
  616.    pragma Import (C, Query, "g_signal_query"); 
  617.    pragma Import (C, Id, "ada_gsignal_query_id"); 
  618.    pragma Import (C, Return_Type, "ada_gsignal_query_return_type"); 
  619. end Glib.Object;