mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-05 16:09:07 -04:00
Use array-like syntax for styles, file filters
These are now pseudo-properties with brackets around the array items, for consistency with more familiar languages.
This commit is contained in:
parent
ebfa72d94f
commit
f8478adf3a
5 changed files with 15 additions and 10 deletions
|
@ -199,7 +199,7 @@ Basic Usage
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
Gtk.Label {
|
Gtk.Label {
|
||||||
style "dim-label", "title";
|
styles: ["dim-label", "title"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ def create_node(tag_name: str, singular: str):
|
||||||
Keyword(tag_name),
|
Keyword(tag_name),
|
||||||
UseLiteral("tag_name", tag_name),
|
UseLiteral("tag_name", tag_name),
|
||||||
Op(":"),
|
Op(":"),
|
||||||
|
OpenBracket(),
|
||||||
Delimited(
|
Delimited(
|
||||||
Group(
|
Group(
|
||||||
FilterString,
|
FilterString,
|
||||||
|
@ -59,6 +60,7 @@ def create_node(tag_name: str, singular: str):
|
||||||
),
|
),
|
||||||
Comma(),
|
Comma(),
|
||||||
),
|
),
|
||||||
|
CloseBracket(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ suffixes = create_node("suffixes", "suffix")
|
||||||
def file_filter_completer(ast_node, match_variables):
|
def file_filter_completer(ast_node, match_variables):
|
||||||
file_filter = ast_node.root.gir.get_type("FileFilter", "Gtk")
|
file_filter = ast_node.root.gir.get_type("FileFilter", "Gtk")
|
||||||
if ast_node.gir_class and ast_node.gir_class.assignable_to(file_filter):
|
if ast_node.gir_class and ast_node.gir_class.assignable_to(file_filter):
|
||||||
yield Completion("mime-types", CompletionItemKind.Snippet, snippet="mime-types \"$0\";")
|
yield Completion("mime-types", CompletionItemKind.Snippet, snippet="mime-types: [\"$0\"];")
|
||||||
yield Completion("patterns", CompletionItemKind.Snippet, snippet="patterns \"$0\";")
|
yield Completion("patterns", CompletionItemKind.Snippet, snippet="patterns: [\"$0\"];")
|
||||||
yield Completion("suffixes", CompletionItemKind.Snippet, snippet="suffixes \"$0\";")
|
yield Completion("suffixes", CompletionItemKind.Snippet, snippet="suffixes: [\"$0\"];")
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,9 @@ class StyleClass(AstNode):
|
||||||
styles = Group(
|
styles = Group(
|
||||||
Styles,
|
Styles,
|
||||||
Statement(
|
Statement(
|
||||||
Keyword("style"),
|
Keyword("styles"),
|
||||||
|
Op(":"),
|
||||||
|
OpenBracket(),
|
||||||
Delimited(
|
Delimited(
|
||||||
Group(
|
Group(
|
||||||
StyleClass,
|
StyleClass,
|
||||||
|
@ -51,6 +53,7 @@ styles = Group(
|
||||||
),
|
),
|
||||||
Comma(),
|
Comma(),
|
||||||
),
|
),
|
||||||
|
CloseBracket(),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,5 +63,5 @@ styles = Group(
|
||||||
matches=new_statement_patterns,
|
matches=new_statement_patterns,
|
||||||
)
|
)
|
||||||
def style_completer(ast_node, match_variables):
|
def style_completer(ast_node, match_variables):
|
||||||
yield Completion("style", CompletionItemKind.Keyword, snippet="style \"$0\";")
|
yield Completion("styles", CompletionItemKind.Keyword, snippet="styles: [\"$0\"];")
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ using Gtk 4.0;
|
||||||
|
|
||||||
FileFilter {
|
FileFilter {
|
||||||
name: "File Filter Name";
|
name: "File Filter Name";
|
||||||
mime-types: "text/plain", "image/ *";
|
mime-types: ["text/plain", "image/ *"];
|
||||||
patterns: "*.txt";
|
patterns: ["*.txt"];
|
||||||
suffixes: "png";
|
suffixes: ["png"];
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using Gtk 4.0;
|
using Gtk 4.0;
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
style "class-1", "class-2";
|
styles: ["class-1", "class-2"];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue