mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -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::
|
||||
|
||||
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),
|
||||
UseLiteral("tag_name", tag_name),
|
||||
Op(":"),
|
||||
OpenBracket(),
|
||||
Delimited(
|
||||
Group(
|
||||
FilterString,
|
||||
|
@ -59,6 +60,7 @@ def create_node(tag_name: str, singular: str):
|
|||
),
|
||||
Comma(),
|
||||
),
|
||||
CloseBracket(),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -75,7 +77,7 @@ suffixes = create_node("suffixes", "suffix")
|
|||
def file_filter_completer(ast_node, match_variables):
|
||||
file_filter = ast_node.root.gir.get_type("FileFilter", "Gtk")
|
||||
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("patterns", CompletionItemKind.Snippet, snippet="patterns \"$0\";")
|
||||
yield Completion("suffixes", CompletionItemKind.Snippet, snippet="suffixes \"$0\";")
|
||||
yield Completion("mime-types", CompletionItemKind.Snippet, snippet="mime-types: [\"$0\"];")
|
||||
yield Completion("patterns", CompletionItemKind.Snippet, snippet="patterns: [\"$0\"];")
|
||||
yield Completion("suffixes", CompletionItemKind.Snippet, snippet="suffixes: [\"$0\"];")
|
||||
|
||||
|
|
|
@ -43,7 +43,9 @@ class StyleClass(AstNode):
|
|||
styles = Group(
|
||||
Styles,
|
||||
Statement(
|
||||
Keyword("style"),
|
||||
Keyword("styles"),
|
||||
Op(":"),
|
||||
OpenBracket(),
|
||||
Delimited(
|
||||
Group(
|
||||
StyleClass,
|
||||
|
@ -51,6 +53,7 @@ styles = Group(
|
|||
),
|
||||
Comma(),
|
||||
),
|
||||
CloseBracket(),
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -60,5 +63,5 @@ styles = Group(
|
|||
matches=new_statement_patterns,
|
||||
)
|
||||
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 {
|
||||
name: "File Filter Name";
|
||||
mime-types: "text/plain", "image/ *";
|
||||
patterns: "*.txt";
|
||||
suffixes: "png";
|
||||
mime-types: ["text/plain", "image/ *"];
|
||||
patterns: ["*.txt"];
|
||||
suffixes: ["png"];
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
style "class-1", "class-2";
|
||||
styles: ["class-1", "class-2"];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue