mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Compare commits
6 commits
06d007a30a
...
78618cb75a
Author | SHA1 | Date | |
---|---|---|---|
|
78618cb75a | ||
|
6a77bfee0a | ||
|
f50b898e4c | ||
|
cc09f3d3bb | ||
|
f93d5d2acd | ||
|
9f9a2d94e0 |
8 changed files with 102 additions and 9 deletions
|
@ -81,8 +81,8 @@ class AdwBreakpointSetter(AstNode):
|
||||||
return self.tokens["property"]
|
return self.tokens["property"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def value(self) -> Value:
|
def value(self) -> T.Optional[Value]:
|
||||||
return self.children[Value][0]
|
return self.children[Value][0] if len(self.children[Value]) > 0 else None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def gir_class(self) -> T.Optional[GirType]:
|
def gir_class(self) -> T.Optional[GirType]:
|
||||||
|
@ -106,7 +106,10 @@ class AdwBreakpointSetter(AstNode):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def document_symbol(self) -> DocumentSymbol:
|
def document_symbol(self) -> T.Optional[DocumentSymbol]:
|
||||||
|
if self.value is None:
|
||||||
|
return None
|
||||||
|
|
||||||
return DocumentSymbol(
|
return DocumentSymbol(
|
||||||
f"{self.object_id}.{self.property_name}",
|
f"{self.object_id}.{self.property_name}",
|
||||||
SymbolKind.Property,
|
SymbolKind.Property,
|
||||||
|
|
|
@ -308,6 +308,9 @@ class XmlOutput(OutputFormat):
|
||||||
|
|
||||||
elif isinstance(extension, AdwBreakpointSetters):
|
elif isinstance(extension, AdwBreakpointSetters):
|
||||||
for setter in extension.setters:
|
for setter in extension.setters:
|
||||||
|
if setter.value is None:
|
||||||
|
continue
|
||||||
|
|
||||||
attrs = {}
|
attrs = {}
|
||||||
|
|
||||||
if isinstance(setter.value.child, Translated):
|
if isinstance(setter.value.child, Translated):
|
||||||
|
|
|
@ -73,6 +73,7 @@ class XmlEmitter:
|
||||||
self._needs_newline = False
|
self._needs_newline = False
|
||||||
|
|
||||||
def put_cdata(self, text: str):
|
def put_cdata(self, text: str):
|
||||||
|
text = text.replace("]]>", "]]]]><![CDATA[>")
|
||||||
self.result += f"<![CDATA[{text}]]>"
|
self.result += f"<![CDATA[{text}]]>"
|
||||||
self._needs_newline = False
|
self._needs_newline = False
|
||||||
|
|
||||||
|
|
|
@ -48,12 +48,19 @@ blueprint-compiler works as a meson subproject.
|
||||||
|
|
||||||
.. code-block:: meson.build
|
.. code-block:: meson.build
|
||||||
|
|
||||||
|
blps = [
|
||||||
|
# LIST YOUR BLUEPRINT FILES HERE
|
||||||
|
]
|
||||||
|
|
||||||
|
uis = []
|
||||||
|
foreach blp : blps
|
||||||
|
uis += blp.replace('.blp', '.ui')
|
||||||
|
endforeach
|
||||||
|
|
||||||
blueprints = custom_target('blueprints',
|
blueprints = custom_target('blueprints',
|
||||||
input: files(
|
input: blps,
|
||||||
# LIST YOUR BLUEPRINT FILES HERE
|
output: uis,
|
||||||
),
|
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTDIR@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
|
||||||
output: '.',
|
|
||||||
command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
#. In the same ``meson.build`` file, add this argument to your ``gnome.compile_resources`` command:
|
#. In the same ``meson.build`` file, add this argument to your ``gnome.compile_resources`` command:
|
||||||
|
|
17
tests/samples/list_factory_nested.blp
Normal file
17
tests/samples/list_factory_nested.blp
Normal file
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
44
tests/samples/list_factory_nested.ui
Normal file
44
tests/samples/list_factory_nested.ui
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--
|
||||||
|
DO NOT EDIT!
|
||||||
|
This file was @generated by blueprint-compiler. Instead, edit the
|
||||||
|
corresponding .blp file and regenerate this file with blueprint-compiler.
|
||||||
|
-->
|
||||||
|
<interface>
|
||||||
|
<requires lib="gtk" version="4.0"/>
|
||||||
|
<object class="GtkListView">
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory" id="list_item_factory">
|
||||||
|
<property name="bytes"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="GtkListItem">
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkListView">
|
||||||
|
<property name="factory">
|
||||||
|
<object class="GtkBuilderListItemFactory" id="list_item_factory">
|
||||||
|
<property name="bytes"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<interface>
|
||||||
|
<template class="GtkListItem">
|
||||||
|
<property name="child">
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<binding name="label">
|
||||||
|
<lookup name="name" type="MyObject">
|
||||||
|
<lookup name="item" type="GtkListItem">
|
||||||
|
<constant>GtkListItem</constant>
|
||||||
|
</lookup>
|
||||||
|
</lookup>
|
||||||
|
</binding>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>]]]]><![CDATA[></property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</template>
|
||||||
|
</interface>]]></property>
|
||||||
|
</object>
|
||||||
|
</property>
|
||||||
|
</object>
|
||||||
|
</interface>
|
18
tests/samples/list_factory_nested_dec.blp
Normal file
18
tests/samples/list_factory_nested_dec.blp
Normal file
|
@ -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;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ from blueprintcompiler.tokenizer import Token, TokenType, tokenize
|
||||||
|
|
||||||
|
|
||||||
class TestTokenizer(unittest.TestCase):
|
class TestTokenizer(unittest.TestCase):
|
||||||
def assert_tokenize(self, string: str, expect: [Token]):
|
def assert_tokenize(self, string: str, expect: list[Token]):
|
||||||
try:
|
try:
|
||||||
tokens = tokenize(string)
|
tokens = tokenize(string)
|
||||||
self.assertEqual(len(tokens), len(expect))
|
self.assertEqual(len(tokens), len(expect))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue