Fix templates in bind-property

This commit is contained in:
James Westman 2023-05-16 17:42:53 -05:00
parent b5eca8b0b3
commit 3ebe5c72c1
4 changed files with 23 additions and 1 deletions

View file

@ -141,7 +141,16 @@ class XmlOutput(OutputFormat):
if value.bidirectional:
bind_flags.append("bidirectional")
if (
value.source == "template"
and value.context[ScopeCtx].template is not None
):
props["bind-source"] = value.context[
ScopeCtx
].template.gir_class.glib_type_name
else:
props["bind-source"] = value.source
props["bind-property"] = value.property_name
props["bind-flags"] = "|".join(bind_flags) or None
xml.put_self_closing("property", **props)

View file

@ -0,0 +1,5 @@
using Gtk 4.0;
template $MyTemplate {
object: bind-property template.object2;
}

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk" version="4.0"/>
<template class="MyTemplate">
<property name="object" bind-source="MyTemplate" bind-property="object2" bind-flags="sync-create"/>
</template>
</interface>

View file

@ -177,6 +177,7 @@ class TestSamples(unittest.TestCase):
"template",
"template_binding",
"template_binding_extern",
"template_bind_property",
"template_id",
"template_no_parent",
"template_simple_binding",