From 9f9a2d94e0622d9c3ae732bbace1a30967778a13 Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Fri, 3 Dec 2021 16:58:24 +0000 Subject: [PATCH 1/5] setup.rst: Fix meson dependencies The previous way did not establish dependencies between .ui files and the gresource properly. --- docs/setup.rst | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/docs/setup.rst b/docs/setup.rst index bb61ae3..af7a6ef 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -48,12 +48,19 @@ blueprint-compiler works as a meson subproject. .. code-block:: meson.build + blps = [ + # LIST YOUR BLUEPRINT FILES HERE + ] + + uis = [] + foreach blp : blps + uis += blp.replace('.blp', '.ui') + endforeach + blueprints = custom_target('blueprints', - input: files( - # LIST YOUR BLUEPRINT FILES HERE - ), - output: '.', - command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], + input: blps, + output: uis, + command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTDIR@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], ) #. In the same ``meson.build`` file, add this argument to your ``gnome.compile_resources`` command: From f93d5d2acd53365f70e48a0002e91e94be37f733 Mon Sep 17 00:00:00 2001 From: Tom Greig Date: Fri, 28 Mar 2025 20:26:19 +0000 Subject: [PATCH 2/5] Handle nested CDATA from nested templates When putting CDATA into the output, any instances of ']]>' in the text are replaced with ']]]]>'. This allows nested templates, e.g. from list views inside list views to work properly. --- blueprintcompiler/outputs/xml/xml_emitter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/blueprintcompiler/outputs/xml/xml_emitter.py b/blueprintcompiler/outputs/xml/xml_emitter.py index ea91e03..d34eff4 100644 --- a/blueprintcompiler/outputs/xml/xml_emitter.py +++ b/blueprintcompiler/outputs/xml/xml_emitter.py @@ -73,6 +73,7 @@ class XmlEmitter: self._needs_newline = False def put_cdata(self, text: str): + text = text.replace("]]>", "]]]]>") self.result += f"" self._needs_newline = False From cc09f3d3bb8e6f273072c1b4727929bf7b0bad83 Mon Sep 17 00:00:00 2001 From: Tom Greig Date: Sun, 30 Mar 2025 10:27:11 +0100 Subject: [PATCH 3/5] Add tests for nested templates Basically just a copy of the list_factory test, but with an extra copy of the list factory inside it. --- tests/samples/list_factory_nested.blp | 17 +++++++++ tests/samples/list_factory_nested.ui | 44 +++++++++++++++++++++++ tests/samples/list_factory_nested_dec.blp | 18 ++++++++++ 3 files changed, 79 insertions(+) create mode 100644 tests/samples/list_factory_nested.blp create mode 100644 tests/samples/list_factory_nested.ui create mode 100644 tests/samples/list_factory_nested_dec.blp diff --git a/tests/samples/list_factory_nested.blp b/tests/samples/list_factory_nested.blp new file mode 100644 index 0000000..86a59b3 --- /dev/null +++ b/tests/samples/list_factory_nested.blp @@ -0,0 +1,17 @@ +using Gtk 4.0; + +Gtk.ListView { + factory: Gtk.BuilderListItemFactory list_item_factory { + template ListItem { + child: Gtk.ListView { + factory: Gtk.BuilderListItemFactory list_item_factory { + template ListItem { + child: Gtk.Label { + label: bind template.item as <$MyObject>.name; + }; + } + }; + }; + } + }; +} diff --git a/tests/samples/list_factory_nested.ui b/tests/samples/list_factory_nested.ui new file mode 100644 index 0000000..44cdb2b --- /dev/null +++ b/tests/samples/list_factory_nested.ui @@ -0,0 +1,44 @@ + + + + + + + + + + +]]> + + + + diff --git a/tests/samples/list_factory_nested_dec.blp b/tests/samples/list_factory_nested_dec.blp new file mode 100644 index 0000000..755491c --- /dev/null +++ b/tests/samples/list_factory_nested_dec.blp @@ -0,0 +1,18 @@ +using Gtk 4.0; + +ListView { + factory: BuilderListItemFactory list_item_factory { + template ListItem { + child: ListView { + factory: BuilderListItemFactory list_item_factory { + template ListItem { + child: Label { + label: bind template.item as <$MyObject>.name; + }; + } + }; + }; + } + }; +} + From f50b898e4ce74d84cfa92ce44e90f9aaca2ec133 Mon Sep 17 00:00:00 2001 From: James Westman Date: Tue, 1 Apr 2025 19:27:59 -0500 Subject: [PATCH 4/5] adw_breakpoint: Fix crash in language server Fix a crash that happened when an AdwBreakpointSetter rule was incomplete, such as when you're still typing it. Fixes #189. --- blueprintcompiler/language/adw_breakpoint.py | 9 ++++++--- blueprintcompiler/outputs/xml/__init__.py | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/blueprintcompiler/language/adw_breakpoint.py b/blueprintcompiler/language/adw_breakpoint.py index 4ad5b24..3d2c10d 100644 --- a/blueprintcompiler/language/adw_breakpoint.py +++ b/blueprintcompiler/language/adw_breakpoint.py @@ -81,8 +81,8 @@ class AdwBreakpointSetter(AstNode): return self.tokens["property"] @property - def value(self) -> Value: - return self.children[Value][0] + def value(self) -> T.Optional[Value]: + return self.children[Value][0] if len(self.children[Value]) > 0 else None @property def gir_class(self) -> T.Optional[GirType]: @@ -106,7 +106,10 @@ class AdwBreakpointSetter(AstNode): return None @property - def document_symbol(self) -> DocumentSymbol: + def document_symbol(self) -> T.Optional[DocumentSymbol]: + if self.value is None: + return None + return DocumentSymbol( f"{self.object_id}.{self.property_name}", SymbolKind.Property, diff --git a/blueprintcompiler/outputs/xml/__init__.py b/blueprintcompiler/outputs/xml/__init__.py index 5c03761..15850f7 100644 --- a/blueprintcompiler/outputs/xml/__init__.py +++ b/blueprintcompiler/outputs/xml/__init__.py @@ -308,6 +308,9 @@ class XmlOutput(OutputFormat): elif isinstance(extension, AdwBreakpointSetters): for setter in extension.setters: + if setter.value is None: + continue + attrs = {} if isinstance(setter.value.child, Translated): From 6a77bfee0a5b2a03390c4ed7f945902a070ef697 Mon Sep 17 00:00:00 2001 From: James Westman Date: Sat, 19 Apr 2025 13:27:20 -0500 Subject: [PATCH 5/5] tests: Fix typing --- tests/test_tokenizer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_tokenizer.py b/tests/test_tokenizer.py index 2bca595..ad5f828 100644 --- a/tests/test_tokenizer.py +++ b/tests/test_tokenizer.py @@ -25,7 +25,7 @@ from blueprintcompiler.tokenizer import Token, TokenType, tokenize class TestTokenizer(unittest.TestCase): - def assert_tokenize(self, string: str, expect: [Token]): + def assert_tokenize(self, string: str, expect: list[Token]): try: tokens = tokenize(string) self.assertEqual(len(tokens), len(expect))