diff --git a/blueprintcompiler/language/gtk_list_item_factory.py b/blueprintcompiler/language/gtk_list_item_factory.py index 5b6177f..c54547f 100644 --- a/blueprintcompiler/language/gtk_list_item_factory.py +++ b/blueprintcompiler/language/gtk_list_item_factory.py @@ -11,7 +11,13 @@ from .types import TypeName class ExtListItemFactory(AstNode): - grammar = [UseExact("id", "template"), Optional(TypeName), ObjectContent] + grammar = [ + UseExact("id", "template"), + Mark("typename_start"), + Optional(TypeName), + Mark("typename_end"), + ObjectContent, + ] @property def id(self) -> str: @@ -57,16 +63,17 @@ class ExtListItemFactory(AstNode): def unique_in_parent(self): self.validate_unique_in_parent("Duplicate template block") - @validate() + @validate("typename_start", "typename_end") def type_is_list_item(self): if self.type_name is not None: if self.type_name.glib_type_name not in ( "GtkListItem", + "GtkListHeader", "GtkColumnViewRow", "GtkColumnViewCell", ): raise CompileError( - f"Only Gtk.ListItem, Gtk.ColumnViewRow, or Gtk.ColumnViewCell is allowed as a type here" + f"Only Gtk.ListItem, Gtk.ListHeader, Gtk.ColumnViewRow, or Gtk.ColumnViewCell is allowed as a type here" ) @validate("template") diff --git a/tests/sample_errors/list_factory.err b/tests/sample_errors/list_factory.err index 1d4dfaa..344e5dd 100644 --- a/tests/sample_errors/list_factory.err +++ b/tests/sample_errors/list_factory.err @@ -1 +1 @@ -4,3,17,Only Gtk.ListItem, Gtk.ColumnViewRow, or Gtk.ColumnViewCell is allowed as a type here \ No newline at end of file +4,11,6,Only Gtk.ListItem, Gtk.ListHeader, Gtk.ColumnViewRow, or Gtk.ColumnViewCell is allowed as a type here \ No newline at end of file diff --git a/tests/samples/gtkcolumnview.blp b/tests/samples/gtkcolumnview.blp index 9f11dd3..3f5bee9 100644 --- a/tests/samples/gtkcolumnview.blp +++ b/tests/samples/gtkcolumnview.blp @@ -1,6 +1,10 @@ using Gtk 4.0; ColumnView { + header-factory: BuilderListItemFactory { + template ListHeader {} + }; + row-factory: BuilderListItemFactory { template ColumnViewRow {} }; diff --git a/tests/samples/gtkcolumnview.ui b/tests/samples/gtkcolumnview.ui index 22c09e8..c6d4ddb 100644 --- a/tests/samples/gtkcolumnview.ui +++ b/tests/samples/gtkcolumnview.ui @@ -7,6 +7,14 @@ corresponding .blp file and regenerate this file with blueprint-compiler. + + + + + +]]> + +