mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Support property binding flags
This commit is contained in:
parent
7cf3c0bfb1
commit
49658c634e
2 changed files with 13 additions and 1 deletions
|
@ -287,7 +287,7 @@ class ObjectContent(AstNode):
|
||||||
|
|
||||||
class Property(AstNode):
|
class Property(AstNode):
|
||||||
child_type = "properties"
|
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__()
|
super().__init__()
|
||||||
self.name = name
|
self.name = name
|
||||||
self.value = value
|
self.value = value
|
||||||
|
@ -296,6 +296,13 @@ class Property(AstNode):
|
||||||
self.bind_property = bind_property
|
self.bind_property = bind_property
|
||||||
self.objects = objects
|
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()
|
@validate()
|
||||||
def gir_property(self):
|
def gir_property(self):
|
||||||
|
@ -338,6 +345,7 @@ class Property(AstNode):
|
||||||
"translatable": "yes" if self.translatable else None,
|
"translatable": "yes" if self.translatable else None,
|
||||||
"bind-source": self.bind_source,
|
"bind-source": self.bind_source,
|
||||||
"bind-property": self.bind_property,
|
"bind-property": self.bind_property,
|
||||||
|
"bind-flags": self.bind_flags,
|
||||||
}
|
}
|
||||||
if self.objects is not None:
|
if self.objects is not None:
|
||||||
xml.start_tag("property", **props)
|
xml.start_tag("property", **props)
|
||||||
|
|
|
@ -103,6 +103,10 @@ def parse(tokens) -> ast.UI:
|
||||||
UseIdent("bind_source").expected("the ID of a source object to bind from"),
|
UseIdent("bind_source").expected("the ID of a source object to bind from"),
|
||||||
Op("."),
|
Op("."),
|
||||||
UseIdent("bind_property").expected("a property name to bind from"),
|
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("`;`"),
|
StmtEnd().expected("`;`"),
|
||||||
)
|
)
|
||||||
).recover()
|
).recover()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue