The PropDescription structure is one of the most important parts of a ProgrammedObject. It defines the types of all the data in your object, allowing properties dialogs, defaults dialogs, loading, saving and copying to be handled automatically. Using the StdProps system, you will only need to worry about the important things of an object: How does it look, and how does it behave.
The list of property descriptions always starts with the properties of the parent class. The PredefinedClasses? have macros defining these properties: OBJECT_COMMON_PROPERTIES, ELEMENT_COMMON_PROPERTIES etc. After that comes a list of property descriptions. It is highly recommended to include all relevant StandardProperties?, as they know how to work with the toolbox widgets, and thus make the object easier to use. The list of property descriptions must end with PROP_DESC_END.
static PropDescription myobject_props[] = {
ELEMENT_COMMON_PROPERTIES,
PROP_STD_LINE_WIDTH,
PROP_STD_LINE_COLOUR,
PROP_STD_FILL_COLOUR,
PROP_STD_SHOW_BACKGROUND,
PROP_STD_LINE_STYLE,
{ "corner_radius", PROP_TYPE_REAL, PROP_FLAG_VISIBLE,
N_("Corner radius"), NULL, &corner_radius_data },
PROP_DESC_END
};
The actual PropDescription structure contains the following fields. You make an instance of this whenever you add a non-standard property.
- name
- (const gchar*) The internal name of this property. This is the same name as is used in the PropOffset structure. It doesn't have to be abbreviated for efficiency, as it is turned into a quark anyway.
- type
- (PropertyType?) The PropertyType? of this property.
- flags
- (guint) The PropertyFlags? of this property. Typical properties will use
PROP_FLAG_VISIBLE
- description
- (const gchar *) The externally visible name of this property. This must be enclosed in
N_() to allow internationalization. This is the label that will be used in the properties dialogs. Do not include a colon.
- tooltip
- (const gchar *) An optional tooltip string with extra explanation of this property. If not NULL, this string must also be enclosed in
N_() for internationalization. This tooltip is not currently used.
- extradata
- (gpointer) Some properties, like enumerations, require extra data passed to them. That data is passed in this field.
- event_handler
- (PropEventHandler?) When properties have events associated with them (like the button property), this is the callback function that will be invoked.
The rest of the PropDescription structure is for internal use only. Typical instances will only fill in the first four fields, the rest can be left out of the structure (and will be NULL).
-- LarsClausen - 05 Sep 2002