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