Files: gui/properties.h, gui/properties.c, gui/units.c
In many VRR windows, a property value needs to be displayed, edited, and updated in reaction to kernel property hooks. To do this, the windows use the property editor widgets. All property editor widgets are generated using the same code, which assures that all editor widgets for the same property type and subtype look the same and behave in the same way.
There is a data structure containing everything needed for a property editor widget:
struct prop_item { struct o * o; string key; uns type, subtype; GtkWidget * value_edit; GtkWidget * unit_edit; uns flags; struct window * pw; };
The o
pointer represents the object to which the property belongs.
key
is the property unique identifier, type
and subtype
store the current property type and subtype (which might change). The two GtkWidget
objects, value_edit
and unit_edit
, are the editor widgets of the
property value and of the property unit. The unit editor does not have to be
present; in that case the pointer is NULL
. The flags
bitmask
is used only in the Property Window for property selection. pw
points
to a parent window, which is either NULL
or the parent Property Window.
To create a property editor widget, you need to allocate a prop_item
structure, fill it with the o
, key
, type
and subtype
values and call these functions:
void prop_value_edit_create( struct prop_item * pi ); void prop_unit_edit_create( struct prop_item * pi ); void prop_sync( struct prop_item * pi );
(where prop_sync
updates the editor value with the current property value.
This function should be called after each change of the property value announced
by kernel hooks).
Or do it all in a more convenient way using
void prop_item_init( struct prop_item * pi, struct o * o, string key );
Then the created widgets can be packed into the window where needed.