From 32d4769f6506bc336d49f71344333a5e1cbdba64 Mon Sep 17 00:00:00 2001 From: James Westman Date: Wed, 26 Jan 2022 23:30:19 -0600 Subject: [PATCH] Change sync-create to no-sync-create Fixes #31 --- blueprintcompiler/decompiler.py | 14 +++++++------- blueprintcompiler/language/gobject_property.py | 5 +++-- tests/samples/binding.blp | 2 +- tests/samples/binding.ui | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/blueprintcompiler/decompiler.py b/blueprintcompiler/decompiler.py index 908d4d5..60a066c 100644 --- a/blueprintcompiler/decompiler.py +++ b/blueprintcompiler/decompiler.py @@ -249,13 +249,13 @@ def decompile_property(ctx, gir, name, cdata, bind_source=None, bind_property=No ctx.end_block_with(";") elif bind_source: flags = "" - if bind_flags: - if "sync-create" in bind_flags: - flags += " sync-create" - if "invert-boolean" in bind_flags: - flags += " inverted" - if "bidirectional" in bind_flags: - flags += " bidirectional" + bind_flags = bind_flags or [] + if "sync-create" not in bind_flags: + flags += " no-sync-create" + if "invert-boolean" in bind_flags: + flags += " inverted" + if "bidirectional" in bind_flags: + flags += " bidirectional" ctx.print(f"{name}: bind {bind_source}.{bind_property}{flags};") elif truthy(translatable): if context is not None: diff --git a/blueprintcompiler/language/gobject_property.py b/blueprintcompiler/language/gobject_property.py index bf63820..cbe31df 100644 --- a/blueprintcompiler/language/gobject_property.py +++ b/blueprintcompiler/language/gobject_property.py @@ -34,7 +34,8 @@ class Property(AstNode): ".", UseIdent("bind_property").expected("a property name to bind from"), ZeroOrMore(AnyOf( - ["sync-create", UseLiteral("sync_create", True)], + "sync-create", + ["no-sync-create", UseLiteral("no_sync_create", True)], ["inverted", UseLiteral("inverted", True)], ["bidirectional", UseLiteral("bidirectional", True)], )), @@ -109,7 +110,7 @@ class Property(AstNode): value = values[0] if len(values) == 1 else None bind_flags = [] - if self.tokens["sync_create"]: + if self.tokens["bind_source"] and not self.tokens["no_sync_create"]: bind_flags.append("sync-create") if self.tokens["inverted"]: bind_flags.append("invert-boolean") diff --git a/tests/samples/binding.blp b/tests/samples/binding.blp index b8b48c2..39e4458 100644 --- a/tests/samples/binding.blp +++ b/tests/samples/binding.blp @@ -3,7 +3,7 @@ using Gtk 4.0; Box { visible: bind box2.visible inverted; orientation: bind box2.orientation; - spacing: bind box2.spacing sync-create; + spacing: bind box2.spacing no-sync-create; } Box box2 { diff --git a/tests/samples/binding.ui b/tests/samples/binding.ui index 5644afa..c496366 100644 --- a/tests/samples/binding.ui +++ b/tests/samples/binding.ui @@ -2,9 +2,9 @@ - - - + + + 6