Change template syntax

Templates now use a TypeName instead of an identifier, which makes it
clearer that it's an extern symbol (or that it's a Gtk.ListItem).
This commit is contained in:
James Westman 2023-05-09 19:42:33 -05:00
parent aebf8be278
commit 04509e4b2e
31 changed files with 175 additions and 55 deletions

View file

@ -1,4 +1,4 @@
using Gtk 4.0;
template MyWidget : Gtk.Widget {}
template $MyWidget : Gtk.Widget {}
Gtk.Widget {}

View file

@ -1,3 +1,3 @@
using Gtk 4.0;
template TestTemplate : Gtk.NotARealClass {}
template $TestTemplate : Gtk.NotARealClass {}

View file

@ -1 +1 @@
3,29,13,Namespace Gtk does not contain a type called NotARealClass
3,30,13,Namespace Gtk does not contain a type called NotARealClass

View file

@ -1,7 +1,5 @@
using Gtk 4.0;
template GtkListItem {
Label {
label: bind GtkListItem.item.label;
}
$MyObject object {
foo: bind object.bar.baz;
}

View file

@ -1 +1 @@
5,34,5,Could not determine the type of the preceding expression
4,24,3,Could not determine the type of the preceding expression

View file

@ -0,0 +1,10 @@
using Gtk 4.0;
template TestTemplate : ApplicationWindow {
test-property: "Hello, world";
test-signal => $on_test_signal();
}
Dialog {
transient-for: TestTemplate;
}

View file

@ -0,0 +1,2 @@
3,10,12,Use type syntax here (introduced in blueprint 0.8.0)
9,18,12,Use 'template' instead of the class name (introduced in 0.8.0)

View file

@ -1,3 +1,3 @@
using Gtk 4.0;
template TestTemplate : Gtk.Orientable {}
template $TestTemplate : Gtk.Orientable {}

View file

@ -1 +1 @@
3,25,14,Gtk.Orientable is an interface, not a class
3,26,14,Gtk.Orientable is an interface, not a class

View file

@ -1,3 +1,3 @@
using Gtk 4.0;
template TestTemplate : Adw.ApplicationWindow {}
template $TestTemplate : Adw.ApplicationWindow {}

View file

@ -1 +1 @@
3,25,3,Namespace Adw was not imported
3,26,3,Namespace Adw was not imported

View file

@ -0,0 +1,3 @@
using Gtk 4.0;
template Gtk.ListItem : $WrongParent {}

View file

@ -0,0 +1 @@
3,1,39,Parent type may only be specified if the template type is extern

View file

@ -1,4 +1,6 @@
using Gtk 4.0;
template ClassName : Gtk.Button {}
template ClassName2 : Gtk.Button {}
template $ClassName : Gtk.Button {}
template $ClassName2 : Gtk.Button {}
Label template {}

View file

@ -1 +1,2 @@
4,10,10,Only one template may be defined per file, but this file contains 2
6,7,8,Duplicate object ID 'template'
4,1,8,Only one template may be defined per file, but this file contains 2

View file

@ -1,10 +1,10 @@
using Gtk 4.0;
template TestTemplate : ApplicationWindow {
template $TestTemplate : ApplicationWindow {
test-property: "Hello, world";
test-signal => $on_test_signal();
}
Dialog {
transient-for: TestTemplate;
transient-for: template;
}

View file

@ -1,5 +1,5 @@
using Gtk 4.0;
template MyTemplate : Box {
prop1: bind MyTemplate.prop2 as <$MyObject>.prop3;
template $MyTemplate : Box {
prop1: bind template.prop2 as <$MyObject>.prop3;
}

View file

@ -1,5 +1,5 @@
using Gtk 4.0;
template MyTemplate : $MyParentClass {
prop1: bind MyTemplate.prop2 as <$MyObject>.prop3;
template $MyTemplate : $MyParentClass {
prop1: bind template.prop2 as <$MyObject>.prop3;
}

View file

@ -1,3 +1,3 @@
using Gtk 4.0;
template GtkListItem {}
template Gtk.ListItem {}

View file

@ -266,6 +266,7 @@ class TestSamples(unittest.TestCase):
self.assert_sample_error("inline_menu")
self.assert_sample_error("invalid_bool")
self.assert_sample_error("layout_in_non_widget")
self.assert_sample_error("legacy_template")
self.assert_sample_error("menu_no_id")
self.assert_sample_error("menu_toplevel_attribute")
self.assert_sample_error("no_import_version")
@ -284,6 +285,7 @@ class TestSamples(unittest.TestCase):
self.assert_sample_error("strv")
self.assert_sample_error("styles_in_non_widget")
self.assert_sample_error("subscope")
self.assert_sample_error("template_parent")
self.assert_sample_error("two_templates")
self.assert_sample_error("uint")
self.assert_sample_error("using_invalid_namespace")