[Contents] [Back] [Prev] [Up] [Next] [Forward]

# Package Glib.Properties

Properties are a fully general way to modify the appareance or behavior of widgets. Most of the time, there exists a faster way to modify the widget in the same fashion (for instance a direct call to a primitive subprogram). However, the properties provide a general scheme to modify these attributes. For instance, they can be used to provide introspection on the widget (to automatically retrieve the attributes that can be modified), or if you need to implement a tool like a GUI-Builder that is able to manipulate any widget, even those that didn't exist when the tool was written.

Two functions are provided for each type of property: Set_Property and Get_Property, which allow easy modification of specific widget properties. For instance, you could do the following: declare Button : Gtk_Button; begin Gtk_New (Button, "old label"); Set_Property (Button, Label_Property, "new label"); end; to modify the label of a button.

Likewise, you can retrieve the current label with: Current : String := Get_Property (Button, Label_Property);

Dispatching is used ensure type-safety while using properties. The appropriate Set_Property/Get_Property functions are called depending on the type of the property you are trying to use. This is checked statically by the compiler, which provides additional type-safety compared to the C library.

Note that some properties are read-only, and thus do not have the Set_Property subprogram defined.

When a property is modified, the signal "notify::<property>" is emitted, for instance, "notify::label" for a gtk_button. This is a standard gtk+ signal to which you can connect with the subprograms in gtk-handlers.ads

- Glib.Properties Types
- Glib.Properties Subprograms

## Types

    type Property_Address is new Glib.Property;

    type Property_Boolean is new Glib.Property;

    type Property_C_Proxy is new Glib.Property;

    type Property_Char is new Char_Properties.Property;

    type Property_Char_RO is new Char_Properties.Property_RO;

    type Property_Double is new Glib.Property;

    type Property_Float is new Glib.Property;

    type Property_Int is new Int_Properties.Property;

    type Property_Long is new Long_Properties.Property;

    type Property_Long_RO is new Long_Properties.Property_RO;

    type Property_Object is new Glib.Property;

    type Property_Object_WO is new Glib.Property;

    type Property_String is new Glib.Property;

    type Property_String_RO is new Glib.Property;

    type Property_String_WO is new Glib.Property;

    type Property_Uchar is new Uchar_Properties.Property;

    type Property_Uchar_RO is new Uchar_Properties.Property_RO;

    type Property_Uint is new Uint_Properties.Property;

    type Property_Uint_RO is new Uint_Properties.Property_RO;

    type Property_Ulong is new Ulong_Properties.Property;

    type Property_Ulong_RO is new Ulong_Properties.Property_RO;

    type Property_Unichar is new Unichar_Properties.Property;

## Subprograms

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_String;
       Value              :        String);

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_String_WO;
       Value              :        String);

    function Get_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_String)
       return String;

    function Get_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_String_RO)
       return String;

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Boolean;
       Value              :        Boolean);

    function Get_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Boolean)
       return Boolean;

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Object;
       Value              : access Glib.Object.GObject_Record'Class);

    function Get_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Object)
       return Glib.Object.GObject;

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Object_WO;
       Value              : access Glib.Object.GObject_Record'Class);

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Address;
       Value              :        System.Address);

    function Get_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Address)
       return System.Address;

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Float;
       Value              :        Gfloat);

    function Get_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Float)
       return Gfloat;

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Double;
       Value              :        Gdouble);

    function Get_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_Double)
       return Gdouble;

    procedure Set_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_C_Proxy;
       Value              :        C_Proxy);

    function Get_Property
      (Object             : access Glib.Object.GObject_Record'Class;
       Name               :        Property_C_Proxy)
       return C_Proxy;

[Contents] [Back] [Prev] [Up] [Next] [Forward]