diff --git a/blueprintcompiler/outputs/xml/__init__.py b/blueprintcompiler/outputs/xml/__init__.py index 0fc2c5e..fd0bb70 100644 --- a/blueprintcompiler/outputs/xml/__init__.py +++ b/blueprintcompiler/outputs/xml/__init__.py @@ -114,7 +114,16 @@ class XmlOutput(OutputFormat): elif isinstance(value, Binding): if simple := value.simple_binding: - props["bind-source"] = simple.source + if ( + simple.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"] = simple.source + props["bind-property"] = simple.property_name props["bind-flags"] = "sync-create" xml.put_self_closing("property", **props) diff --git a/tests/samples/template_simple_binding.blp b/tests/samples/template_simple_binding.blp new file mode 100644 index 0000000..549f885 --- /dev/null +++ b/tests/samples/template_simple_binding.blp @@ -0,0 +1,5 @@ +using Gtk 4.0; + +template $MyTemplate { + prop: bind template.prop2; +} \ No newline at end of file diff --git a/tests/samples/template_simple_binding.ui b/tests/samples/template_simple_binding.ui new file mode 100644 index 0000000..41788e4 --- /dev/null +++ b/tests/samples/template_simple_binding.ui @@ -0,0 +1,7 @@ + + + + + diff --git a/tests/test_samples.py b/tests/test_samples.py index f6ba1a0..fa628be 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -178,6 +178,7 @@ class TestSamples(unittest.TestCase): "template_binding", "template_binding_extern", "template_no_parent", + "template_simple_binding", "typeof", "unchecked_class", ]