Support property binding flags

This commit is contained in:
James Westman 2021-10-24 13:45:03 -05:00
parent 7cf3c0bfb1
commit 49658c634e
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
2 changed files with 13 additions and 1 deletions

View file

@ -287,7 +287,7 @@ class ObjectContent(AstNode):
class Property(AstNode):
child_type = "properties"
def __init__(self, name, value=None, translatable=False, bind_source=None, bind_property=None, objects=None):
def __init__(self, name, value=None, translatable=False, bind_source=None, bind_property=None, objects=None, sync_create=None, after=None):
super().__init__()
self.name = name
self.value = value
@ -296,6 +296,13 @@ class Property(AstNode):
self.bind_property = bind_property
self.objects = objects
bind_flags = []
if sync_create:
bind_flags.append("sync-create")
if after:
bind_flags.append("after")
self.bind_flags = "|".join(bind_flags) or None
@validate()
def gir_property(self):
@ -338,6 +345,7 @@ class Property(AstNode):
"translatable": "yes" if self.translatable else None,
"bind-source": self.bind_source,
"bind-property": self.bind_property,
"bind-flags": self.bind_flags,
}
if self.objects is not None:
xml.start_tag("property", **props)

View file

@ -103,6 +103,10 @@ def parse(tokens) -> ast.UI:
UseIdent("bind_source").expected("the ID of a source object to bind from"),
Op("."),
UseIdent("bind_property").expected("a property name to bind from"),
AnyOf(
Sequence(Keyword("sync-create"), UseLiteral("sync_create", True)),
Sequence(Keyword("after"), UseLiteral("after", True)),
),
StmtEnd().expected("`;`"),
)
).recover()