I've written a simple function which aim is to change text & color of a GtkLabel. Trouble is (off course) : it doesn't work. Text contained in "status" is set correctly but color is not.
I use the Pango Attribute to set it but no way. Call is like : _SetStatus(context, "Running", "green");
GUI_ERR_HDL _SetStatus(GuiContext *context, const gchar *status, const gchar *color) {
GtkLabel *lbl;
PangoAttrList *pngList;
PangoAttribute *pngFgColor;
GdkRGBA rgba;
guint16 r;
guint16 g;
guint16 b;
lbl=GTK_LABEL(gtk_builder_get_object(context->builder,
(gchar*)OPENSESSION_LBL_STATUS));
pngList=gtk_label_get_attributes(lbl);
gdk_rgba_parse(&rgba, color);
r=(guint16)rgba.red*255;
g=(guint16)rgba.green*255;
b=(guint16)rgba.blue*255;
pngFgColor=pango_attr_foreground_new(r,g,b);
pango_attr_list_change(pngList, pngFgColor);
gtk_label_set_attributes(lbl, pngList);
gtk_label_set_label(lbl, status);
return NO_ERR;
}
Any idea ?
Thanks in advance.
Vincent.