BuilderListItemFactory, using gtkexpression to set the style class #1535
-
I'm using BuilderListItemFactory to have dynamic GtkListItems. It's working fine to set a GtkLabel label as in the example. However I would use that to apply a (potentially) different style class name to every list item. Here's what I did: <?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkLabel">
<!-- <property name="css-classes">project-item-prod</property> -->
<binding name="css-classes">
<lookup name="environmentcss" type="ProjectItemModel">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
<binding name="label">
<lookup name="title" type="ProjectItemModel">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</property>
</template>
</interface> Note that setting the #[derive(Properties, Default)]
#[properties(wrapper_type = super::ProjectItemModel)]
pub struct ProjectItemModel {
#[property(get, set)]
title: Rc<RefCell<String>>,
#[property(get, set)]
environmentcss: Rc<RefCell<String>>,
} Now that compiles, but at runtime, I get:
It actually would seem (probably naively) that I'm not too far... If only I could explicitly say that the type of my model property should be So, is this at all possible? 😬 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ok, i got it, for I got confused by the fact that when you specify the value by hand, you give a single newline-separated string. And I didn't look too closely at the C alias for GStrv, which is a double pointer, and so doesn't explicitely say it contains an array (like it would with a |
Beta Was this translation helpful? Give feedback.
Ok, i got it, for
GStrv
, the type of the property should beVec<String>
instead ofString
. Then it works just fine.I got confused by the fact that when you specify the value by hand, you give a single newline-separated string. And I didn't look too closely at the C alias for GStrv, which is a double pointer, and so doesn't explicitely say it contains an array (like it would with a
[]
marker for instance).