Methods to install custom style properties in GTK+-widgets

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?

Answers


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.


Need Your Help

How to make a surface with a transparent background in pygame

python transparency pygame

Can someone give me some example code that creates a surface with a transparent background in pygame?

Match any/all of multiple words in a string

javascript regex

I'm trying to write this regEx (javascript) to match word1 and word2 (when it exists):