1. ------------------------------------------------------------------------------ 
  2. --                  GtkAda - Ada95 binding for Gtk+/Gnome                   -- 
  3. --                                                                          -- 
  4. --                     Copyright (C) 2001-2014, AdaCore                     -- 
  5. --                                                                          -- 
  6. -- This library is free software;  you can redistribute it and/or modify it -- 
  7. -- under terms of the  GNU General Public License  as published by the Free -- 
  8. -- Software  Foundation;  either version 3,  or (at your  option) any later -- 
  9. -- version. This library is distributed in the hope that it will be useful, -- 
  10. -- but WITHOUT ANY WARRANTY;  without even the implied warranty of MERCHAN- -- 
  11. -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.                            -- 
  12. --                                                                          -- 
  13. -- As a special exception under Section 7 of GPL version 3, you are granted -- 
  14. -- additional permissions described in the GCC Runtime Library Exception,   -- 
  15. -- version 3.1, as published by the Free Software Foundation.               -- 
  16. --                                                                          -- 
  17. -- You should have received a copy of the GNU General Public License and    -- 
  18. -- a copy of the GCC Runtime Library Exception along with this program;     -- 
  19. -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    -- 
  20. -- <http://www.gnu.org/licenses/>.                                          -- 
  21. --                                                                          -- 
  22. ------------------------------------------------------------------------------ 
  23.  
  24. --  <description> 
  25. --  Properties are a fully general way to modify the appareance or behavior 
  26. --  of widgets. Most of the time, there exists a faster way to modify the 
  27. --  widget in the same fashion (for instance a direct call to a primitive 
  28. --  subprogram). However, the properties provide a general scheme to modify 
  29. --  these attributes. 
  30. --  For instance, they can be used to provide introspection on the widget 
  31. --  (to automatically retrieve the attributes that can be modified), or if 
  32. --  you need to implement a tool like a GUI-Builder that is able to 
  33. --  manipulate any widget, even those that didn't exist when the tool was 
  34. --  written. 
  35. -- 
  36. --  Two functions are provided for each type of property: Set_Property and 
  37. --  Get_Property, which allow easy modification of specific widget 
  38. --  properties. For instance, you could do the following: 
  39. --      declare 
  40. --          Button : Gtk_Button; 
  41. --      begin 
  42. --          Gtk_New (Button, "old label"); 
  43. --          Set_Property (Button, Label_Property, "new label"); 
  44. --      end; 
  45. --  to modify the label of a button. 
  46. -- 
  47. --  Likewise, you can retrieve the current label with: 
  48. --      Current : String := Get_Property (Button, Label_Property); 
  49. -- 
  50. --  Dispatching is used ensure type-safety while using properties. The 
  51. --  appropriate Set_Property/Get_Property functions are called depending 
  52. --  on the type of the property you are trying to use. This is checked 
  53. --  statically by the compiler, which provides additional type-safety 
  54. --  compared to the C library. 
  55. -- 
  56. --  Note that some properties are read-only, and thus do not have the 
  57. --  Set_Property subprogram defined. 
  58. -- 
  59. --  When a property is modified, the signal "notify::<property>" is emitted, 
  60. --  for instance, "notify::label" for a gtk_button. This is a standard gtk+ 
  61. --  signal to which you can connect with the subprograms in gtk-handlers.ads 
  62.  
  63. --  </description> 
  64. --  <c_version>1.3.4</c_version> 
  65. --  <group>Glib, the general-purpose library</group> 
  66.  
  67. with Glib.Object; 
  68. with Glib.Generic_Properties; use Glib.Generic_Properties; 
  69. pragma Elaborate_All (Glib.Generic_Properties); 
  70. with System; 
  71. with Glib.Types; 
  72. with Glib.Values; 
  73.  
  74. package Glib.Properties is 
  75.  
  76.    --  <doc_ignore> 
  77.  
  78.    --  Definition of the types and subprograms. 
  79.    --  You can ignore this section. 
  80.  
  81.    package Char_Properties is new 
  82.      Generic_Internal_Discrete_Property (Glib.Gchar); 
  83.    package Uchar_Properties is new 
  84.      Generic_Internal_Discrete_Property (Glib.Guchar); 
  85.    package Int_Properties is new 
  86.      Generic_Internal_Discrete_Property (Glib.Gint); 
  87.    package Uint_Properties is new 
  88.      Generic_Internal_Discrete_Property (Glib.Guint); 
  89.    package Long_Properties is new 
  90.      Generic_Internal_Discrete_Property (Glib.Glong); 
  91.    package Ulong_Properties is new 
  92.      Generic_Internal_Discrete_Property (Glib.Gulong); 
  93.    package Unichar_Properties is new 
  94.      Generic_Internal_Discrete_Property (Glib.Gunichar); 
  95.  
  96.    --  </doc_ignore> 
  97.  
  98.    --  Predefined types of properties. Additional types are available 
  99.    --  for most of the standard enumeration types, and you can create 
  100.    --  your own types (see Glib.Properties). 
  101.  
  102.    type Property_Char      is new Char_Properties.Property; 
  103.    type Property_Char_RO   is new Char_Properties.Property_RO; 
  104.    type Property_Uchar     is new Uchar_Properties.Property; 
  105.    type Property_Uchar_RO  is new Uchar_Properties.Property_RO; 
  106.    type Property_Int       is new Int_Properties.Property; 
  107.    type Property_Uint_RO   is new Uint_Properties.Property_RO; 
  108.    type Property_Uint      is new Uint_Properties.Property; 
  109.    type Property_Long_RO   is new Long_Properties.Property_RO; 
  110.    type Property_Long      is new Long_Properties.Property; 
  111.    type Property_Ulong_RO  is new Ulong_Properties.Property_RO; 
  112.    type Property_Ulong     is new Ulong_Properties.Property; 
  113.    type Property_Unichar   is new Unichar_Properties.Property; 
  114.    type Property_C_Proxy   is new Glib.Property; 
  115.    type Property_Interface is new Glib.Property; 
  116.    type Property_String_RO is new Glib.Property; 
  117.    type Property_String_WO is new Glib.Property; 
  118.    type Property_String    is new Glib.Property; 
  119.    type Property_Boolean   is new Glib.Property; 
  120.    type Property_Object    is new Glib.Property; 
  121.    type Property_Object_WO is new Glib.Property; 
  122.    type Property_Address   is new Glib.Property; 
  123.    type Property_Float     is new Glib.Property; 
  124.    type Property_Double    is new Glib.Property; 
  125.    type Property_Enum      is new Glib.Property; 
  126.    type Property_Boxed     is new Glib.Property; 
  127.  
  128.    --  General properties getter 
  129.  
  130.    procedure Set_Property 
  131.      (Object : access Glib.Object.GObject_Record'Class; 
  132.       Name   : String; 
  133.       Value  : in out Glib.Values.GValue); 
  134.    procedure Get_Property 
  135.      (Object : access Glib.Object.GObject_Record'Class; 
  136.       Name   : String; 
  137.       Value  : in out Glib.Values.GValue); 
  138.    --  Get the property. Value must have been initialized first with the 
  139.    --  expected type for the property, as in: 
  140.    --      Value : GValue; 
  141.    --      Init (Value, Value_Type (Pspec)); 
  142.    --      Get_Property (Object, Pspec_Name (Pspec), Value); 
  143.    --  If you do not have a Param_Spec, this can be replaced with: 
  144.    --      Init (Value, GType_Int); 
  145.    --      Get_Property (Object, Property_Name (Property), Value); 
  146.    --  Value must be Unset by the caller to free memory 
  147.  
  148.    --  Special handling of string properties 
  149.  
  150.    procedure Set_Property 
  151.      (Object : access Glib.Object.GObject_Record'Class; 
  152.       Name : Property_String; 
  153.       Value : String); 
  154.  
  155.    procedure Set_Property 
  156.      (Object : access Glib.Object.GObject_Record'Class; 
  157.       Name : Property_String_WO; 
  158.       Value : String); 
  159.  
  160.    function Get_Property 
  161.      (Object : access Glib.Object.GObject_Record'Class; 
  162.       Name : Property_String) return String; 
  163.  
  164.    function Get_Property 
  165.      (Object : access Glib.Object.GObject_Record'Class; 
  166.       Name : Property_String_RO) return String; 
  167.  
  168.    --  Special handling of boolean properties 
  169.  
  170.    procedure Set_Property 
  171.      (Object : access Glib.Object.GObject_Record'Class; 
  172.       Name   : Property_Boolean; 
  173.       Value  : Boolean); 
  174.  
  175.    function Get_Property 
  176.      (Object : access Glib.Object.GObject_Record'Class; 
  177.       Name : Property_Boolean) return Boolean; 
  178.  
  179.    --  Special handling of object properties 
  180.  
  181.    procedure Set_Property 
  182.      (Object : access Glib.Object.GObject_Record'Class; 
  183.       Name   : Property_Object; 
  184.       Value  : access Glib.Object.GObject_Record'Class); 
  185.  
  186.    function Get_Property 
  187.      (Object : access Glib.Object.GObject_Record'Class; 
  188.       Name : Property_Object) return Glib.Object.GObject; 
  189.  
  190.    procedure Set_Property 
  191.      (Object : access Glib.Object.GObject_Record'Class; 
  192.       Name   : Property_Object_WO; 
  193.       Value  : access Glib.Object.GObject_Record'Class); 
  194.  
  195.    --  Special handling of address properties 
  196.  
  197.    procedure Set_Property 
  198.      (Object : access Glib.Object.GObject_Record'Class; 
  199.       Name   : Property_Address; 
  200.       Value  : System.Address); 
  201.  
  202.    function Get_Property 
  203.      (Object : access Glib.Object.GObject_Record'Class; 
  204.       Name : Property_Address) return System.Address; 
  205.  
  206.    --  Special handling of float properties 
  207.  
  208.    procedure Set_Property 
  209.      (Object : access Glib.Object.GObject_Record'Class; 
  210.       Name   : Property_Float; 
  211.       Value  : Gfloat); 
  212.  
  213.    function Get_Property 
  214.      (Object : access Glib.Object.GObject_Record'Class; 
  215.       Name : Property_Float) return Gfloat; 
  216.  
  217.    --  Special handling of double properties 
  218.  
  219.    procedure Set_Property 
  220.      (Object : access Glib.Object.GObject_Record'Class; 
  221.       Name   : Property_Double; 
  222.       Value  : Gdouble); 
  223.  
  224.    function Get_Property 
  225.      (Object : access Glib.Object.GObject_Record'Class; 
  226.       Name : Property_Double) return Gdouble; 
  227.  
  228.    --  Special handling of c_proxy properties 
  229.  
  230.    procedure Set_Property 
  231.      (Object : access Glib.Object.GObject_Record'Class; 
  232.       Name   : Property_C_Proxy; 
  233.       Value  : C_Proxy); 
  234.  
  235.    function Get_Property 
  236.      (Object : access Glib.Object.GObject_Record'Class; 
  237.       Name : Property_C_Proxy) return C_Proxy; 
  238.  
  239.    procedure Set_Property 
  240.      (Object : access Glib.Object.GObject_Record'Class; 
  241.       Name   : Property_Interface; 
  242.       Value  : Glib.Types.GType_Interface); 
  243.  
  244.    function Get_Property 
  245.      (Object : access Glib.Object.GObject_Record'Class; 
  246.       Name : Property_Interface) return Glib.Types.GType_Interface; 
  247.  
  248. end Glib.Properties;