mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
language: Add expression literals
Add expression literals, so you can set properties of type Gtk.Expression.
This commit is contained in:
parent
b9f58aeab5
commit
8c6f8760f7
29 changed files with 268 additions and 21 deletions
5
tests/sample_errors/expr_item_not_cast.blp
Normal file
5
tests/sample_errors/expr_item_not_cast.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr item.visible;
|
||||
}
|
1
tests/sample_errors/expr_item_not_cast.err
Normal file
1
tests/sample_errors/expr_item_not_cast.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,20,4,"item" must be cast to its object type
|
5
tests/sample_errors/expr_value_assignment.blp
Normal file
5
tests/sample_errors/expr_value_assignment.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
label: expr 1;
|
||||
}
|
1
tests/sample_errors/expr_value_assignment.err
Normal file
1
tests/sample_errors/expr_value_assignment.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,10,4,Cannot convert Gtk.Expression to string
|
5
tests/sample_errors/expr_value_closure_arg.blp
Normal file
5
tests/sample_errors/expr_value_closure_arg.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr $closure(item as <Entry>) as <bool>;
|
||||
}
|
1
tests/sample_errors/expr_value_closure_arg.err
Normal file
1
tests/sample_errors/expr_value_closure_arg.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,29,4,"item" can only be used for looking up properties
|
5
tests/sample_errors/expr_value_item.blp
Normal file
5
tests/sample_errors/expr_value_item.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr item as <Label>;
|
||||
}
|
1
tests/sample_errors/expr_value_item.err
Normal file
1
tests/sample_errors/expr_value_item.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,20,4,"item" can only be used for looking up properties
|
9
tests/samples/bind_expr_prop.blp
Normal file
9
tests/samples/bind_expr_prop.blp
Normal file
|
@ -0,0 +1,9 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter filter1 {
|
||||
expression: expr true;
|
||||
}
|
||||
|
||||
BoolFilter filter2 {
|
||||
expression: bind filter1.expression;
|
||||
}
|
17
tests/samples/bind_expr_prop.ui
Normal file
17
tests/samples/bind_expr_prop.ui
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?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="GtkBoolFilter" id="filter1">
|
||||
<property name="expression">
|
||||
<constant type="gboolean">true</constant>
|
||||
</property>
|
||||
</object>
|
||||
<object class="GtkBoolFilter" id="filter2">
|
||||
<property name="expression" bind-source="filter1" bind-property="expression" bind-flags="sync-create"/>
|
||||
</object>
|
||||
</interface>
|
5
tests/samples/bind_literal.blp
Normal file
5
tests/samples/bind_literal.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Label {
|
||||
label: bind "Hello, world!";
|
||||
}
|
14
tests/samples/bind_literal.ui
Normal file
14
tests/samples/bind_literal.ui
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?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="GtkLabel">
|
||||
<binding name="label">
|
||||
<constant type="gchararray">Hello, world!</constant>
|
||||
</binding>
|
||||
</object>
|
||||
</interface>
|
5
tests/samples/expr_value.blp
Normal file
5
tests/samples/expr_value.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr item as <Entry>.visible;
|
||||
}
|
14
tests/samples/expr_value.ui
Normal file
14
tests/samples/expr_value.ui
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?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="GtkBoolFilter">
|
||||
<property name="expression">
|
||||
<lookup name="visible" type="GtkEntry"></lookup>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
5
tests/samples/expr_value_closure.blp
Normal file
5
tests/samples/expr_value_closure.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr $closure(item as <Entry>.visible) as <bool>;
|
||||
}
|
16
tests/samples/expr_value_closure.ui
Normal file
16
tests/samples/expr_value_closure.ui
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?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="GtkBoolFilter">
|
||||
<property name="expression">
|
||||
<closure function="closure" type="gboolean">
|
||||
<lookup name="visible" type="GtkEntry"></lookup>
|
||||
</closure>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
5
tests/samples/expr_value_literal.blp
Normal file
5
tests/samples/expr_value_literal.blp
Normal file
|
@ -0,0 +1,5 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
BoolFilter {
|
||||
expression: expr true;
|
||||
}
|
14
tests/samples/expr_value_literal.ui
Normal file
14
tests/samples/expr_value_literal.ui
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?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="GtkBoolFilter">
|
||||
<property name="expression">
|
||||
<constant type="gboolean">true</constant>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
|
@ -198,6 +198,7 @@ class TestSamples(unittest.TestCase):
|
|||
"adw_breakpoint_template",
|
||||
"expr_closure",
|
||||
"expr_closure_args",
|
||||
"expr_value_closure",
|
||||
"parseable",
|
||||
"signal",
|
||||
"signal_not_swapped",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue