This package provides all the required subprograms to create and manipulate new properties associated with new widget types.
You do not have to be familiar with this package in order to use properties. See Glib.Object instead, that provides the minimal subprograms to get and set properties.
This package is only intended for writers of new widgets. You will need this function to create new properties.
Each object in gtk+ has a set of so-called properties. These are attributes that can be accessed, and possibly modified, by names. They provide introspection, that is an object can specify which properties it knows about, which can be modified,..., and thus provide a huge support for special applications like GUI-Builders that need to act on any kind of widgets, even those it doesn't know about yet.
However, for efficiency reasons, the properties are only names, and are not the only way to modify attributes of objects. It is often more efficient to use the alternate method, as documented in the GtkAda documentation for each property.
Another interesting feature of properties is that every time a property is modified, a signal "property_changed" or "notify" is emitted, and it is thus easy to keep track of attributes in objects.
Types |
---|
type Enum_Class is new Glib.C_Proxy; | |
| |
type Enum_Value is new Glib.C_Proxy; | |
| |
type Flags_Class is new Glib.C_Proxy; | |
| |
type Flags_Int_Value is mod Glib.Gint'Last; | |
| |
type Flags_Value is new Glib.C_Proxy; | |
| |
type Get_Property_Handler is access procedure | |
| |
type Param_Spec_Boolean is new Param_Spec; | |
| |
type Param_Spec_Boxed is new Param_Spec; | |
| |
type Param_Spec_Char is new Param_Spec; | |
| |
type Param_Spec_Double is new Param_Spec; | |
| |
type Param_Spec_Enum is new Param_Spec; | |
| |
type Param_Spec_Flags is new Param_Spec; | |
| |
type Param_Spec_Float is new Param_Spec; | |
| |
type Param_Spec_Int is new Param_Spec; | |
| |
type Param_Spec_Long is new Param_Spec; | |
| |
type Param_Spec_Object is new Param_Spec; | |
| |
type Param_Spec_Param is new Param_Spec; | |
| |
type Param_Spec_Pointer is new Param_Spec; | |
| |
type Param_Spec_String is new Param_Spec; | |
| |
type Param_Spec_Uchar is new Param_Spec; | |
| |
type Param_Spec_Uint is new Param_Spec; | |
| |
type Param_Spec_Ulong is new Param_Spec; | |
| |
type Param_Spec_Unichar is new Param_Spec; | |
| |
type Property_Id is new Guint; | |
| |
type Set_Property_Handler is access procedure | |
|
Subprograms |
---|
procedure Unref (Param : Param_Spec); | ||
Decrement the reference counter. If it reaches 0, the memory is freed.
| ||
Enum classes | ||
gtk+, a C library, has a whole system to describe its enumeration types, | ||
function Get_Value (Klass : Enum_Class; Value : Glib.Gint) return Enum_Value; | ||
Return the value in Klass that is Value (equivalent of 'Val in Ada)
| ||
function Nth_Value (Klass : Enum_Class; Nth : Glib.Guint) return Enum_Value; | ||
Return the Nth-th value in Klass, or null if there is no such value.
| ||
function Value (Val : Enum_Value) return Glib.Gint; | ||
Return the numeric value for a specific enumeration. Use the matching | ||
function Name (Val : Enum_Value) return String; | ||
Return the name of Val. This is the equivalent of 'Image in Ada.
| ||
function Nick (Val : Enum_Value) return String; | ||
Return a displayable string for Val.
| ||
Flags classes | ||
These are very similar to Enum Classes. However, the actual value | ||
function Nth_Value (Klass : Flags_Class; Nth : Glib.Guint) return Flags_Value; | ||
Return the Nth-th value in Klass, or null if there is no such value.
| ||
function Value (Val : Flags_Value) return Flags_Int_Value; | ||
Return the numeric value for a specific enumeration. Use the matching | ||
function Name (Val : Flags_Value) return String; | ||
Return the name of Val. This is the equivalent of 'Image in Ada.
| ||
function Nick (Val : Flags_Value) return String; | ||
Return a displayable string for Val.
| ||
ParamSpec | ||
function Pspec_Name (Param : Param_Spec) return String; | ||
Return the name of the property. | ||
function Nick_Name (Param : Param_Spec) return String; | ||
Return the nickname of the property. This is a string | ||
function Flags (Param : Param_Spec) return Param_Flags; | ||
Return the flags for the property
| ||
function Description (Param : Param_Spec) return String; | ||
Return the description (ie the help string) for Param
| ||
function Value_Type (Param : Param_Spec) return Glib.GType; | ||
Return the type of param
| ||
procedure Set_Value_Type (Param : Param_Spec; Typ : Glib.GType); | ||
Override the type of param. You should only use this function when | ||
function Get_Qdata (Param : Param_Spec; Quark : GQuark) return Glib.C_Proxy; | ||
Return the user data set for Param
| ||
procedure Set_Qdata (Param : Param_Spec; Quark : GQuark; Data : Glib.C_Proxy; Destroy : G_Destroy_Notify := null); | ||
Associate some named data with Param. Destroy is called when Param is | ||
function Minimum (Param : Param_Spec_Char) return Glib.Gint8; | ||
| ||
function Default (Param : Param_Spec_Char) return Glib.Gint8; | ||
| ||
function Minimum (Param : Param_Spec_Uchar) return Glib.Guint8; | ||
| ||
function Default (Param : Param_Spec_Uchar) return Glib.Guint8; | ||
| ||
function Default (Param : Param_Spec_Boolean) return Boolean; | ||
| ||
function Minimum (Param : Param_Spec_Int) return Glib.Gint; | ||
| ||
function Default (Param : Param_Spec_Int) return Glib.Gint; | ||
| ||
function Minimum (Param : Param_Spec_Uint) return Glib.Guint; | ||
| ||
function Default (Param : Param_Spec_Uint) return Glib.Guint; | ||
| ||
function Minimum (Param : Param_Spec_Long) return Glib.Glong; | ||
| ||
function Default (Param : Param_Spec_Long) return Glib.Glong; | ||
| ||
function Minimum (Param : Param_Spec_Ulong) return Glib.Gulong; | ||
| ||
function Default (Param : Param_Spec_Ulong) return Glib.Gulong; | ||
| ||
function Default (Param : Param_Spec_Unichar) return Gunichar; | ||
| ||
function Enumeration (Param : Param_Spec_Enum) return Enum_Class; | ||
| ||
function Flags_Enumeration (Param : Param_Spec_Flags) return Flags_Class; | ||
| ||
function Gnew_Flags (Name, Nick, Blurb : String; Flags_Type : Glib.GType; Default : Guint; Flags : Param_Flags := Param_Readable or Param_Writable) return Param_Spec; | ||
| ||
function Minimum (Param : Param_Spec_Float) return Gfloat; | ||
| ||
function Default (Param : Param_Spec_Float) return Gfloat; | ||
| ||
function Gnew_Float (Name, Nick, Blurb : String; Minimum, Maximum, Default : Glib.Gfloat; Flags : Param_Flags := Param_Readable or Param_Writable) return Param_Spec; | ||
| ||
function Minimum (Param : Param_Spec_Double) return Gdouble; | ||
| ||
function Default (Param : Param_Spec_Double) return Gdouble; | ||
| ||
function Gnew_Double (Name, Nick, Blurb : String; Minimum, Maximum, Default : Glib.Gdouble; Flags : Param_Flags := Param_Readable or Param_Writable) return Param_Spec; | ||
| ||
function Default (Param : Param_Spec_String) return String; | ||
| ||
function Cset_Nth (Param : Param_Spec_String) return String; | ||
| ||
function Ensure_Non_Null (Param : Param_Spec_String) return Boolean; | ||
| ||
function Gnew_Param (Name, Nick, Blurb : String; Param_Type : Glib.GType; Flags : Param_Flags := Param_Readable or Param_Writable) return Param_Spec; | ||
| ||
function Gnew_Boxed (Name, Nick, Blurb : String; Boxed_Type : Glib.GType; Flags : Param_Flags := Param_Readable or Param_Writable) return Param_Spec; | ||
| ||
function Gnew_Pointer (Name, Nick, Blurb : String; Flags : Param_Flags := Param_Readable or Param_Writable) return Param_Spec; | ||
| ||
function Gnew_Object (Name, Nick, Blurb : String; Object_Type : Glib.GType; Flags : Param_Flags := Param_Readable or Param_Writable) return Param_Spec; | ||
| ||
Creating new properties | ||
There are several things that need to be done when creating a property. Your widget needs to define two handlers, Set_Property_Handler and Get_Property_Handler, that are called every time the user accesses the value of a property through a call to Glib.Object.Set_Property or Glib.Object.Get_Property. For efficiency reasons, a property is also associated with an integer value, that you must provide when creating the property. This value is completely free, and is passed to the two handlers described above.
The two handlers manipulate Glib.Values.GValue values, so that they
can get and return various types.
| ||
procedure Set_Properties_Handlers (Class_Record : Glib.Object.GObject_Class; Set_Property : Set_Property_Handler; Get_Property : Get_Property_Handler); | ||
Set the two functions used to set and retrieve properties. You
You cannot pass null to either of the two parameters, or you won't
be able to install new properties afterwards
| ||
procedure Install_Property (Class_Record : Glib.Object.GObject_Class; Prop_Id : Property_Id; Property_Spec : Param_Spec); | ||
Adds a new property to Class_Record. You should use this function only |