mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Fix referencing template by ID
This commit is contained in:
parent
664fa2250b
commit
08da6f79c7
3 changed files with 10 additions and 3 deletions
|
@ -26,7 +26,7 @@ from .types import ClassName
|
||||||
class Template(Object):
|
class Template(Object):
|
||||||
grammar = [
|
grammar = [
|
||||||
"template",
|
"template",
|
||||||
UseIdent("name").expected("template class name"),
|
UseIdent("id").expected("template class name"),
|
||||||
Optional([
|
Optional([
|
||||||
Match(":"),
|
Match(":"),
|
||||||
to_parse_node(ClassName).expected("parent class"),
|
to_parse_node(ClassName).expected("parent class"),
|
||||||
|
@ -40,7 +40,7 @@ class Template(Object):
|
||||||
if len(self.children[ClassName]):
|
if len(self.children[ClassName]):
|
||||||
return self.children[ClassName][0].gir_type
|
return self.children[ClassName][0].gir_type
|
||||||
|
|
||||||
@validate("name")
|
@validate("id")
|
||||||
def unique_in_parent(self):
|
def unique_in_parent(self):
|
||||||
self.validate_unique_in_parent(f"Only one template may be defined per file, but this file contains {len(self.parent.children[Template])}",)
|
self.validate_unique_in_parent(f"Only one template may be defined per file, but this file contains {len(self.parent.children[Template])}",)
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ class Template(Object):
|
||||||
|
|
||||||
xml.start_tag(
|
xml.start_tag(
|
||||||
"template",
|
"template",
|
||||||
**{"class": self.tokens["name"]},
|
**{"class": self.tokens["id"]},
|
||||||
parent=parent
|
parent=parent
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -4,3 +4,7 @@ template TestTemplate : ApplicationWindow {
|
||||||
test-property: "Hello, world";
|
test-property: "Hello, world";
|
||||||
test-signal => on_test_signal();
|
test-signal => on_test_signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dialog {
|
||||||
|
transient-for: TestTemplate;
|
||||||
|
}
|
|
@ -5,4 +5,7 @@
|
||||||
<property name="test-property">Hello, world</property>
|
<property name="test-property">Hello, world</property>
|
||||||
<signal name="test-signal" handler="on_test_signal"/>
|
<signal name="test-signal" handler="on_test_signal"/>
|
||||||
</template>
|
</template>
|
||||||
|
<object class="GtkDialog">
|
||||||
|
<property name="transient-for">TestTemplate</property>
|
||||||
|
</object>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue