mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Fix template IDs in a couple more places
This commit is contained in:
parent
3ebe5c72c1
commit
c95195197d
2 changed files with 18 additions and 28 deletions
|
@ -26,6 +26,10 @@ from .contexts import ScopeCtx
|
||||||
class Widget(AstNode):
|
class Widget(AstNode):
|
||||||
grammar = UseIdent("name")
|
grammar = UseIdent("name")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def name(self) -> str:
|
||||||
|
return self.tokens["name"]
|
||||||
|
|
||||||
@validate("name")
|
@validate("name")
|
||||||
def obj_widget(self):
|
def obj_widget(self):
|
||||||
object = self.context[ScopeCtx].objects.get(self.tokens["name"])
|
object = self.context[ScopeCtx].objects.get(self.tokens["name"])
|
||||||
|
|
|
@ -114,16 +114,7 @@ class XmlOutput(OutputFormat):
|
||||||
|
|
||||||
elif isinstance(value, Binding):
|
elif isinstance(value, Binding):
|
||||||
if simple := value.simple_binding:
|
if simple := value.simple_binding:
|
||||||
if (
|
props["bind-source"] = self._object_id(value, simple.source)
|
||||||
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-property"] = simple.property_name
|
||||||
props["bind-flags"] = "sync-create"
|
props["bind-flags"] = "sync-create"
|
||||||
xml.put_self_closing("property", **props)
|
xml.put_self_closing("property", **props)
|
||||||
|
@ -141,16 +132,7 @@ class XmlOutput(OutputFormat):
|
||||||
if value.bidirectional:
|
if value.bidirectional:
|
||||||
bind_flags.append("bidirectional")
|
bind_flags.append("bidirectional")
|
||||||
|
|
||||||
if (
|
props["bind-source"] = self._object_id(value, value.source)
|
||||||
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-property"] = value.property_name
|
||||||
props["bind-flags"] = "|".join(bind_flags) or None
|
props["bind-flags"] = "|".join(bind_flags) or None
|
||||||
xml.put_self_closing("property", **props)
|
xml.put_self_closing("property", **props)
|
||||||
|
@ -182,7 +164,9 @@ class XmlOutput(OutputFormat):
|
||||||
name=name,
|
name=name,
|
||||||
handler=signal.handler,
|
handler=signal.handler,
|
||||||
swapped=signal.is_swapped or None,
|
swapped=signal.is_swapped or None,
|
||||||
object=signal.object_id,
|
object=(
|
||||||
|
self._object_id(signal, signal.object_id) if signal.object_id else None
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
def _emit_child(self, child: Child, xml: XmlEmitter):
|
def _emit_child(self, child: Child, xml: XmlEmitter):
|
||||||
|
@ -210,13 +194,8 @@ class XmlOutput(OutputFormat):
|
||||||
xml.put_text(value.ident)
|
xml.put_text(value.ident)
|
||||||
elif isinstance(value_type, gir.Enumeration):
|
elif isinstance(value_type, gir.Enumeration):
|
||||||
xml.put_text(str(value_type.members[value.ident].value))
|
xml.put_text(str(value_type.members[value.ident].value))
|
||||||
elif (
|
|
||||||
value.ident == "template"
|
|
||||||
and value.context[ScopeCtx].template is not None
|
|
||||||
):
|
|
||||||
xml.put_text(value.context[ScopeCtx].template.gir_class.glib_type_name)
|
|
||||||
else:
|
else:
|
||||||
xml.put_text(value.ident)
|
xml.put_text(self._object_id(value, value.ident))
|
||||||
elif isinstance(value, TypeLiteral):
|
elif isinstance(value, TypeLiteral):
|
||||||
xml.put_text(value.type_name.glib_type_name)
|
xml.put_text(value.type_name.glib_type_name)
|
||||||
else:
|
else:
|
||||||
|
@ -394,6 +373,7 @@ class XmlOutput(OutputFormat):
|
||||||
xml.put_text(value.string)
|
xml.put_text(value.string)
|
||||||
xml.end_tag()
|
xml.end_tag()
|
||||||
xml.end_tag()
|
xml.end_tag()
|
||||||
|
|
||||||
elif isinstance(extension, ExtListItemFactory):
|
elif isinstance(extension, ExtListItemFactory):
|
||||||
child_xml = XmlEmitter()
|
child_xml = XmlEmitter()
|
||||||
child_xml.start_tag("interface")
|
child_xml.start_tag("interface")
|
||||||
|
@ -414,8 +394,14 @@ class XmlOutput(OutputFormat):
|
||||||
elif isinstance(extension, ExtSizeGroupWidgets):
|
elif isinstance(extension, ExtSizeGroupWidgets):
|
||||||
xml.start_tag("widgets")
|
xml.start_tag("widgets")
|
||||||
for prop in extension.children:
|
for prop in extension.children:
|
||||||
xml.put_self_closing("widget", name=prop.tokens["name"])
|
xml.put_self_closing("widget", name=prop.name)
|
||||||
xml.end_tag()
|
xml.end_tag()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise CompilerBugError()
|
raise CompilerBugError()
|
||||||
|
|
||||||
|
def _object_id(self, node: AstNode, id: str) -> str:
|
||||||
|
if id == "template" and node.context[ScopeCtx].template is not None:
|
||||||
|
return node.context[ScopeCtx].template.gir_class.glib_type_name
|
||||||
|
else:
|
||||||
|
return id
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue