1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                    Copyright (C) 2010, 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 
  26. -- 
  27. --  A Gtk_Builder is an auxiliary object that reads textual descriptions of a 
  28. --  user interface and instantiates the described objects. To pass a 
  29. --  description to a Gtk_Builder, call Add_From_File or Add_From_String. 
  30. --  These subprograms can be called multiple times; the builder merges the 
  31. --  content of all descriptions. 
  32. -- 
  33. --  A Gtk_Builder holds a reference to all objects that it has constructed and 
  34. --  drops these references when it is finalized. This finalization can cause 
  35. --  the destruction of non-widget objects or widgets which are not contained 
  36. --  in a toplevel window. For toplevel windows constructed by a builder, it is 
  37. --  the responsibility of the user to call Gtk.Widget.Destroy to get rid of 
  38. --  them and all the widgets they contain. 
  39. -- 
  40. --  The subprogram Get_Object can be used to access the widgets in the 
  41. --  interface by the names assigned to them inside the UI description. 
  42. --  Toplevel windows returned by this subprogram will stay around until the 
  43. --  user explicitly destroys them with Gtk.Widget.Destroy. 
  44. --  Other widgets will either be part of a larger hierarchy constructed by 
  45. --  the builder (in which case you should not have to worry about their 
  46. --  lifecycle), or without a parent, in which case they have to be added 
  47. --  to some container to make use of them. Non-widget objects need to be 
  48. --  reffed with Glib.Object.Ref to keep them beyond the lifespan of the 
  49. --  builder. 
  50. -- 
  51. --  The subprogram Connect_Signals_Full can be used to connect handlers to the 
  52. --  named signals in the description. 
  53. --  </description> 
  54. --  <c_version>2.16.6</c_version> 
  55.  
  56. with System; 
  57. with Glib; 
  58. with Glib.Error; 
  59. with Glib.Object; 
  60. with Glib.Properties; 
  61. with Interfaces.C.Strings; 
  62.  
  63. package Gtk.Builder is 
  64.  
  65.    type Gtk_Builder_Record is new Glib.Object.GObject_Record with private; 
  66.    type Gtk_Builder is access all Gtk_Builder_Record'Class; 
  67.  
  68.    function Get_Type return GType; 
  69.  
  70.    procedure Gtk_New (Builder : out Gtk_Builder); 
  71.    procedure Initialize (Builder : access Gtk_Builder_Record'Class); 
  72.    --  Creates a new Gtk_Builder object. 
  73.  
  74.    function Error_Quark return GQuark; 
  75.  
  76.    function Add_From_File 
  77.      (Builder  : access Gtk_Builder_Record; 
  78.       Filename : String) 
  79.       return Glib.Error.GError; 
  80.    --  Parses a file containing a Gtk_Builder UI definition and merges it with 
  81.    --  the current contents of builder. 
  82.    --  Returns: A GError if an error occured, otherwise null. 
  83.  
  84.    function Add_From_String 
  85.      (Builder : access Gtk_Builder_Record; 
  86.       Buffer  : String; 
  87.       Length  : Gsize) 
  88.       return Glib.Error.GError; 
  89.    --  Parses a string containing a Gtk_Builder UI definition and merges it 
  90.    --  with the current contents of Builder. 
  91.    --  Returns: A GError if an error occured, otherwise null. 
  92.  
  93.    function Get_Object 
  94.      (Builder     : access Gtk_Builder_Record; 
  95.       Object_Name : String) 
  96.       return Glib.Object.GObject; 
  97.    --  Gets the object named Object_Name. Note that this function does not 
  98.    --  increment the reference count of the returned object.  Returns null 
  99.    --  if it could not be found in the object tree. 
  100.  
  101.    ------------------------ 
  102.    -- Connecting signals -- 
  103.    ------------------------ 
  104.  
  105.    --  The following is a low-level binding to Gtk+. 
  106.    --  See create_builder.adb in the testgtk source for an example of how 
  107.    --  to use this low-level binding in an applications. 
  108.  
  109.    type Gtk_Builder_Connect_Func is access procedure 
  110.      (Builder        : System.Address; 
  111.       Object         : System.Address; 
  112.       Signal_Name    : Interfaces.C.Strings.chars_ptr; 
  113.       Handler_Name   : Interfaces.C.Strings.chars_ptr; 
  114.       Connect_Object : System.Address; 
  115.       Flags          : Glib.G_Connect_Flags; 
  116.       User_Data      : System.Address); 
  117.    pragma Convention (C, Gtk_Builder_Connect_Func); 
  118.    --  This is the signature of a subprogram used to connect signals. It is 
  119.    --  used by the Connect_Signals and Connect_Signals_Full methods. 
  120.    -- 
  121.    --  Parameters: 
  122.    --     Builder:        The address of a Gtk_Builder 
  123.    --     Object:         The object to connect a signal to 
  124.    --     Signal_Name:    The name of the signal 
  125.    --     Handler_Name:   The name of the handler 
  126.    --     Connect_Object: The internal address of a GObject 
  127.    --     Flags:          G_Connect_Flags to use 
  128.    --     User_Data:      user data 
  129.  
  130.    procedure Connect_Signals_Full 
  131.      (Builder         : access Gtk_Builder_Record; 
  132.       Signal_Function : Gtk_Builder_Connect_Func; 
  133.       User_Data       : System.Address); 
  134.    --  This function can be thought of the interpreted language binding 
  135.    --  version of Connect_Signals, except that it does not require GModule 
  136.    --  to function correctly. 
  137.  
  138.    ---------------- 
  139.    -- Properties -- 
  140.    ---------------- 
  141.  
  142.    --  <properties> 
  143.    --  Name:  Translation_Domain_Property 
  144.    --  Type:  String 
  145.    --  Descr: The translation domain used by gettext 
  146.    -- 
  147.    --  </properties> 
  148.  
  149.    Translation_Domain_Property : constant Glib.Properties.Property_String; 
  150.  
  151. private 
  152.  
  153.    type Gtk_Builder_Record is new Glib.Object.GObject_Record with null record; 
  154.  
  155.    Translation_Domain_Property : constant Glib.Properties.Property_String := 
  156.      Glib.Properties.Build ("translation-domain"); 
  157.  
  158.    pragma Import (C, Error_Quark, "gtk_builder_error_quark"); 
  159.    pragma Import (C, Get_Type, "gtk_builder_get_type"); 
  160.  
  161. end Gtk.Builder;