Previous: Hook Handling and Transactions, Up: Property Editor Widgets



7.6.4 Property Recycler

Files: gui/properties.h, gui/properties.c

When the property values are set using the TRANS_PROP_CHANGE macro, the values of some properties (those that have the PTF_RECYCLABLE flag set) are stored in a special place called the property store. The property store is a GO – a top-level group of a tlo linked in the zombie, not in the universe, and a reference is kept for it to prevent its deletion.

To manipulate with property stores, VRR provides the following functions and macros:

     /* the definition */
     PROP_STORE_DEFINE(_id)
     
     PROP_STORE_NEW(_id)
     
     PROP_STORE_DESTROY(_id)
     
     /* the actual object which stores the properties */
     PROP_STORE_O(_id)
     
     /* the transaction tlo for recycler property changes */
     PROP_STORE_TLO(_id)
     
     PROP_STORE_GET(_id, _name, _type, _union_member_name, _default)
     
     void prop_store_set( PROP_STORE_DEFINE(ps), const char * name,
                          uns type, prop_value pv );

It has two property stores: ps_global and ps_recycler. The recycler stores the properties set by the user in some editor widgets, whereas the purpose of the global store is to store various settings of some dialogs which are not saved anywhere else. The ps_recycler has its own additional functions:

     void gui_prop_recycler_set( string key, uns type,
                                 uns subtype, uns unit, prop_value val );
     
     void gui_prop_recycle( struct o * o );

The gui_prop_recycler_set function sets the given property to the recycler. If it already contains a property of the same key, type and subtype, then the value is changed; if the key is the same but the type or subtype does not match, the old property is deleted and a new one is created.

The gui_prop_recycle function goes through all the object's properties and seeks matching properties in the recycler (with the same key, type and subtype). The values of all matching properties are copied into the object. This function is used by the GO Factory when creating new objects.