1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                  Copyright (C) 2010-2011, AdaCore                 -- 
  5. --                                                                   -- 
  6. -- This library is free software; you can redistribute it and/or     -- 
  7. -- modify it under the terms of the GNU General Public               -- 
  8. -- License as published by the Free Software Foundation; either      -- 
  9. -- version 2 of the License, or (at your option) any later version.  -- 
  10. --                                                                   -- 
  11. -- This library is distributed in the hope that it will be useful,   -- 
  12. -- but WITHOUT ANY WARRANTY; without even the implied warranty of    -- 
  13. -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU -- 
  14. -- General Public License for more details.                          -- 
  15. --                                                                   -- 
  16. -- You should have received a copy of the GNU General Public         -- 
  17. -- License along with this library; if not, write to the             -- 
  18. -- Free Software Foundation, Inc., 59 Temple Place - Suite 330,      -- 
  19. -- Boston, MA 02111-1307, USA.                                       -- 
  20. --                                                                   -- 
  21. -- -- -- -- -- -- -- -- -- -- -- --
  22. ----------------------------------------------------------------------- 
  23.  
  24. --  <description> 
  25. --  Gtk.Builder - Build an interface from an XML UI definition as produced by 
  26. --  the Glade-3 GUI builder. 
  27. -- 
  28. --  Note that GtkAda provides a higher-level API for using the GUI builder, 
  29. --  in Gtkada.Builder. 
  30. -- 
  31. --  A Gtk_Builder is an auxiliary object that reads textual descriptions of a 
  32. --  user interface and instantiates the described objects. To pass a 
  33. --  description to a Gtk_Builder, call Add_From_File or Add_From_String. 
  34. --  These subprograms can be called multiple times; the builder merges the 
  35. --  content of all descriptions. 
  36. -- 
  37. --  A Gtk_Builder holds a reference to all objects that it has constructed and 
  38. --  drops these references when it is finalized. This finalization can cause 
  39. --  the destruction of non-widget objects or widgets which are not contained 
  40. --  in a toplevel window. For toplevel windows constructed by a builder, it is 
  41. --  the responsibility of the user to call Gtk.Widget.Destroy to get rid of 
  42. --  them and all the widgets they contain. 
  43. -- 
  44. --  The subprograms Get_Object and Get_Widget can be used to access the widgets 
  45. --  in the interface by the names assigned to them inside the UI description. 
  46. --  Toplevel windows returned by this subprogram will stay around until the 
  47. --  user explicitly destroys them with Gtk.Widget.Destroy. 
  48. --  Other widgets will either be part of a larger hierarchy constructed by 
  49. --  the builder (in which case you should not have to worry about their 
  50. --  lifecycle), or without a parent, in which case they have to be added 
  51. --  to some container to make use of them. Non-widget objects need to be 
  52. --  reffed with Glib.Object.Ref to keep them beyond the lifespan of the 
  53. --  builder. 
  54. -- 
  55. --  The subprogram Connect_Signals_Full can be used to connect handlers to the 
  56. --  named signals in the description. 
  57. --  </description> 
  58. --  <group>GUI Builder</group> 
  59. --  <c_version>2.16.6</c_version> 
  60.  
  61. with System; 
  62. with Interfaces.C.Strings; 
  63.  
  64. with Glib; 
  65. with Glib.Error; 
  66. with Glib.Object; 
  67. with Glib.Properties; 
  68.  
  69. with Gtk.Widget; 
  70.  
  71. package Gtk.Builder is 
  72.  
  73.    type Gtk_Builder_Record is new Glib.Object.GObject_Record with private; 
  74.    type Gtk_Builder is access all Gtk_Builder_Record'Class; 
  75.  
  76.    function Get_Type return GType; 
  77.  
  78.    procedure Gtk_New (Builder : out Gtk_Builder); 
  79.    procedure Initialize (Builder : access Gtk_Builder_Record'Class); 
  80.    --  Creates a new Gtk_Builder object. 
  81.  
  82.    function Error_Quark return GQuark; 
  83.  
  84.    function Add_From_File 
  85.      (Builder  : access Gtk_Builder_Record; 
  86.       Filename : String) 
  87.       return Glib.Error.GError; 
  88.    --  Parses a file containing a Gtk_Builder UI definition and merges it with 
  89.    --  the current contents of builder. 
  90.    --  Returns: A GError if an error occured, otherwise null. 
  91.  
  92.    function Add_From_String 
  93.      (Builder : access Gtk_Builder_Record; 
  94.       Buffer  : String; 
  95.       Length  : Gsize) 
  96.       return Glib.Error.GError; 
  97.    --  Parses a string containing a Gtk_Builder UI definition and merges it 
  98.    --  with the current contents of Builder. 
  99.    --  Returns: A GError if an error occured, otherwise null. 
  100.  
  101.    function Get_Object 
  102.      (Builder     : access Gtk_Builder_Record; 
  103.       Object_Name : String) 
  104.       return Glib.Object.GObject; 
  105.    --  Gets the object named Object_Name. Note that this function does not 
  106.    --  increment the reference count of the returned object.  Returns null 
  107.    --  if it could not be found in the object tree. 
  108.    --  See also Get_Widget below. 
  109.  
  110.    function Get_Widget 
  111.      (Builder : access Gtk_Builder_Record; 
  112.       Name    : String) return Gtk.Widget.Gtk_Widget; 
  113.    --  Utility function to retrieve a widget created by Builder. 
  114.    --  Returns null if no widget was found with the given name. 
  115.  
  116.    ------------------------ 
  117.    -- Connecting signals -- 
  118.    ------------------------ 
  119.  
  120.    --  The following is a low-level binding to Gtk+. 
  121.    -- 
  122.    --  You should not need to use this directly. Instead, use a 
  123.    --  Gtkada.Builder.Gtkada_Builder and use the procedures Register_Handler 
  124.    --  to connect your callbacks to signals defined in the GUI builder. 
  125.  
  126.    type Gtk_Builder_Connect_Func is access procedure 
  127.      (Builder        : System.Address; 
  128.       Object         : System.Address; 
  129.       Signal_Name    : Interfaces.C.Strings.chars_ptr; 
  130.       Handler_Name   : Interfaces.C.Strings.chars_ptr; 
  131.       Connect_Object : System.Address; 
  132.       Flags          : Glib.G_Connect_Flags; 
  133.       User_Data      : System.Address); 
  134.    pragma Convention (C, Gtk_Builder_Connect_Func); 
  135.    --  This is the signature of a subprogram used to connect signals. It is 
  136.    --  used by the Connect_Signals and Connect_Signals_Full methods. 
  137.    -- 
  138.    --  Parameters: 
  139.    --     Builder:        The address of a Gtk_Builder 
  140.    --     Object:         The object to connect a signal to 
  141.    --     Signal_Name:    The name of the signal 
  142.    --     Handler_Name:   The name of the handler 
  143.    --     Connect_Object: The internal address of a GObject 
  144.    --     Flags:          G_Connect_Flags to use 
  145.    --     User_Data:      user data 
  146.  
  147.    procedure Connect_Signals_Full 
  148.      (Builder         : access Gtk_Builder_Record; 
  149.       Signal_Function : Gtk_Builder_Connect_Func; 
  150.       User_Data       : System.Address); 
  151.    --  This function can be thought of the interpreted language binding 
  152.    --  version of Connect_Signals, except that it does not require GModule 
  153.    --  to function correctly. 
  154.  
  155.    ---------------- 
  156.    -- Properties -- 
  157.    ---------------- 
  158.  
  159.    --  <properties> 
  160.    --  Name:  Translation_Domain_Property 
  161.    --  Type:  String 
  162.    --  Descr: The translation domain used by gettext 
  163.    -- 
  164.    --  </properties> 
  165.  
  166.    Translation_Domain_Property : constant Glib.Properties.Property_String; 
  167.  
  168. private 
  169.  
  170.    type Gtk_Builder_Record is new Glib.Object.GObject_Record with null record; 
  171.  
  172.    Translation_Domain_Property : constant Glib.Properties.Property_String := 
  173.      Glib.Properties.Build ("translation-domain"); 
  174.  
  175.    pragma Import (C, Error_Quark, "gtk_builder_error_quark"); 
  176.    pragma Import (C, Get_Type, "gtk_builder_get_type"); 
  177.  
  178. end Gtk.Builder;