diff --git a/blueprintcompiler/outputs/xml/__init__.py b/blueprintcompiler/outputs/xml/__init__.py index fd0bb70..a58ca9d 100644 --- a/blueprintcompiler/outputs/xml/__init__.py +++ b/blueprintcompiler/outputs/xml/__init__.py @@ -141,7 +141,16 @@ class XmlOutput(OutputFormat): if value.bidirectional: bind_flags.append("bidirectional") - props["bind-source"] = value.source + 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) diff --git a/tests/samples/template_bind_property.blp b/tests/samples/template_bind_property.blp new file mode 100644 index 0000000..e2be0bf --- /dev/null +++ b/tests/samples/template_bind_property.blp @@ -0,0 +1,5 @@ +using Gtk 4.0; + +template $MyTemplate { + object: bind-property template.object2; +} \ No newline at end of file diff --git a/tests/samples/template_bind_property.ui b/tests/samples/template_bind_property.ui new file mode 100644 index 0000000..eb55547 --- /dev/null +++ b/tests/samples/template_bind_property.ui @@ -0,0 +1,7 @@ + + + + + diff --git a/tests/test_samples.py b/tests/test_samples.py index 34fe45f..30a41aa 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -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",