Methods to install custom style properties in GTK+-widgets

935 views Asked by At

I'm writing custom GtkWidgets for a small library and therefore need custom style properties. I usually use the gtk_widget_class_install_style_property-function during the class-initialisation to do that. However I could not find a way to install a color-property, such as a GdkRGBA or a GdkColor for a widget. How could I do that?

Most of the available functions for installing or registering style-properties are deprecated since the move to the CssProvider for style-handling and it is sometimes hard to get the best way of handling with style-properties in gtk from the reference manuals.

Is there a different way to install such properties? Furthermore is there a documentation how the CssStyleProvider works internally and how properties are parsed from a css-file to the actual widget or GtkStyleContext?

1

There are 1 answers

2
ptomato On BEST ANSWER

You can do so with

gtk_widget_class_install_style_property (widget_class,
    g_param_spec_boxed ("color-property", "Short name of property",
         "Long description of the color property",
         GDK_TYPE_COLOR,
         G_PARAM_READWRITE));

However, I don't think there's anything you can do with a color-typed style property that you can't do better with just plain CSS.