SIL LSDev Linux Development

Language software for Linux and Mac OS X

Explorations in GTK# part 1

GTK.Settings: What and how

What?…
For the standard set of GTK# widgets, there is a property or method to change almost any aspect of the widgets appearance and behaviour. But some things require using GTK.Settings. For example setting the palette in a colour selector, or changing the cursor behaviour in a text entry.

How…? To set a property, the following methods can be used:

SetDoubleProperty (string Name, double Value, string Origin)
SetLongProperty   (string Name, long Value, string Origin)
SetStringProperty (string Name, string Value, string Origin)
SetPropertyValue  (string Name, SettingsValue Value)

For all except SetPropertyValue, the parameters are as follows:

  • Name The name of the value. A list of possible names can be found in the GTK+ documentation for settings
  • Value The value that the property is to be set to.
  • Origin A description of the source of this value. It does not need to be anything specific.

For any other type of value than string, long or double, SetPropertyValue must be used (i.e. object types). Forthis, the Name parameter is used the same as with the other methods, and the Value is a SettingsValue object with the following properties set:

  • Value The value that the property is to be set to.
  • Origin A description of the source of this value. It does not need to be anything specific

Seems like a convoluted way of setting a property, but this is the way GTK+ does it, so this is what we get in GTK#.

Leave a Reply