Let’s say I have a list that renders a button for deleting that particular list item. Ordinarily, I can create a .ui
file and use GtkExpression
like in the example below.
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<template class="GtkListItem">
<property name="child">
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="homogeneous">true</property>
<child>
<object class="GtkLabel">
<property name="xalign">0</property>
<binding name="label">
<lookup name="number" type="EvenNumber">
<lookup name="item">GtkListItem</lookup>
</lookup>
</binding>
</object>
</child>
<child>
<object class="GtkBox">
<property name="orientation">horizontal</property>
<property name="halign">2</property>
<child>
<object class="GtkButton">
<style>
<class name="suggested-action" />
</style>
<property name="label">Delete row</property>
<!-- This is where the error is -->
<signal name="clicked" handler="handleClicked"/>
</object>
</child>
</object>
</child>
</object>
</property>
</template>
</interface>
I was able to load to load the above .ui
file using GtkBuilderListItemFactory
in my main template file after commenting out the signal connected to the GtkButton
.
<object class="GtkBuilderListItemFactory">
<property name="resource">/path/to/my/resource</property>
</object>
However, I wasn’t able to load the .ui
file above with the clicked
signal. I want the button signal handler to be declared in the main class because it needs access to the global state. Is there a way I can use signals with GtkExpression
so that I can attach the handleClicked
handler to the button? The same way I have used GtkExpression
to access listItem.item.number
.