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