1. ----------------------------------------------------------------------- 
  2. --               GtkAda - Ada95 binding for Gtk+/Gnome               -- 
  3. --                                                                   -- 
  4. --                Copyright (C) 2001-2003, ACT-Europe                -- 
  5. --                    Copyright (C) 2010, 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. --  Properties are a fully general way to modify the appareance or behavior 
  27. --  of widgets. Most of the time, there exists a faster way to modify the 
  28. --  widget in the same fashion (for instance a direct call to a primitive 
  29. --  subprogram). However, the properties provide a general scheme to modify 
  30. --  these attributes. 
  31. --  For instance, they can be used to provide introspection on the widget 
  32. --  (to automatically retrieve the attributes that can be modified), or if 
  33. --  you need to implement a tool like a GUI-Builder that is able to 
  34. --  manipulate any widget, even those that didn't exist when the tool was 
  35. --  written. 
  36. -- 
  37. --  Two functions are provided for each type of property: Set_Property and 
  38. --  Get_Property, which allow easy modification of specific widget 
  39. --  properties. For instance, you could do the following: 
  40. --      declare 
  41. --          Button : Gtk_Button; 
  42. --      begin 
  43. --          Gtk_New (Button, "old label"); 
  44. --          Set_Property (Button, Label_Property, "new label"); 
  45. --      end; 
  46. --  to modify the label of a button. 
  47. -- 
  48. --  Likewise, you can retrieve the current label with: 
  49. --      Current : String := Get_Property (Button, Label_Property); 
  50. -- 
  51. --  Dispatching is used ensure type-safety while using properties. The 
  52. --  appropriate Set_Property/Get_Property functions are called depending 
  53. --  on the type of the property you are trying to use. This is checked 
  54. --  statically by the compiler, which provides additional type-safety 
  55. --  compared to the C library. 
  56. -- 
  57. --  Note that some properties are read-only, and thus do not have the 
  58. --  Set_Property subprogram defined. 
  59. -- 
  60. --  When a property is modified, the signal "notify::<property>" is emitted, 
  61. --  for instance, "notify::label" for a gtk_button. This is a standard gtk+ 
  62. --  signal to which you can connect with the subprograms in gtk-handlers.ads 
  63.  
  64. --  </description> 
  65. --  <c_version>1.3.4</c_version> 
  66. --  <group>Glib, the general-purpose library</group> 
  67.  
  68. with Glib.Object; 
  69. with Glib.Generic_Properties; use Glib.Generic_Properties; 
  70. pragma Elaborate_All (Glib.Generic_Properties); 
  71. with System; 
  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_String_RO is new Glib.Property; 
  116.    type Property_String_WO is new Glib.Property; 
  117.    type Property_String    is new Glib.Property; 
  118.    type Property_Boolean   is new Glib.Property; 
  119.    type Property_Object    is new Glib.Property; 
  120.    type Property_Object_WO is new Glib.Property; 
  121.    type Property_Address   is new Glib.Property; 
  122.    type Property_Float     is new Glib.Property; 
  123.    type Property_Double    is new Glib.Property; 
  124.    type Property_Enum      is new Glib.Property; 
  125.    type Property_Boxed     is new Glib.Property; 
  126.  
  127.    --  General properties getter 
  128.  
  129.    procedure Set_Property 
  130.      (Object : access Glib.Object.GObject_Record'Class; 
  131.       Name   : String; 
  132.       Value  : in out Glib.Values.GValue); 
  133.    procedure Get_Property 
  134.      (Object : access Glib.Object.GObject_Record'Class; 
  135.       Name   : String; 
  136.       Value  : in out Glib.Values.GValue); 
  137.    --  Get the property. Value must have been initialized first with the 
  138.    --  expected type for the property, as in: 
  139.    --      Value : GValue; 
  140.    --      Init (Value, Value_Type (Pspec)); 
  141.    --      Get_Property (Object, Pspec_Name (Pspec), Value); 
  142.    --  If you do not have a Param_Spec, this can be replaced with: 
  143.    --      Init (Value, GType_Int); 
  144.    --      Get_Property (Object, Property_Name (Property), Value); 
  145.    --  Value must be Unset by the caller to free memory 
  146.  
  147.    --  Special handling of string properties 
  148.  
  149.    procedure Set_Property 
  150.      (Object : access Glib.Object.GObject_Record'Class; 
  151.       Name : Property_String; 
  152.       Value : String); 
  153.  
  154.    procedure Set_Property 
  155.      (Object : access Glib.Object.GObject_Record'Class; 
  156.       Name : Property_String_WO; 
  157.       Value : String); 
  158.  
  159.    function Get_Property 
  160.      (Object : access Glib.Object.GObject_Record'Class; 
  161.       Name : Property_String) return String; 
  162.  
  163.    function Get_Property 
  164.      (Object : access Glib.Object.GObject_Record'Class; 
  165.       Name : Property_String_RO) return String; 
  166.  
  167.    --  Special handling of boolean properties 
  168.  
  169.    procedure Set_Property 
  170.      (Object : access Glib.Object.GObject_Record'Class; 
  171.       Name   : Property_Boolean; 
  172.       Value  : Boolean); 
  173.  
  174.    function Get_Property 
  175.      (Object : access Glib.Object.GObject_Record'Class; 
  176.       Name : Property_Boolean) return Boolean; 
  177.  
  178.    --  Special handling of object properties 
  179.  
  180.    procedure Set_Property 
  181.      (Object : access Glib.Object.GObject_Record'Class; 
  182.       Name   : Property_Object; 
  183.       Value  : access Glib.Object.GObject_Record'Class); 
  184.  
  185.    function Get_Property 
  186.      (Object : access Glib.Object.GObject_Record'Class; 
  187.       Name : Property_Object) return Glib.Object.GObject; 
  188.  
  189.    procedure Set_Property 
  190.      (Object : access Glib.Object.GObject_Record'Class; 
  191.       Name   : Property_Object_WO; 
  192.       Value  : access Glib.Object.GObject_Record'Class); 
  193.  
  194.    --  Special handling of address properties 
  195.  
  196.    procedure Set_Property 
  197.      (Object : access Glib.Object.GObject_Record'Class; 
  198.       Name   : Property_Address; 
  199.       Value  : System.Address); 
  200.  
  201.    function Get_Property 
  202.      (Object : access Glib.Object.GObject_Record'Class; 
  203.       Name : Property_Address) return System.Address; 
  204.  
  205.    --  Special handling of float properties 
  206.  
  207.    procedure Set_Property 
  208.      (Object : access Glib.Object.GObject_Record'Class; 
  209.       Name   : Property_Float; 
  210.       Value  : Gfloat); 
  211.  
  212.    function Get_Property 
  213.      (Object : access Glib.Object.GObject_Record'Class; 
  214.       Name : Property_Float) return Gfloat; 
  215.  
  216.    --  Special handling of double properties 
  217.  
  218.    procedure Set_Property 
  219.      (Object : access Glib.Object.GObject_Record'Class; 
  220.       Name   : Property_Double; 
  221.       Value  : Gdouble); 
  222.  
  223.    function Get_Property 
  224.      (Object : access Glib.Object.GObject_Record'Class; 
  225.       Name : Property_Double) return Gdouble; 
  226.  
  227.    --  Special handling of c_proxy properties 
  228.  
  229.    procedure Set_Property 
  230.      (Object : access Glib.Object.GObject_Record'Class; 
  231.       Name   : Property_C_Proxy; 
  232.       Value  : C_Proxy); 
  233.  
  234.    function Get_Property 
  235.      (Object : access Glib.Object.GObject_Record'Class; 
  236.       Name : Property_C_Proxy) return C_Proxy; 
  237.  
  238. end Glib.Properties;