GDKColor as Treeviewcolumn attribute

HI
I attempted to set cell-background via an attribute, as opposed to a property

As a property I need to setup a GDK::RGBA object eg: my $rgbaedit1=Gtk3::Gdk::RGBA->new(0,0,0,0.1);
and Then $cell->set (‘cell-background-rgba’,$rgbaedit1)

However if I try an equivalent approach via attribute
eg: lookup column in the model ‘Glib::String’
value in column $rgbaedit1
$col->add_attribute($renderer,‘cell-background-rgba’,), I get unable to set GDKColor from gchararray error

However if I change to

value in column ‘rgba(0,0,0,0.1)’
and $col->add_attribute($renderer,‘cell-background’,) it works (note the missing -rgba suffix to attribute name)

Is this expected behaviour, or is there a different Glib type I should be using for the model

There is no automatic transformation from strings to GdkRGBA values; if you want to do that, you will need to use a custom cell data function. Alternatively, you will need to store the color as a GdkRGBA in the model in the first place.

Thats what I tried to do initially, so what column type do I need in order to do this?

The Perl type for GdkRGBA is Gtk3::Gdk::RGBA.

So what do I put in the Liststore definition? I understand (possibly incorrectly) that Liststore column types need to be Glib::*

I just told you: Gtk3::Gdk::RGBA. :wink:

No, that’s not true. You can use any GType as the column in a ListStore.

thanks , apologies for sounding dim

Final question , this all worked.

Is there a difference, performance or otherwise between
model column - Glib::String
Model value - rgba(0…0.0.0.1)
$cell->add_attribute($r,‘cell-background’,$col)

and
my $rgba=Gtk3::Gdk::RGBA;
Model Column - Gtk3::Gdk::RGBA;
Model Value - $rgba
$cell->add_attribute($r,‘cell-attribute-rgba’,$col)
(where $col in both cases is the appropriate column in the liststore and $r is the cell renderer)

thanks

No, there’s really no difference; parsing a color definition is not really intensive.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.