1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --   Copyright (C) 1998-2000 E. Briot, J. Brobecker and A. Charlet   -- 
  5. --                Copyright (C) 2000-2009, AdaCore                   -- 
  6. --                                                                   -- 
  7. -- This library is free software; you can redistribute it and/or     -- 
  8. -- modify it under the terms of the GNU General Public               -- 
  9. -- License as published by the Free Software Foundation; either      -- 
  10. -- version 2 of the License, or (at your option) any later version.  -- 
  11. --                                                                   -- 
  12. -- This library is distributed in the hope that it will be useful,   -- 
  13. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  14. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  15. -- General Public License for more details.                          -- 
  16. --                                                                   -- 
  17. -- You should have received a copy of the GNU General Public         -- 
  18. -- License along with this library; if not, write to the             -- 
  19. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  20. -- Boston, MA 02111-1307, USA.                                       -- 
  21. --                                                                   -- 
  22. -- -- -- -- -- -- -- -- -- -- -- --
  23. ----------------------------------------------------------------------- 
  24.  
  25. --  <description> 
  26. -- 
  27. --  The aim of this package is to provide some services to connect a 
  28. --  handler to a signal emitted by a Gtk Object. To understand the 
  29. --  services provided by this package, some definitions are necessary: 
  30. -- 
  31. --    Signal: A signal is a kind of message that an object wants to 
  32. --    broadcast. All GObjects can emit signals. These messages are 
  33. --    associated to certain events happening during the life of an 
  34. --    object. For instance, when a user clicks on a button, the 
  35. --    "clicked" signal is emitted by the button. 
  36. -- 
  37. --    Handler (or callback): A handler is a function or procedure that 
  38. --    the user "connects" to a signal for a particular object. 
  39. --    Connecting a handler to a signal means associating this handler to 
  40. --    the signal.  When the signal is emitted, all connected handlers 
  41. --    are called back. Usually, the role of those callbacks is to do 
  42. --    some processing triggered by a user action. For instance, when 
  43. --    "clicked" signal is emitted by the "OK" button of a dialog, the 
  44. --    connected handler can be used to close the dialog or recompute 
  45. --    some value. 
  46. -- 
  47. --    In GtkAda, the handlers are defined in a form as general as 
  48. --    possible. The first argument is always an access to the object it 
  49. --    has been connected to. The second object is a table of values 
  50. --    (See Glib.Values for more details about this table). It is the 
  51. --    responsibility of this handler to extract the values from it, and 
  52. --    to convert them to the correct Ada type. 
  53. -- 
  54. --    Because such handlers are not very convenient to use, this package 
  55. --    also provides some services to connect a marshaller instead. It 
  56. --    will then do the extraction work before calling the more 
  57. --    programmer-friendly handler, as defined in Gtk.Marshallers (see 
  58. --    Gtk.Marshallers for more details). 
  59. -- 
  60. --  The subdivision of this package is identical to Gtk.Marshallers; it 
  61. --  is made of four generic sub-packages, each representing one of the 
  62. --  four possible kinds of handlers: they can return a value or not, and 
  63. --  they can have some user specific data associated to them or not. 
  64. --  Selecting the right package depends on the profile of the handler. 
  65. --  For example, the handler for the "delete_event" signal of a 
  66. --  Gtk_Window has a return value, and has an extra parameter (a Gint). 
  67. --  All handlers also have a user_data field by default, but its usage 
  68. --  is optional. To connect a handler to this signal, if the user_data 
  69. --  field is not used, the Return_Callback generic should be 
  70. --  instantiated. On the other hand, if the user_data field is 
  71. --  necessary, then the User_Return_Callback generic should be used. 
  72. -- 
  73. --  Note also that the real handler in Gtk+ should expect at least as 
  74. --  many arguments as in the marshaller you are using. If your 
  75. --  marshaller has one argument, the C handler must have at least one 
  76. --  argument too. 
  77. -- 
  78. --  The common generic parameter to all sub-packages is the widget type, 
  79. --  which is the basic widget manipulated. This can be 
  80. --  Glib.Object.GObject_Record type if you want to reduce the number of 
  81. --  instantiations, but the conversion to the original type will have to be 
  82. --  done inside the handler. 
  83. -- 
  84. --  All sub-packages are organized in the same way. 
  85. -- 
  86. --    First, the type "Handler" is defined. It represents the general 
  87. --    form of the callbacks supported by the sub-package. 
  88. -- 
  89. --    The corresponding sub-package of Gtk.Marshallers is instantiated. 
  90. -- 
  91. --    A series of "Connect" procedures and functions is given. All cases 
  92. --    are covered: the functions return the Handler_Id of the newly 
  93. --    created association, while the procedures just connect the 
  94. --    handler, dropping the Handler_Id; some services allow the user to 
  95. --    connect a Handler while some others allow the usage of 
  96. --    Marshallers, which are more convenient. Note that more than one 
  97. --    handler may be connected to a signal; the handlers will then be 
  98. --    invoked in the order of connection. 
  99. -- 
  100. --    Some "Connect_Object" services are also provided. Those services 
  101. --    never have a user_data. They accept an additional parameter called 
  102. --    Slot_Object. When the callback in invoked, the Gtk Object emitting 
  103. --    the signal is substituted by this Slot_Object. 
  104. --    These callbacks are always automatically disconnected as soon as one 
  105. --    of the two widgets involved is destroyed. 
  106. -- 
  107. --    There are several methods to connect a handler. For each method, 
  108. --    although the option of connecting a Handler is provided, the 
  109. --    recommended way is to use Marshallers. Each connect service is 
  110. --    documented below, in the first sub-package. 
  111. -- 
  112. --    A series of "To_Marshaller" functions are provided. They return 
  113. --    some marshallers for the most commonly used types in order to ease 
  114. --    the usage of this package. Most of the time, it will not be 
  115. --    necessary to use some other marshallers. 
  116. --    For instance, if a signal is documented as receiving a single argument, 
  117. --    the widget (for instance the "clicked" signal for a Gtk_Button), you 
  118. --    will connect to it with: 
  119. --        with Gtkada.Handlers; 
  120. --        procedure On_Clicked (Button : access Gtk_Widget_Record'Class); 
  121. --        ... 
  122. --           Widget_Callback.Connect (Button, "clicked", On_Clicked'Access); 
  123. -- 
  124. --    The simple form above also applies for most handlers that take one 
  125. --    additional argument, for instance the "button_press_event" in 
  126. --    gtk-widget.ads. Just declare your subprogram with the appropriate profile 
  127. --    and connect it, as in: 
  128. --        with Gtkada.Handlers; 
  129. --        procedure On_Button (Widget : access Gtk_Widget_Record'Class; 
  130. --                             Event  : Gdk_Event); 
  131. --        ... 
  132. --           Widget_Callback.Connect (Widget, "button_press_event", 
  133. --                                    On_Button'Access); 
  134. -- 
  135. --    More complex forms of handlers exists however in GtkAda, for which no 
  136. --    predefined marshaller exists. In this case, you have to use the general 
  137. --    form of callbacks. For instance, the "select_row" signal of Gtk.Clist. 
  138. --        with Gtkada.Handlers; 
  139. --        with Gtk.Arguments; 
  140. --        procedure On_Select (Clist : access Gtk_Widget_Record'Class; 
  141. --                             Args  : Glib.Values.GValues) 
  142. --        is 
  143. --           Row : constant Gint := To_Gint (Args, 1); 
  144. --           Column : constant Gint := To_Gint (Args, 2); 
  145. --           Event  : constant Gdk_Event := To_Event (Args, 3); 
  146. --        begin 
  147. --           ... 
  148. --        end On_Select; 
  149. --        ... 
  150. --            Widget_Callback.Connect (Clist, "select_row", On_Select'Access); 
  151. -- 
  152. --    As for the "To_Marshaller" functions, a series of "Emit_By_Name" 
  153. --    procedures are also provided for the same most common types, to 
  154. --    allow the user to easily emit signals. These procedures are mainly 
  155. --    intended for people building new GObjects. 
  156. -- 
  157. --  At the end of this package, some general services related to the 
  158. --  management of signals and handlers are also provided. Each one of 
  159. --  them is documented individually below. 
  160. -- 
  161. --  IMPORTANT NOTE: These packages must be instantiated at library-level 
  162. -- 
  163. --  </description> 
  164. --  <c_version>2.8.17</c_version> 
  165. --  <group>Signal handling</group> 
  166.  
  167. with Glib.Values; 
  168. with Gdk.Event; 
  169. with Glib.Object; 
  170. with Gtk.Marshallers; 
  171. pragma Elaborate_All (Gtk.Marshallers); 
  172.  
  173. with Gtk.Notebook; 
  174. with Gtk.Tree_Model; 
  175. with Gtk.Widget; 
  176.  
  177. with Unchecked_Conversion; 
  178.  
  179. package Gtk.Handlers is 
  180.  
  181.    --  <doc_ignore> 
  182.  
  183.    pragma Elaborate_Body; 
  184.  
  185.    type GClosure is new Glib.C_Proxy; 
  186.  
  187.    Null_Handler_Id : constant Gulong := 0; 
  188.  
  189.    type Handler_Id is record 
  190.       Id      : Gulong := Null_Handler_Id; 
  191.       Closure : GClosure; 
  192.    end record; 
  193.    --  This uniquely identifies a connection widget<->signal. 
  194.    --  Closure is an internal data, that you should not use. 
  195.  
  196.    --------------------------------------------------------- 
  197.    --  These handlers should return a value 
  198.    --  They do not have a User_Data 
  199.    --------------------------------------------------------- 
  200.  
  201.    generic 
  202.       type Widget_Type is new Glib.Object.GObject_Record with private; 
  203.       type Return_Type is (<>); 
  204.    package Return_Callback is 
  205.  
  206.       type Handler is access function 
  207.         (Widget : access Widget_Type'Class; 
  208.          Params : Glib.Values.GValues) return Return_Type; 
  209.  
  210.       type Simple_Handler is access function 
  211.         (Widget : access Widget_Type'Class) return Return_Type; 
  212.  
  213.       package Marshallers is new Gtk.Marshallers.Return_Marshallers 
  214.         (Widget_Type, Return_Type); 
  215.  
  216.       --  Connecting a handler to an object 
  217.  
  218.       --  In all the Connect services below, the following arguments 
  219.       --  will be used: 
  220.       --    o Widget, Name: This represents the association (Gtk Object, 
  221.       --      Glib.Signal_Name) to which the handler is to be connected. 
  222.       --    o After: If this boolean is set to True, then the handler 
  223.       --      will be connected after all the default handlers. By 
  224.       --      default, it is set to False. 
  225.  
  226.       procedure Connect 
  227.         (Widget : access Widget_Type'Class; 
  228.          Name   : Glib.Signal_Name; 
  229.          Marsh  : Marshallers.Marshaller; 
  230.          After  : Boolean := False); 
  231.       --  Connects a Marshaller. The Handler_Id is dropped. 
  232.  
  233.       procedure Object_Connect 
  234.         (Widget      : access Glib.Object.GObject_Record'Class; 
  235.          Name        : Glib.Signal_Name; 
  236.          Marsh       : Marshallers.Marshaller; 
  237.          Slot_Object : access Widget_Type'Class; 
  238.          After       : Boolean := False); 
  239.       --  Connect a Marshaller. The Handler_Id is dropped. 
  240.       --  This is automatically disconnected as soon as either Widget or 
  241.       --  Slot_Object is destroyed. 
  242.       --  Slot_Object *must* be of type Gtk_Object or one of its children. 
  243.  
  244.       procedure Connect 
  245.         (Widget : access Widget_Type'Class; 
  246.          Name   : Glib.Signal_Name; 
  247.          Cb     : Simple_Handler; 
  248.          After  : Boolean := False); 
  249.       procedure Object_Connect 
  250.         (Widget      : access Glib.Object.GObject_Record'Class; 
  251.          Name        : Glib.Signal_Name; 
  252.          Cb          : Simple_Handler; 
  253.          Slot_Object : access Widget_Type'Class; 
  254.          After       : Boolean := False); 
  255.       --  Same as above, except with a simple handle with no parameter. This 
  256.       --  is the same as using a To_Marshaller call to the above two 
  257.       --  procedures, except it is shorter to write. 
  258.  
  259.       procedure Connect 
  260.         (Widget : access Widget_Type'Class; 
  261.          Name   : Glib.Signal_Name; 
  262.          Cb     : Handler; 
  263.          After  : Boolean := False); 
  264.       procedure Object_Connect 
  265.         (Widget      : access Glib.Object.GObject_Record'Class; 
  266.          Name        : Glib.Signal_Name; 
  267.          Cb          : Handler; 
  268.          Slot_Object : access Widget_Type'Class; 
  269.          After       : Boolean := False); 
  270.       --  Connect a Handler. The Handler_Id is dropped. 
  271.       --  This is automatically disconnected as soon as either Widget or 
  272.       --  Slot_Object is destroyed. 
  273.       --  Slot_Object *must* be of type Gtk_Object or one of its children. 
  274.  
  275.       pragma Inline (Connect); 
  276.       pragma Inline (Object_Connect); 
  277.  
  278.       function Connect 
  279.         (Widget : access Widget_Type'Class; 
  280.          Name   : Glib.Signal_Name; 
  281.          Marsh  : Marshallers.Marshaller; 
  282.          After  : Boolean := False) return Handler_Id; 
  283.       --  Connects a Marshaller. Returns the Handler_Id. 
  284.  
  285.       function Object_Connect 
  286.         (Widget      : access Glib.Object.GObject_Record'Class; 
  287.          Name        : Glib.Signal_Name; 
  288.          Marsh       : Marshallers.Marshaller; 
  289.          Slot_Object : access Widget_Type'Class; 
  290.          After       : Boolean := False) return Handler_Id; 
  291.       --  Connect a Marshaller. Return the Handler_Id. 
  292.       --  This is automatically disconnected as soon as either Widget or 
  293.       --  Slot_Object is destroyed. 
  294.       --  Slot_Object *must* be of type Gtk_Object or one of its children. 
  295.  
  296.       function Connect 
  297.         (Widget : access Widget_Type'Class; 
  298.          Name   : Glib.Signal_Name; 
  299.          Cb     : Handler; 
  300.          After  : Boolean := False) return Handler_Id; 
  301.       --  Connects a Handler. Returns the Handler_Id. 
  302.  
  303.       function Object_Connect 
  304.         (Widget      : access Glib.Object.GObject_Record'Class; 
  305.          Name        : Glib.Signal_Name; 
  306.          Cb          : Handler; 
  307.          Slot_Object : access Widget_Type'Class; 
  308.          After       : Boolean := False) return Handler_Id; 
  309.       --  Connect a Handler. Returns the Handler_Id. 
  310.       --  This is automatically disconnected as soon as either Widget or 
  311.       --  Slot_Object is destroyed. 
  312.       --  Slot_Object *must* be of type Gtk_Object or one of its children. 
  313.  
  314.       --  Some convenient functions to create marshallers 
  315.  
  316.       package Gint_Marshaller is new Marshallers.Generic_Marshaller 
  317.         (Gint, Glib.Values.Get_Int); 
  318.       package Guint_Marshaller is new Marshallers.Generic_Marshaller 
  319.         (Guint, Glib.Values.Get_Uint); 
  320.       package Event_Marshaller is new Marshallers.Generic_Marshaller 
  321.         (Gdk.Event.Gdk_Event, Gdk.Event.Get_Event); 
  322.       package Widget_Marshaller is new Marshallers.Generic_Widget_Marshaller 
  323.         (Gtk.Widget.Gtk_Widget_Record, Gtk.Widget.Gtk_Widget); 
  324.       package Notebook_Page_Marshaller is new Marshallers.Generic_Marshaller 
  325.         (Gtk.Notebook.Gtk_Notebook_Page, Gtk.Notebook.Get_Notebook_Page); 
  326.  
  327.       function To_Marshaller 
  328.         (Cb : Gint_Marshaller.Handler) 
  329.          return Marshallers.Marshaller renames Gint_Marshaller.To_Marshaller; 
  330.  
  331.       function To_Marshaller 
  332.         (Cb : Guint_Marshaller.Handler) 
  333.          return Marshallers.Marshaller renames Guint_Marshaller.To_Marshaller; 
  334.  
  335.       function To_Marshaller 
  336.         (Cb : Event_Marshaller.Handler) 
  337.          return Marshallers.Marshaller renames Event_Marshaller.To_Marshaller; 
  338.  
  339.       function To_Marshaller 
  340.         (Cb : Widget_Marshaller.Handler) 
  341.          return Marshallers.Marshaller renames Widget_Marshaller.To_Marshaller; 
  342.  
  343.       function To_Marshaller 
  344.         (Cb : Marshallers.Void_Marshaller.Handler) 
  345.          return Marshallers.Marshaller 
  346.          renames Marshallers.Void_Marshaller.To_Marshaller; 
  347.  
  348.       function To_Marshaller 
  349.         (Cb : Notebook_Page_Marshaller.Handler) 
  350.          return Marshallers.Marshaller 
  351.          renames Notebook_Page_Marshaller.To_Marshaller; 
  352.  
  353.       --  Emitting a signal 
  354.  
  355.       function Emit_By_Name 
  356.         (Object : access Widget_Type'Class; 
  357.          Name   : Glib.Signal_Name; 
  358.          Param  : Gint) 
  359.          return Return_Type renames Gint_Marshaller.Emit_By_Name; 
  360.  
  361.       function Emit_By_Name 
  362.         (Object : access Widget_Type'Class; 
  363.          Name   : Glib.Signal_Name; 
  364.          Param  : Guint) 
  365.          return Return_Type renames Guint_Marshaller.Emit_By_Name; 
  366.  
  367.       function Emit_By_Name 
  368.         (Object : access Widget_Type'Class; 
  369.          Name   : Glib.Signal_Name; 
  370.          Param  : Gdk.Event.Gdk_Event) return Return_Type; 
  371.  
  372.       function Emit_By_Name 
  373.         (Object : access Widget_Type'Class; 
  374.          Name   : Glib.Signal_Name; 
  375.          Param  : access Gtk.Widget.Gtk_Widget_Record'Class) 
  376.          return Return_Type renames Widget_Marshaller.Emit_By_Name; 
  377.  
  378.       function Emit_By_Name 
  379.         (Object : access Widget_Type'Class; 
  380.          Name   : Glib.Signal_Name) 
  381.          return Return_Type renames Marshallers.Void_Marshaller.Emit_By_Name; 
  382.  
  383.       function Emit_By_Name 
  384.         (Object : access Widget_Type'Class; 
  385.          Name   : Glib.Signal_Name; 
  386.          Param  : Gtk.Notebook.Gtk_Notebook_Page) 
  387.          return Return_Type renames Notebook_Page_Marshaller.Emit_By_Name; 
  388.  
  389.    private 
  390.       --  <doc_ignore> 
  391.       type Acc is access all Widget_Type'Class; 
  392.       --  This type has to be declared at library level, otherwise 
  393.       --  Program_Error might be raised when trying to cast from the 
  394.       --  parameter of Marshaller to another type. 
  395.  
  396.       type Data_Type_Record is record 
  397.          Func   : Handler; 
  398.          --  User's callback 
  399.  
  400.          Proxy  : Marshallers.Handler_Proxy := null; 
  401.          --  Handler_Proxy to use 
  402.  
  403.          Object : Acc := null; 
  404.          --  Slot Object for Object_Connect 
  405.       end record; 
  406.       type Data_Type_Access is access all Data_Type_Record; 
  407.       pragma Convention (C, Data_Type_Access); 
  408.       --  Data passed to the C handler 
  409.  
  410.       function Convert is new Unchecked_Conversion 
  411.         (Data_Type_Access, System.Address); 
  412.       function Convert is new Unchecked_Conversion 
  413.         (System.Address, Data_Type_Access); 
  414.  
  415.       procedure Free_Data (Data : Data_Type_Access); 
  416.       pragma Convention (C, Free_Data); 
  417.       --  Free the memory associated with the callback's data 
  418.  
  419.       procedure First_Marshaller 
  420.         (Closure         : GClosure; 
  421.          Return_Value    : Glib.Values.GValue; 
  422.          N_Params        : Guint; 
  423.          Params          : System.Address; 
  424.          Invocation_Hint : System.Address; 
  425.          User_Data       : System.Address); 
  426.       pragma Convention (C, First_Marshaller); 
  427.       --  First level marshaller. This is the function that is actually 
  428.       --  called by gtk+. It then calls the Ada functions as required. 
  429.       --  </doc_ignore> 
  430.  
  431.    end Return_Callback; 
  432.  
  433.    --------------------------------------------------------- 
  434.    --  These handlers should return a value 
  435.    --  They require a User_Data 
  436.    --  See also the package User_Callback_With_Setup 
  437.    --------------------------------------------------------- 
  438.  
  439.    generic 
  440.       type Widget_Type is new Glib.Object.GObject_Record with private; 
  441.       type Return_Type is (<>); 
  442.       type User_Type (<>) is private; 
  443.    package User_Return_Callback is 
  444.  
  445.       type Handler is access function 
  446.         (Widget    : access Widget_Type'Class; 
  447.          Params    : Glib.Values.GValues; 
  448.          User_Data : User_Type) return Return_Type; 
  449.       type Simple_Handler is access function 
  450.         (Widget    : access Widget_Type'Class; 
  451.          User_Data : User_Type) return Return_Type; 
  452.  
  453.       package Marshallers is new Gtk.Marshallers.User_Return_Marshallers 
  454.         (Widget_Type, Return_Type, User_Type); 
  455.  
  456.       --  Connecting a handler to an object 
  457.  
  458.       procedure Connect 
  459.         (Widget    : access Widget_Type'Class; 
  460.          Name      : Glib.Signal_Name; 
  461.          Marsh     : Marshallers.Marshaller; 
  462.          User_Data : User_Type; 
  463.          After     : Boolean := False); 
  464.       procedure Object_Connect 
  465.         (Widget      : access Glib.Object.GObject_Record'Class; 
  466.          Name        : Glib.Signal_Name; 
  467.          Marsh       : Marshallers.Marshaller; 
  468.          Slot_Object : access Widget_Type'Class; 
  469.          User_Data   : User_Type; 
  470.          After       : Boolean := False); 
  471.  
  472.       procedure Connect 
  473.         (Widget    : access Widget_Type'Class; 
  474.          Name      : Glib.Signal_Name; 
  475.          Cb        : Simple_Handler; 
  476.          User_Data : User_Type; 
  477.          After     : Boolean := False); 
  478.       procedure Object_Connect 
  479.         (Widget      : access Glib.Object.GObject_Record'Class; 
  480.          Name        : Glib.Signal_Name; 
  481.          Cb          : Simple_Handler; 
  482.          Slot_Object : access Widget_Type'Class; 
  483.          User_Data   : User_Type; 
  484.          After       : Boolean := False); 
  485.  
  486.       procedure Connect 
  487.         (Widget    : access Widget_Type'Class; 
  488.          Name      : Glib.Signal_Name; 
  489.          Cb        : Handler; 
  490.          User_Data : User_Type; 
  491.          After     : Boolean := False); 
  492.       procedure Object_Connect 
  493.         (Widget      : access Glib.Object.GObject_Record'Class; 
  494.          Name        : Glib.Signal_Name; 
  495.          Cb          : Handler; 
  496.          Slot_Object : access Widget_Type'Class; 
  497.          User_Data   : User_Type; 
  498.          After       : Boolean := False); 
  499.  
  500.       pragma Inline (Connect); 
  501.  
  502.       function Connect 
  503.         (Widget    : access Widget_Type'Class; 
  504.          Name      : Glib.Signal_Name; 
  505.          Marsh     : Marshallers.Marshaller; 
  506.          User_Data : User_Type; 
  507.          After     : Boolean := False) return Handler_Id; 
  508.  
  509.       function Object_Connect 
  510.         (Widget      : access Glib.Object.GObject_Record'Class; 
  511.          Name        : Glib.Signal_Name; 
  512.          Marsh       : Marshallers.Marshaller; 
  513.          Slot_Object : access Widget_Type'Class; 
  514.          User_Data   : User_Type; 
  515.          After       : Boolean := False) return Handler_Id; 
  516.  
  517.       function Connect 
  518.         (Widget    : access Widget_Type'Class; 
  519.          Name      : Glib.Signal_Name; 
  520.          Cb        : Handler; 
  521.          User_Data : User_Type; 
  522.          After     : Boolean := False) return Handler_Id; 
  523.  
  524.       function Object_Connect 
  525.         (Widget      : access Glib.Object.GObject_Record'Class; 
  526.          Name        : Glib.Signal_Name; 
  527.          Cb          : Handler; 
  528.          Slot_Object : access Widget_Type'Class; 
  529.          User_Data   : User_Type; 
  530.          After       : Boolean := False) return Handler_Id; 
  531.  
  532.       --  Some convenient functions to create marshallers 
  533.  
  534.       package Gint_Marshaller is new Marshallers.Generic_Marshaller 
  535.         (Gint, Glib.Values.Get_Int); 
  536.       package Guint_Marshaller is new Marshallers.Generic_Marshaller 
  537.         (Guint, Glib.Values.Get_Uint); 
  538.       package Event_Marshaller is new Marshallers.Generic_Marshaller 
  539.         (Gdk.Event.Gdk_Event, Gdk.Event.Get_Event); 
  540.       package Widget_Marshaller is new Marshallers.Generic_Widget_Marshaller 
  541.         (Gtk.Widget.Gtk_Widget_Record, Gtk.Widget.Gtk_Widget); 
  542.       package Notebook_Page_Marshaller is new Marshallers.Generic_Marshaller 
  543.         (Gtk.Notebook.Gtk_Notebook_Page, Gtk.Notebook.Get_Notebook_Page); 
  544.  
  545.       function To_Marshaller 
  546.         (Cb : Gint_Marshaller.Handler) 
  547.          return Marshallers.Marshaller renames Gint_Marshaller.To_Marshaller; 
  548.  
  549.       function To_Marshaller 
  550.         (Cb : Guint_Marshaller.Handler) 
  551.          return Marshallers.Marshaller renames Guint_Marshaller.To_Marshaller; 
  552.  
  553.       function To_Marshaller 
  554.         (Cb : Event_Marshaller.Handler) 
  555.          return Marshallers.Marshaller renames Event_Marshaller.To_Marshaller; 
  556.  
  557.       function To_Marshaller 
  558.         (Cb : Widget_Marshaller.Handler) 
  559.          return Marshallers.Marshaller renames Widget_Marshaller.To_Marshaller; 
  560.  
  561.       function To_Marshaller 
  562.         (Cb : Marshallers.Void_Marshaller.Handler) 
  563.          return Marshallers.Marshaller 
  564.          renames Marshallers.Void_Marshaller.To_Marshaller; 
  565.  
  566.       function To_Marshaller 
  567.         (Cb : Notebook_Page_Marshaller.Handler) 
  568.          return Marshallers.Marshaller 
  569.          renames Notebook_Page_Marshaller.To_Marshaller; 
  570.  
  571.       --  Emitting a signal 
  572.  
  573.       function Emit_By_Name 
  574.         (Object : access Widget_Type'Class; 
  575.          Name   : Glib.Signal_Name; 
  576.          Param  : Gint) 
  577.          return Return_Type renames Gint_Marshaller.Emit_By_Name; 
  578.  
  579.       function Emit_By_Name 
  580.         (Object : access Widget_Type'Class; 
  581.          Name   : Glib.Signal_Name; 
  582.          Param  : Guint) 
  583.          return Return_Type renames Guint_Marshaller.Emit_By_Name; 
  584.  
  585.       function Emit_By_Name 
  586.         (Object : access Widget_Type'Class; 
  587.          Name   : Glib.Signal_Name; 
  588.          Param  : Gdk.Event.Gdk_Event) return Return_Type; 
  589.  
  590.       function Emit_By_Name 
  591.         (Object : access Widget_Type'Class; 
  592.          Name   : Glib.Signal_Name; 
  593.          Param  : access Gtk.Widget.Gtk_Widget_Record'Class) 
  594.          return Return_Type renames Widget_Marshaller.Emit_By_Name; 
  595.  
  596.       function Emit_By_Name 
  597.         (Object : access Widget_Type'Class; 
  598.          Name   : Glib.Signal_Name) 
  599.          return Return_Type renames Marshallers.Void_Marshaller.Emit_By_Name; 
  600.  
  601.       function Emit_By_Name 
  602.         (Object : access Widget_Type'Class; 
  603.          Name   : Glib.Signal_Name; 
  604.          Param  : Gtk.Notebook.Gtk_Notebook_Page) 
  605.          return Return_Type renames Notebook_Page_Marshaller.Emit_By_Name; 
  606.  
  607.    private 
  608.       --  <doc_ignore> 
  609.       type Acc is access all Widget_Type'Class; 
  610.       --  This type has to be declared at library level, otherwise 
  611.       --  Program_Error might be raised when trying to cast from the 
  612.       --  parameter of Marshaller to another type. 
  613.  
  614.       type User_Access is access User_Type; 
  615.       type Data_Type_Record is record 
  616.          Func   : Handler; 
  617.          --  User's callback 
  618.  
  619.          Proxy  : Marshallers.Handler_Proxy := null; 
  620.          --  Handler_Proxy to use 
  621.  
  622.          User   : User_Access := null; 
  623.          Object : Acc := null; 
  624.          --  Slot Object for Object_Connect 
  625.       end record; 
  626.       type Data_Type_Access is access all Data_Type_Record; 
  627.       pragma Convention (C, Data_Type_Access); 
  628.       --  Data passed to the C handler 
  629.  
  630.       function Convert is new Unchecked_Conversion 
  631.         (Data_Type_Access, System.Address); 
  632.       function Convert is new Unchecked_Conversion 
  633.         (System.Address, Data_Type_Access); 
  634.  
  635.       procedure Free_Data (Data : Data_Type_Access); 
  636.       pragma Convention (C, Free_Data); 
  637.       --  Free the memory associated with the callback's data 
  638.  
  639.       procedure First_Marshaller 
  640.         (Closure         : GClosure; 
  641.          Return_Value    : Glib.Values.GValue; 
  642.          N_Params        : Guint; 
  643.          Params          : System.Address; 
  644.          Invocation_Hint : System.Address; 
  645.          User_Data       : System.Address); 
  646.       pragma Convention (C, First_Marshaller); 
  647.       --  First level marshaller. This is the function that is actually 
  648.       --  called by gtk+. It then calls the Ada functions as required. 
  649.       --  </doc_ignore> 
  650.  
  651.    end User_Return_Callback; 
  652.  
  653.    ------------------------------------- 
  654.    -- User_Return_Callback_With_Setup -- 
  655.    ------------------------------------- 
  656.    --  This package is basically the same as User_Return_Callback, except that 
  657.    --  an extra function (Setup) is called after a handler has been 
  658.    --  connected. Typical usage is to automatically call Add_Watch (see below) 
  659.    --  in case the User_Type is (or contains) widgets. 
  660.  
  661.    generic 
  662.       type Widget_Type is new Glib.Object.GObject_Record with private; 
  663.       type Return_Type is (<>); 
  664.       type User_Type (<>) is private; 
  665.       with procedure Setup (User_Data : User_Type; Id : Handler_Id); 
  666.    package User_Return_Callback_With_Setup is 
  667.  
  668.       package Internal_Cb is new User_Return_Callback 
  669.         (Widget_Type, Return_Type, User_Type); 
  670.  
  671.       subtype Handler is Internal_Cb.Handler; 
  672.       subtype Simple_Handler is Internal_Cb.Simple_Handler; 
  673.       package Marshallers renames Internal_Cb.Marshallers; 
  674.  
  675.       --  Connecting a handler to an object 
  676.  
  677.       procedure Connect 
  678.         (Widget    : access Widget_Type'Class; 
  679.          Name      : Glib.Signal_Name; 
  680.          Marsh     : Marshallers.Marshaller; 
  681.          User_Data : User_Type; 
  682.          After     : Boolean := False); 
  683.       procedure Object_Connect 
  684.         (Widget      : access Glib.Object.GObject_Record'Class; 
  685.          Name        : Glib.Signal_Name; 
  686.          Marsh       : Marshallers.Marshaller; 
  687.          Slot_Object : access Widget_Type'Class; 
  688.          User_Data   : User_Type; 
  689.          After       : Boolean := False); 
  690.  
  691.       procedure Connect 
  692.         (Widget    : access Widget_Type'Class; 
  693.          Name      : Glib.Signal_Name; 
  694.          Cb        : Handler; 
  695.          User_Data : User_Type; 
  696.          After     : Boolean := False); 
  697.       procedure Object_Connect 
  698.         (Widget      : access Glib.Object.GObject_Record'Class; 
  699.          Name        : Glib.Signal_Name; 
  700.          Cb          : Handler; 
  701.          Slot_Object : access Widget_Type'Class; 
  702.          User_Data   : User_Type; 
  703.          After       : Boolean := False); 
  704.  
  705.       procedure Connect 
  706.         (Widget    : access Widget_Type'Class; 
  707.          Name      : Glib.Signal_Name; 
  708.          Cb        : Simple_Handler; 
  709.          User_Data : User_Type; 
  710.          After     : Boolean := False); 
  711.       procedure Object_Connect 
  712.         (Widget      : access Glib.Object.GObject_Record'Class; 
  713.          Name        : Glib.Signal_Name; 
  714.          Cb          : Simple_Handler; 
  715.          Slot_Object : access Widget_Type'Class; 
  716.          User_Data   : User_Type; 
  717.          After       : Boolean := False); 
  718.  
  719.       pragma Inline (Connect); 
  720.  
  721.       function Connect 
  722.         (Widget    : access Widget_Type'Class; 
  723.          Name      : Glib.Signal_Name; 
  724.          Marsh     : Marshallers.Marshaller; 
  725.          User_Data : User_Type; 
  726.          After     : Boolean := False) return Handler_Id; 
  727.  
  728.       function Object_Connect 
  729.         (Widget      : access Glib.Object.GObject_Record'Class; 
  730.          Name        : Glib.Signal_Name; 
  731.          Marsh       : Marshallers.Marshaller; 
  732.          Slot_Object : access Widget_Type'Class; 
  733.          User_Data   : User_Type; 
  734.          After       : Boolean := False) return Handler_Id; 
  735.  
  736.       function Connect 
  737.         (Widget    : access Widget_Type'Class; 
  738.          Name      : Glib.Signal_Name; 
  739.          Cb        : Handler; 
  740.          User_Data : User_Type; 
  741.          After     : Boolean := False) return Handler_Id; 
  742.  
  743.       function Object_Connect 
  744.         (Widget      : access Glib.Object.GObject_Record'Class; 
  745.          Name        : Glib.Signal_Name; 
  746.          Cb          : Handler; 
  747.          Slot_Object : access Widget_Type'Class; 
  748.          User_Data   : User_Type; 
  749.          After       : Boolean := False) return Handler_Id; 
  750.  
  751.       --  Some convenient functions to create marshallers 
  752.  
  753.       package Gint_Marshaller renames Internal_Cb.Gint_Marshaller; 
  754.       package Guint_Marshaller renames Internal_Cb.Guint_Marshaller; 
  755.       package Event_Marshaller renames Internal_Cb.Event_Marshaller; 
  756.       package Widget_Marshaller renames Internal_Cb.Widget_Marshaller; 
  757.       package Notebook_Page_Marshaller 
  758.         renames Internal_Cb.Notebook_Page_Marshaller; 
  759.  
  760.       function To_Marshaller 
  761.         (Cb : Gint_Marshaller.Handler) 
  762.          return Internal_Cb.Marshallers.Marshaller 
  763.          renames Internal_Cb.To_Marshaller; 
  764.       function To_Marshaller 
  765.         (Cb : Guint_Marshaller.Handler) 
  766.          return Internal_Cb.Marshallers.Marshaller 
  767.          renames Internal_Cb.To_Marshaller; 
  768.       function To_Marshaller 
  769.         (Cb : Event_Marshaller.Handler) 
  770.          return Internal_Cb.Marshallers.Marshaller 
  771.          renames Internal_Cb.To_Marshaller; 
  772.       function To_Marshaller 
  773.         (Cb : Widget_Marshaller.Handler) 
  774.          return Internal_Cb.Marshallers.Marshaller 
  775.          renames Internal_Cb.To_Marshaller; 
  776.       function To_Marshaller 
  777.         (Cb : Internal_Cb.Marshallers.Void_Marshaller.Handler) 
  778.          return Internal_Cb.Marshallers.Marshaller 
  779.          renames Internal_Cb.To_Marshaller; 
  780.       function To_Marshaller 
  781.         (Cb : Notebook_Page_Marshaller.Handler) 
  782.          return Internal_Cb.Marshallers.Marshaller 
  783.          renames Internal_Cb.To_Marshaller; 
  784.  
  785.       --  Emitting a signal 
  786.  
  787.       function Emit_By_Name 
  788.         (Object : access Widget_Type'Class; 
  789.          Name   : Glib.Signal_Name; 
  790.          Param  : Gint) return Return_Type renames Internal_Cb.Emit_By_Name; 
  791.  
  792.       function Emit_By_Name 
  793.         (Object : access Widget_Type'Class; 
  794.          Name   : Glib.Signal_Name; 
  795.          Param  : Guint) return Return_Type renames Internal_Cb.Emit_By_Name; 
  796.  
  797.       function Emit_By_Name 
  798.         (Object : access Widget_Type'Class; 
  799.          Name   : Glib.Signal_Name; 
  800.          Param  : Gdk.Event.Gdk_Event) return Return_Type 
  801.          renames Internal_Cb.Emit_By_Name; 
  802.  
  803.       function Emit_By_Name 
  804.         (Object : access Widget_Type'Class; 
  805.          Name   : Glib.Signal_Name; 
  806.          Param  : access Gtk.Widget.Gtk_Widget_Record'Class) 
  807.          return Return_Type renames Internal_Cb.Emit_By_Name; 
  808.  
  809.       function Emit_By_Name 
  810.         (Object : access Widget_Type'Class; 
  811.          Name   : Glib.Signal_Name) 
  812.          return Return_Type renames Internal_Cb.Emit_By_Name; 
  813.  
  814.       function Emit_By_Name 
  815.         (Object : access Widget_Type'Class; 
  816.          Name   : Glib.Signal_Name; 
  817.          Param  : Gtk.Notebook.Gtk_Notebook_Page) 
  818.          return Return_Type renames Internal_Cb.Emit_By_Name; 
  819.  
  820.    end User_Return_Callback_With_Setup; 
  821.  
  822.    --------------------------------------------------------- 
  823.    --  These handlers do not return a value 
  824.    --  They do not have a User_Data 
  825.    --------------------------------------------------------- 
  826.  
  827.    generic 
  828.       type Widget_Type is new Glib.Object.GObject_Record with private; 
  829.    package Callback is 
  830.  
  831.       type Handler is access procedure 
  832.         (Widget : access Widget_Type'Class; 
  833.          Params : Glib.Values.GValues); 
  834.       type Simple_Handler is access procedure 
  835.         (Widget : access Widget_Type'Class); 
  836.  
  837.       package Marshallers is new 
  838.         Gtk.Marshallers.Void_Marshallers (Widget_Type); 
  839.  
  840.       --  Connecting a handler to an object 
  841.  
  842.       procedure Connect 
  843.         (Widget : access Widget_Type'Class; 
  844.          Name   : Glib.Signal_Name; 
  845.          Marsh  : Marshallers.Marshaller; 
  846.          After  : Boolean := False); 
  847.       procedure Object_Connect 
  848.         (Widget      : access Glib.Object.GObject_Record'Class; 
  849.          Name        : Glib.Signal_Name; 
  850.          Marsh       : Marshallers.Marshaller; 
  851.          Slot_Object : access Widget_Type'Class; 
  852.          After       : Boolean := False); 
  853.  
  854.       procedure Connect 
  855.         (Widget : access Widget_Type'Class; 
  856.          Name   : Glib.Signal_Name; 
  857.          Cb     : Handler; 
  858.          After  : Boolean := False); 
  859.       procedure Object_Connect 
  860.         (Widget      : access Glib.Object.GObject_Record'Class; 
  861.          Name        : Glib.Signal_Name; 
  862.          Cb          : Handler; 
  863.          Slot_Object : access Widget_Type'Class; 
  864.          After       : Boolean := False); 
  865.  
  866.       procedure Connect 
  867.         (Widget : access Widget_Type'Class; 
  868.          Name   : Glib.Signal_Name; 
  869.          Cb     : Simple_Handler; 
  870.          After  : Boolean := False); 
  871.       procedure Object_Connect 
  872.         (Widget      : access Glib.Object.GObject_Record'Class; 
  873.          Name        : Glib.Signal_Name; 
  874.          Cb          : Simple_Handler; 
  875.          Slot_Object : access Widget_Type'Class; 
  876.          After       : Boolean := False); 
  877.  
  878.       pragma Inline (Connect); 
  879.       pragma Inline (Object_Connect); 
  880.  
  881.       function Connect 
  882.         (Widget : access Widget_Type'Class; 
  883.          Name   : Glib.Signal_Name; 
  884.          Marsh  : Marshallers.Marshaller; 
  885.          After  : Boolean := False) return Handler_Id; 
  886.  
  887.       function Object_Connect 
  888.         (Widget      : access Glib.Object.GObject_Record'Class; 
  889.          Name        : Glib.Signal_Name; 
  890.          Marsh       : Marshallers.Marshaller; 
  891.          Slot_Object : access Widget_Type'Class; 
  892.          After       : Boolean := False) return Handler_Id; 
  893.  
  894.       function Connect 
  895.         (Widget : access Widget_Type'Class; 
  896.          Name   : Glib.Signal_Name; 
  897.          Cb     : Handler; 
  898.          After  : Boolean := False) return Handler_Id; 
  899.  
  900.       function Object_Connect 
  901.         (Widget      : access Glib.Object.GObject_Record'Class; 
  902.          Name        : Glib.Signal_Name; 
  903.          Cb          : Handler; 
  904.          Slot_Object : access Widget_Type'Class; 
  905.          After       : Boolean := False) return Handler_Id; 
  906.  
  907.       --  Some convenient functions to create marshallers 
  908.  
  909.       package Gint_Marshaller is new Marshallers.Generic_Marshaller 
  910.         (Gint, Glib.Values.Get_Int); 
  911.       package Guint_Marshaller is new Marshallers.Generic_Marshaller 
  912.         (Guint, Glib.Values.Get_Uint); 
  913.       package Event_Marshaller is new Marshallers.Generic_Marshaller 
  914.         (Gdk.Event.Gdk_Event, Gdk.Event.Get_Event); 
  915.       package Widget_Marshaller is new Marshallers.Generic_Widget_Marshaller 
  916.         (Gtk.Widget.Gtk_Widget_Record, Gtk.Widget.Gtk_Widget); 
  917.       package Notebook_Page_Marshaller is new Marshallers.Generic_Marshaller 
  918.         (Gtk.Notebook.Gtk_Notebook_Page, Gtk.Notebook.Get_Notebook_Page); 
  919.       package Tree_Path_Marshaller is new Marshallers.Generic_Marshaller 
  920.         (Gtk.Tree_Model.Gtk_Tree_Path, Gtk.Tree_Model.Get_Tree_Path); 
  921.       package Tree_Iter_Tree_Path_Marshaller is 
  922.          new Marshallers.Generic_Marshaller_2 
  923.                (Gtk.Tree_Model.Gtk_Tree_Iter, Gtk.Tree_Model.Get_Tree_Iter, 
  924.                 Gtk.Tree_Model.Gtk_Tree_Path, Gtk.Tree_Model.Get_Tree_Path); 
  925.       package Tree_Path_Tree_Iter_Marshaller is 
  926.          new Marshallers.Generic_Marshaller_2 
  927.                (Gtk.Tree_Model.Gtk_Tree_Path, Gtk.Tree_Model.Get_Tree_Path, 
  928.                 Gtk.Tree_Model.Gtk_Tree_Iter, Gtk.Tree_Model.Get_Tree_Iter); 
  929.  
  930.       function To_Marshaller 
  931.         (Cb : Gint_Marshaller.Handler) 
  932.          return Marshallers.Marshaller renames Gint_Marshaller.To_Marshaller; 
  933.  
  934.       function To_Marshaller 
  935.         (Cb : Guint_Marshaller.Handler) 
  936.          return Marshallers.Marshaller renames Guint_Marshaller.To_Marshaller; 
  937.  
  938.       function To_Marshaller 
  939.         (Cb : Event_Marshaller.Handler) 
  940.          return Marshallers.Marshaller renames Event_Marshaller.To_Marshaller; 
  941.  
  942.       function To_Marshaller 
  943.         (Cb : Widget_Marshaller.Handler) 
  944.          return Marshallers.Marshaller renames Widget_Marshaller.To_Marshaller; 
  945.  
  946.       function To_Marshaller 
  947.         (Cb : Marshallers.Void_Marshaller.Handler) 
  948.          return Marshallers.Marshaller 
  949.          renames Marshallers.Void_Marshaller.To_Marshaller; 
  950.  
  951.       function To_Marshaller 
  952.         (Cb : Notebook_Page_Marshaller.Handler) 
  953.          return Marshallers.Marshaller 
  954.          renames Notebook_Page_Marshaller.To_Marshaller; 
  955.  
  956.       function To_Marshaller 
  957.         (Cb : Tree_Path_Marshaller.Handler) 
  958.          return Marshallers.Marshaller 
  959.          renames Tree_Path_Marshaller.To_Marshaller; 
  960.  
  961.       function To_Marshaller 
  962.         (Cb : Tree_Iter_Tree_Path_Marshaller.Handler) 
  963.          return Marshallers.Marshaller 
  964.          renames Tree_Iter_Tree_Path_Marshaller.To_Marshaller; 
  965.  
  966.       function To_Marshaller 
  967.         (Cb : Tree_Path_Tree_Iter_Marshaller.Handler) 
  968.          return Marshallers.Marshaller 
  969.          renames Tree_Path_Tree_Iter_Marshaller.To_Marshaller; 
  970.  
  971.       --  Emitting a signal 
  972.  
  973.       procedure Emit_By_Name 
  974.         (Object : access Widget_Type'Class; 
  975.          Name   : Glib.Signal_Name; 
  976.          Param  : Gint) renames Gint_Marshaller.Emit_By_Name; 
  977.  
  978.       procedure Emit_By_Name 
  979.         (Object : access Widget_Type'Class; 
  980.          Name   : Glib.Signal_Name; 
  981.          Param  : Guint) renames Guint_Marshaller.Emit_By_Name; 
  982.  
  983.       procedure Emit_By_Name 
  984.          (Object : access Widget_Type'Class; 
  985.           Name   : Glib.Signal_Name; 
  986.           Param  : Gdk.Event.Gdk_Event); 
  987.  
  988.       procedure Emit_By_Name 
  989.         (Object : access Widget_Type'Class; 
  990.          Name   : Glib.Signal_Name; 
  991.          Param  : access Gtk.Widget.Gtk_Widget_Record'Class) 
  992.          renames Widget_Marshaller.Emit_By_Name; 
  993.  
  994.       procedure Emit_By_Name 
  995.         (Object : access Widget_Type'Class; 
  996.          Name   : Glib.Signal_Name) 
  997.          renames Marshallers.Void_Marshaller.Emit_By_Name; 
  998.  
  999.       procedure Emit_By_Name 
  1000.         (Object : access Widget_Type'Class; 
  1001.          Name   : Glib.Signal_Name; 
  1002.          Param  : Gtk.Notebook.Gtk_Notebook_Page) 
  1003.          renames Notebook_Page_Marshaller.Emit_By_Name; 
  1004.  
  1005.       procedure Emit_By_Name is 
  1006.         new Tree_Path_Marshaller.Emit_By_Name_Generic 
  1007.               (Gtk.Tree_Model.To_Address); 
  1008.  
  1009.       procedure Emit_By_Name is 
  1010.         new Tree_Iter_Tree_Path_Marshaller.Emit_By_Name_Generic 
  1011.               (Gtk.Tree_Model.To_Address, 
  1012.                Gtk.Tree_Model.To_Address); 
  1013.  
  1014.       procedure Emit_By_Name is 
  1015.         new Tree_Path_Tree_Iter_Marshaller.Emit_By_Name_Generic 
  1016.               (Gtk.Tree_Model.To_Address, 
  1017.                Gtk.Tree_Model.To_Address); 
  1018.  
  1019.    private 
  1020.       --  <doc_ignore> 
  1021.       type Acc is access all Widget_Type'Class; 
  1022.       --  This type has to be declared at library level, otherwise 
  1023.       --  Program_Error might be raised when trying to cast from the 
  1024.       --  parameter of Marshaller to another type. 
  1025.  
  1026.       type Data_Type_Record is record 
  1027.          Func   : Handler;             --  User's callback 
  1028.          Proxy  : Marshallers.Handler_Proxy := null;  --  Handler_Proxy to use 
  1029.          Object : Acc := null;         --  Slot Object for Object_Connect 
  1030.       end record; 
  1031.       type Data_Type_Access is access all Data_Type_Record; 
  1032.       pragma Convention (C, Data_Type_Access); 
  1033.       --  Data passed to the C handler 
  1034.  
  1035.       function Convert is new Unchecked_Conversion 
  1036.         (Data_Type_Access, System.Address); 
  1037.       function Convert is new Unchecked_Conversion 
  1038.         (System.Address, Data_Type_Access); 
  1039.  
  1040.       procedure Free_Data (Data : Data_Type_Access); 
  1041.       pragma Convention (C, Free_Data); 
  1042.       --  Free the memory associated with the callback's data 
  1043.  
  1044.       procedure First_Marshaller 
  1045.         (Closure         : GClosure; 
  1046.          Return_Value    : Glib.Values.GValue; 
  1047.          N_Params        : Guint; 
  1048.          Params          : System.Address; 
  1049.          Invocation_Hint : System.Address; 
  1050.          User_Data       : System.Address); 
  1051.       pragma Convention (C, First_Marshaller); 
  1052.       --  First level marshaller. This is the function that is actually 
  1053.       --  called by gtk+. It then calls the Ada functions as required. 
  1054.       --  </doc_ignore> 
  1055.  
  1056.    end Callback; 
  1057.  
  1058.    --------------------------------------------------------- 
  1059.    --  These handlers do not return a value 
  1060.    --  They require a User_Data 
  1061.    --  See also the package User_Callback_With_Setup 
  1062.    --------------------------------------------------------- 
  1063.  
  1064.    generic 
  1065.       type Widget_Type is new Glib.Object.GObject_Record with private; 
  1066.       type User_Type (<>) is private; 
  1067.    package User_Callback is 
  1068.  
  1069.       type Handler is access procedure 
  1070.         (Widget    : access Widget_Type'Class; 
  1071.          Params    : Glib.Values.GValues; 
  1072.          User_Data : User_Type); 
  1073.       type Simple_Handler is access procedure 
  1074.         (Widget    : access Widget_Type'Class; 
  1075.          User_Data : User_Type); 
  1076.  
  1077.       package Marshallers is new 
  1078.         Gtk.Marshallers.User_Void_Marshallers (Widget_Type, User_Type); 
  1079.  
  1080.       --  Connecting a handler to an object 
  1081.  
  1082.       procedure Connect 
  1083.         (Widget    : access Widget_Type'Class; 
  1084.          Name      : Glib.Signal_Name; 
  1085.          Marsh     : Marshallers.Marshaller; 
  1086.          User_Data : User_Type; 
  1087.          After     : Boolean := False); 
  1088.       procedure Object_Connect 
  1089.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1090.          Name        : Glib.Signal_Name; 
  1091.          Marsh       : Marshallers.Marshaller; 
  1092.          Slot_Object : access Widget_Type'Class; 
  1093.          User_Data   : User_Type; 
  1094.          After       : Boolean := False); 
  1095.  
  1096.       procedure Connect 
  1097.         (Widget    : access Widget_Type'Class; 
  1098.          Name      : Glib.Signal_Name; 
  1099.          Cb        : Handler; 
  1100.          User_Data : User_Type; 
  1101.          After     : Boolean := False); 
  1102.       procedure Object_Connect 
  1103.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1104.          Name        : Glib.Signal_Name; 
  1105.          Cb          : Handler; 
  1106.          Slot_Object : access Widget_Type'Class; 
  1107.          User_Data   : User_Type; 
  1108.          After       : Boolean := False); 
  1109.  
  1110.       procedure Connect 
  1111.         (Widget    : access Widget_Type'Class; 
  1112.          Name      : Glib.Signal_Name; 
  1113.          Cb        : Simple_Handler; 
  1114.          User_Data : User_Type; 
  1115.          After     : Boolean := False); 
  1116.       procedure Object_Connect 
  1117.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1118.          Name        : Glib.Signal_Name; 
  1119.          Cb          : Simple_Handler; 
  1120.          Slot_Object : access Widget_Type'Class; 
  1121.          User_Data   : User_Type; 
  1122.          After       : Boolean := False); 
  1123.  
  1124.       pragma Inline (Connect); 
  1125.  
  1126.       function Connect 
  1127.         (Widget    : access Widget_Type'Class; 
  1128.          Name      : Glib.Signal_Name; 
  1129.          Marsh     : Marshallers.Marshaller; 
  1130.          User_Data : User_Type; 
  1131.          After     : Boolean := False) return Handler_Id; 
  1132.  
  1133.       function Object_Connect 
  1134.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1135.          Name        : Glib.Signal_Name; 
  1136.          Marsh       : Marshallers.Marshaller; 
  1137.          Slot_Object : access Widget_Type'Class; 
  1138.          User_Data   : User_Type; 
  1139.          After       : Boolean := False) return Handler_Id; 
  1140.  
  1141.       function Connect 
  1142.         (Widget    : access Widget_Type'Class; 
  1143.          Name      : Glib.Signal_Name; 
  1144.          Cb        : Handler; 
  1145.          User_Data : User_Type; 
  1146.          After     : Boolean := False) return Handler_Id; 
  1147.  
  1148.       function Object_Connect 
  1149.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1150.          Name        : Glib.Signal_Name; 
  1151.          Cb          : Handler; 
  1152.          Slot_Object : access Widget_Type'Class; 
  1153.          User_Data   : User_Type; 
  1154.          After       : Boolean := False) return Handler_Id; 
  1155.  
  1156.       --  Some convenient functions to create marshallers 
  1157.  
  1158.       package Gint_Marshaller is new Marshallers.Generic_Marshaller 
  1159.         (Gint, Glib.Values.Get_Int); 
  1160.       package Guint_Marshaller is new Marshallers.Generic_Marshaller 
  1161.         (Guint, Glib.Values.Get_Uint); 
  1162.       package Event_Marshaller is new Marshallers.Generic_Marshaller 
  1163.         (Gdk.Event.Gdk_Event, Gdk.Event.Get_Event); 
  1164.       package Widget_Marshaller is new Marshallers.Generic_Widget_Marshaller 
  1165.         (Gtk.Widget.Gtk_Widget_Record, Gtk.Widget.Gtk_Widget); 
  1166.       package Notebook_Page_Marshaller is new Marshallers.Generic_Marshaller 
  1167.         (Gtk.Notebook.Gtk_Notebook_Page, Gtk.Notebook.Get_Notebook_Page); 
  1168.       package Tree_Path_Marshaller is new Marshallers.Generic_Marshaller 
  1169.         (Gtk.Tree_Model.Gtk_Tree_Path, Gtk.Tree_Model.Get_Tree_Path); 
  1170.       package Tree_Iter_Tree_Path_Marshaller is 
  1171.          new Marshallers.Generic_Marshaller_2 
  1172.                (Gtk.Tree_Model.Gtk_Tree_Iter, Gtk.Tree_Model.Get_Tree_Iter, 
  1173.                 Gtk.Tree_Model.Gtk_Tree_Path, Gtk.Tree_Model.Get_Tree_Path); 
  1174.       package Tree_Path_Tree_Iter_Marshaller is 
  1175.          new Marshallers.Generic_Marshaller_2 
  1176.                (Gtk.Tree_Model.Gtk_Tree_Path, Gtk.Tree_Model.Get_Tree_Path, 
  1177.                 Gtk.Tree_Model.Gtk_Tree_Iter, Gtk.Tree_Model.Get_Tree_Iter); 
  1178.  
  1179.       function To_Marshaller 
  1180.         (Cb : Gint_Marshaller.Handler) 
  1181.          return Marshallers.Marshaller renames Gint_Marshaller.To_Marshaller; 
  1182.  
  1183.       function To_Marshaller 
  1184.         (Cb : Guint_Marshaller.Handler) 
  1185.          return Marshallers.Marshaller renames Guint_Marshaller.To_Marshaller; 
  1186.  
  1187.       function To_Marshaller 
  1188.         (Cb : Event_Marshaller.Handler) 
  1189.          return Marshallers.Marshaller renames Event_Marshaller.To_Marshaller; 
  1190.  
  1191.       function To_Marshaller 
  1192.         (Cb : Widget_Marshaller.Handler) 
  1193.          return Marshallers.Marshaller renames Widget_Marshaller.To_Marshaller; 
  1194.  
  1195.       function To_Marshaller 
  1196.         (Cb : Marshallers.Void_Marshaller.Handler) 
  1197.          return Marshallers.Marshaller 
  1198.          renames Marshallers.Void_Marshaller.To_Marshaller; 
  1199.  
  1200.       function To_Marshaller 
  1201.         (Cb : Notebook_Page_Marshaller.Handler) 
  1202.          return Marshallers.Marshaller 
  1203.          renames Notebook_Page_Marshaller.To_Marshaller; 
  1204.  
  1205.       function To_Marshaller 
  1206.         (Cb : Tree_Path_Marshaller.Handler) 
  1207.          return Marshallers.Marshaller 
  1208.          renames Tree_Path_Marshaller.To_Marshaller; 
  1209.  
  1210.       function To_Marshaller 
  1211.         (Cb : Tree_Iter_Tree_Path_Marshaller.Handler) 
  1212.          return Marshallers.Marshaller 
  1213.          renames Tree_Iter_Tree_Path_Marshaller.To_Marshaller; 
  1214.  
  1215.       function To_Marshaller 
  1216.         (Cb : Tree_Path_Tree_Iter_Marshaller.Handler) 
  1217.          return Marshallers.Marshaller 
  1218.          renames Tree_Path_Tree_Iter_Marshaller.To_Marshaller; 
  1219.  
  1220.       --  Emitting a signal 
  1221.  
  1222.       procedure Emit_By_Name 
  1223.         (Object : access Widget_Type'Class; 
  1224.          Name   : Glib.Signal_Name; 
  1225.          Param  : Gint) renames Gint_Marshaller.Emit_By_Name; 
  1226.  
  1227.       procedure Emit_By_Name 
  1228.         (Object : access Widget_Type'Class; 
  1229.          Name   : Glib.Signal_Name; 
  1230.          Param  : Guint) renames Guint_Marshaller.Emit_By_Name; 
  1231.  
  1232.       procedure Emit_By_Name 
  1233.         (Object : access Widget_Type'Class; 
  1234.          Name   : Glib.Signal_Name; 
  1235.          Param  : Gdk.Event.Gdk_Event); 
  1236.  
  1237.       procedure Emit_By_Name 
  1238.         (Object : access Widget_Type'Class; 
  1239.          Name   : Glib.Signal_Name; 
  1240.          Param  : access Gtk.Widget.Gtk_Widget_Record'Class) 
  1241.          renames Widget_Marshaller.Emit_By_Name; 
  1242.  
  1243.       procedure Emit_By_Name 
  1244.         (Object : access Widget_Type'Class; 
  1245.          Name   : Glib.Signal_Name) 
  1246.          renames Marshallers.Void_Marshaller.Emit_By_Name; 
  1247.  
  1248.       procedure Emit_By_Name 
  1249.         (Object : access Widget_Type'Class; 
  1250.          Name   : Glib.Signal_Name; 
  1251.          Param  : Gtk.Notebook.Gtk_Notebook_Page) 
  1252.          renames Notebook_Page_Marshaller.Emit_By_Name; 
  1253.  
  1254.       procedure Emit_By_Name is 
  1255.         new Tree_Path_Marshaller.Emit_By_Name_Generic 
  1256.               (Gtk.Tree_Model.To_Address); 
  1257.  
  1258.       procedure Emit_By_Name is 
  1259.         new Tree_Iter_Tree_Path_Marshaller.Emit_By_Name_Generic 
  1260.               (Gtk.Tree_Model.To_Address, 
  1261.                Gtk.Tree_Model.To_Address); 
  1262.  
  1263.       procedure Emit_By_Name is 
  1264.         new Tree_Path_Tree_Iter_Marshaller.Emit_By_Name_Generic 
  1265.               (Gtk.Tree_Model.To_Address, 
  1266.                Gtk.Tree_Model.To_Address); 
  1267.  
  1268.    private 
  1269.       --  <doc_ignore> 
  1270.       type Acc is access all Widget_Type'Class; 
  1271.       --  This type has to be declared at library level, otherwise 
  1272.       --  Program_Error might be raised when trying to cast from the 
  1273.       --  parameter of Marshaller to another type. 
  1274.  
  1275.       type User_Access is access User_Type; 
  1276.       type Data_Type_Record is record 
  1277.          Func   : Handler; 
  1278.          --  User's callback 
  1279.  
  1280.          Proxy  : Marshallers.Handler_Proxy := null; 
  1281.          --  Handler_Proxy to use 
  1282.  
  1283.          User   : User_Access := null; 
  1284.          Object : Acc := null; 
  1285.          --  Slot_Object for Object_Connect 
  1286.       end record; 
  1287.       type Data_Type_Access is access all Data_Type_Record; 
  1288.       pragma Convention (C, Data_Type_Access); 
  1289.       --  Data passed to the C handler 
  1290.  
  1291.       function Convert is new Unchecked_Conversion 
  1292.         (Data_Type_Access, System.Address); 
  1293.       function Convert is new Unchecked_Conversion 
  1294.         (System.Address, Data_Type_Access); 
  1295.  
  1296.       procedure Free_Data (Data : Data_Type_Access); 
  1297.       pragma Convention (C, Free_Data); 
  1298.       --  Free the memory associated with the callback's data 
  1299.  
  1300.       procedure First_Marshaller 
  1301.         (Closure         : GClosure; 
  1302.          Return_Value    : Glib.Values.GValue; 
  1303.          N_Params        : Guint; 
  1304.          Params          : System.Address; 
  1305.          Invocation_Hint : System.Address; 
  1306.          User_Data       : System.Address); 
  1307.       pragma Convention (C, First_Marshaller); 
  1308.       --  First level marshaller. This is the function that is actually 
  1309.       --  called by gtk+. It then calls the Ada functions as required. 
  1310.       --  </doc_ignore> 
  1311.  
  1312.    end User_Callback; 
  1313.  
  1314.    ------------------------------ 
  1315.    -- User_Callback_With_Setup -- 
  1316.    ------------------------------ 
  1317.    --  This package is basically the same as User_Callback, except that an 
  1318.    --  extra function (Setup) is called after a handler has been 
  1319.    --  connected. Typical usage is to automatically call Add_Watch (see below) 
  1320.    --  in case the User_Type is (or contains) widgets. 
  1321.  
  1322.    generic 
  1323.       type Widget_Type is new Glib.Object.GObject_Record with private; 
  1324.       type User_Type (<>) is private; 
  1325.       with procedure Setup (User_Data : User_Type; Id : Handler_Id); 
  1326.    package User_Callback_With_Setup is 
  1327.  
  1328.       package Internal_Cb is new User_Callback (Widget_Type, User_Type); 
  1329.       package Marshallers renames Internal_Cb.Marshallers; 
  1330.  
  1331.       subtype Handler is Internal_Cb.Handler; 
  1332.       subtype Simple_Handler is Internal_Cb.Simple_Handler; 
  1333.  
  1334.       --  Connecting a handler to an object 
  1335.  
  1336.       procedure Connect 
  1337.         (Widget    : access Widget_Type'Class; 
  1338.          Name      : Glib.Signal_Name; 
  1339.          Marsh     : Marshallers.Marshaller; 
  1340.          User_Data : User_Type; 
  1341.          After     : Boolean := False); 
  1342.       procedure Object_Connect 
  1343.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1344.          Name        : Glib.Signal_Name; 
  1345.          Marsh       : Marshallers.Marshaller; 
  1346.          Slot_Object : access Widget_Type'Class; 
  1347.          User_Data   : User_Type; 
  1348.          After       : Boolean := False); 
  1349.  
  1350.       procedure Connect 
  1351.         (Widget    : access Widget_Type'Class; 
  1352.          Name      : Glib.Signal_Name; 
  1353.          Cb        : Handler; 
  1354.          User_Data : User_Type; 
  1355.          After     : Boolean := False); 
  1356.       procedure Object_Connect 
  1357.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1358.          Name        : Glib.Signal_Name; 
  1359.          Cb          : Handler; 
  1360.          Slot_Object : access Widget_Type'Class; 
  1361.          User_Data   : User_Type; 
  1362.          After       : Boolean := False); 
  1363.  
  1364.       procedure Connect 
  1365.         (Widget    : access Widget_Type'Class; 
  1366.          Name      : Glib.Signal_Name; 
  1367.          Cb        : Simple_Handler; 
  1368.          User_Data : User_Type; 
  1369.          After     : Boolean := False); 
  1370.       procedure Object_Connect 
  1371.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1372.          Name        : Glib.Signal_Name; 
  1373.          Cb          : Simple_Handler; 
  1374.          Slot_Object : access Widget_Type'Class; 
  1375.          User_Data   : User_Type; 
  1376.          After       : Boolean := False); 
  1377.  
  1378.       pragma Inline (Connect); 
  1379.  
  1380.       function Connect 
  1381.         (Widget    : access Widget_Type'Class; 
  1382.          Name      : Glib.Signal_Name; 
  1383.          Marsh     : Marshallers.Marshaller; 
  1384.          User_Data : User_Type; 
  1385.          After     : Boolean := False) return Handler_Id; 
  1386.  
  1387.       function Object_Connect 
  1388.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1389.          Name        : Glib.Signal_Name; 
  1390.          Marsh       : Marshallers.Marshaller; 
  1391.          Slot_Object : access Widget_Type'Class; 
  1392.          User_Data   : User_Type; 
  1393.          After       : Boolean := False) return Handler_Id; 
  1394.  
  1395.       function Connect 
  1396.         (Widget    : access Widget_Type'Class; 
  1397.          Name      : Glib.Signal_Name; 
  1398.          Cb        : Handler; 
  1399.          User_Data : User_Type; 
  1400.          After     : Boolean := False) return Handler_Id; 
  1401.  
  1402.       function Object_Connect 
  1403.         (Widget      : access Glib.Object.GObject_Record'Class; 
  1404.          Name        : Glib.Signal_Name; 
  1405.          Cb          : Handler; 
  1406.          Slot_Object : access Widget_Type'Class; 
  1407.          User_Data   : User_Type; 
  1408.          After       : Boolean := False) return Handler_Id; 
  1409.  
  1410.       --  Some convenient functions to create marshallers 
  1411.  
  1412.       package Gint_Marshaller renames Internal_Cb.Gint_Marshaller; 
  1413.       package Guint_Marshaller renames Internal_Cb.Guint_Marshaller; 
  1414.       package Event_Marshaller renames Internal_Cb.Event_Marshaller; 
  1415.       package Widget_Marshaller renames Internal_Cb.Widget_Marshaller; 
  1416.       package Notebook_Page_Marshaller 
  1417.         renames Internal_Cb.Notebook_Page_Marshaller; 
  1418.  
  1419.       function To_Marshaller 
  1420.         (Cb : Gint_Marshaller.Handler) 
  1421.          return Internal_Cb.Marshallers.Marshaller 
  1422.          renames Internal_Cb.To_Marshaller; 
  1423.       function To_Marshaller 
  1424.         (Cb : Guint_Marshaller.Handler) 
  1425.          return Internal_Cb.Marshallers.Marshaller 
  1426.          renames Internal_Cb.To_Marshaller; 
  1427.       function To_Marshaller 
  1428.         (Cb : Event_Marshaller.Handler) 
  1429.          return Internal_Cb.Marshallers.Marshaller 
  1430.          renames Internal_Cb.To_Marshaller; 
  1431.       function To_Marshaller 
  1432.         (Cb : Widget_Marshaller.Handler) 
  1433.          return Internal_Cb.Marshallers.Marshaller 
  1434.          renames Internal_Cb.To_Marshaller; 
  1435.       function To_Marshaller 
  1436.         (Cb : Internal_Cb.Marshallers.Void_Marshaller.Handler) 
  1437.          return Internal_Cb.Marshallers.Marshaller 
  1438.          renames Internal_Cb.To_Marshaller; 
  1439.       function To_Marshaller 
  1440.         (Cb : Notebook_Page_Marshaller.Handler) 
  1441.          return Internal_Cb.Marshallers.Marshaller 
  1442.          renames Internal_Cb.To_Marshaller; 
  1443.  
  1444.       --  Emitting a signal 
  1445.  
  1446.       procedure Emit_By_Name 
  1447.         (Object : access Widget_Type'Class; 
  1448.          Name   : Glib.Signal_Name; 
  1449.          Param  : Gint) renames Internal_Cb.Emit_By_Name; 
  1450.  
  1451.       procedure Emit_By_Name 
  1452.         (Object : access Widget_Type'Class; 
  1453.          Name   : Glib.Signal_Name; 
  1454.          Param  : Guint) renames Internal_Cb.Emit_By_Name; 
  1455.  
  1456.       procedure Emit_By_Name 
  1457.         (Object : access Widget_Type'Class; 
  1458.          Name   : Glib.Signal_Name; 
  1459.          Param  : Gdk.Event.Gdk_Event) renames Internal_Cb.Emit_By_Name; 
  1460.  
  1461.       procedure Emit_By_Name 
  1462.         (Object : access Widget_Type'Class; 
  1463.          Name   : Glib.Signal_Name; 
  1464.          Param  : access Gtk.Widget.Gtk_Widget_Record'Class) 
  1465.          renames Internal_Cb.Emit_By_Name; 
  1466.  
  1467.       procedure Emit_By_Name 
  1468.         (Object : access Widget_Type'Class; 
  1469.          Name   : Glib.Signal_Name) renames Internal_Cb.Emit_By_Name; 
  1470.  
  1471.       procedure Emit_By_Name 
  1472.         (Object : access Widget_Type'Class; 
  1473.          Name   : Glib.Signal_Name; 
  1474.          Param  : Gtk.Notebook.Gtk_Notebook_Page) 
  1475.          renames Internal_Cb.Emit_By_Name; 
  1476.  
  1477.    end User_Callback_With_Setup; 
  1478.  
  1479.    ------------------------------------------------------------------ 
  1480.    --  General functions 
  1481.    ------------------------------------------------------------------ 
  1482.  
  1483.    procedure Add_Watch 
  1484.      (Id : Handler_Id; Object : access Glib.Object.GObject_Record'Class); 
  1485.    --  Make sure that when Object is destroyed, the handler Id is also 
  1486.    --  destroyed. This function should mostly be used in cases where you use a 
  1487.    --  User_Data that is Object. If you don't destroy the callback at the same 
  1488.    --  time, then the next time the callback is called it will try to access 
  1489.    --  some invalid memory (Object being destroyed), and you will likely get a 
  1490.    --  Storage_Error. 
  1491.  
  1492.    procedure Disconnect 
  1493.      (Object : access Glib.Object.GObject_Record'Class; 
  1494.       Id     : in out Handler_Id); 
  1495.    --  Disconnect the handler identified by the given Handler_Id. 
  1496.  
  1497.    procedure Emit_Stop_By_Name 
  1498.      (Object : access Glib.Object.GObject_Record'Class; 
  1499.       Name   : Glib.Signal_Name); 
  1500.    --  During a signal emission, invoking this procedure will halt the 
  1501.    --  emission. 
  1502.  
  1503.    procedure Handler_Block 
  1504.      (Obj : access Glib.Object.GObject_Record'Class; 
  1505.       Id  : Handler_Id); 
  1506.    --  Blocks temporily the signal. For each call to this procedure, 
  1507.    --  a call to Handler_Unblock must be performed in order to really 
  1508.    --  unblock the signal. 
  1509.  
  1510.    procedure Handlers_Destroy 
  1511.      (Obj : access Glib.Object.GObject_Record'Class); 
  1512.    --  Destroys all the handlers associated to the given object. 
  1513.  
  1514.    procedure Handler_Unblock 
  1515.      (Obj : access Glib.Object.GObject_Record'Class; 
  1516.       Id  : Handler_Id); 
  1517.    --  See Handler_Block. 
  1518.  
  1519.    --  </doc_ignore> 
  1520.  
  1521. end Gtk.Handlers; 
  1522.  
  1523. --  <example> 
  1524. --  --  This example connects the "delete_event" signal to a widget. 
  1525. --  --  The handlers for this signal get an extra argument which is 
  1526. --  --  the Gdk_Event that generated the signal. 
  1527. -- 
  1528. --  with Gtk.Handlers;    use Gtk.Handlers; 
  1529. --  with Gtk.Marshallers; use Gtk.Marshallers; 
  1530. -- 
  1531. --  function My_Cb (Widget : access Gtk_Widget_Record'Class; 
  1532. --                  Event  : Gdk.Event.Gdk_Event) 
  1533. --                  return Gint; 
  1534. --  --  your own function 
  1535. -- 
  1536. --  package Return_Widget_Cb is new Gtk.Handlers.Return_Callback 
  1537. --     (Gtk.Widget.Gtk_Widget_Record, Gint); 
  1538. -- 
  1539. --  Return_Widget_Cb.Connect (W, "delete_event", 
  1540. --     Return_Widget_Cb.To_Marshaller (My_Cb'Access)); 
  1541. -- 
  1542. --  </example>