Improve the migration guide
Add some hints about dealing with colors.
This commit is contained in:
committed by
Carlos Garnacho
parent
53c2114356
commit
ab0a8fc17f
@ -140,6 +140,7 @@
|
|||||||
although custom widgets may define their own, which themes may
|
although custom widgets may define their own, which themes may
|
||||||
attempt to handle.
|
attempt to handle.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</refsect2>
|
</refsect2>
|
||||||
|
|
||||||
<refsect2 id="gtk-migrating-GtkStyleContext-parser-extensions">
|
<refsect2 id="gtk-migrating-GtkStyleContext-parser-extensions">
|
||||||
@ -357,6 +358,37 @@
|
|||||||
independently.
|
independently.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Access to colors has also changed a bit. With #GtkStyle, the common
|
||||||
|
way to access colors is:
|
||||||
|
<informalexample><programlisting>
|
||||||
|
GdkColor *color1;
|
||||||
|
GdkColor color2;
|
||||||
|
|
||||||
|
color1 = &style->bg[GTK_STATE_PRELIGHT];
|
||||||
|
gtk_style_lookup_color (style, "focus_color", &color2);
|
||||||
|
</programlisting></informalexample>
|
||||||
|
With #GtkStyleContext, you generally use #GdkRGBA instead of #GdkColor
|
||||||
|
and the code looks like this:
|
||||||
|
<informalexample><programlisting>
|
||||||
|
GdkRGBA *color1;
|
||||||
|
GdkRGBA color2;
|
||||||
|
|
||||||
|
gtk_style_context_get (context, GTK_STATE_FLAG_PRELIGHT,
|
||||||
|
"background-color", &color1,
|
||||||
|
NULL);
|
||||||
|
gtk_style_context_lookup_color (context, "focus_color", &color2);
|
||||||
|
|
||||||
|
...
|
||||||
|
|
||||||
|
gdk_rgba_free (color1);
|
||||||
|
</programlisting></informalexample>
|
||||||
|
Note that the memory handling here is different: gtk_style_context_get()
|
||||||
|
expects the address of a GdkRGBA* and returns a newly allocated struct,
|
||||||
|
gtk_style_context_lookup_color() expects the address of an existing
|
||||||
|
struct, and fills it.
|
||||||
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
It is worth mentioning that the new file format does not support
|
It is worth mentioning that the new file format does not support
|
||||||
custom keybindings nor stock icon mappings as the RC format did.
|
custom keybindings nor stock icon mappings as the RC format did.
|
||||||
|
|||||||
Reference in New Issue
Block a user