mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
lang: Also allow Gtk.ListHeader in factory template
This commit is contained in:
parent
c502dee36b
commit
07e824d8e7
4 changed files with 23 additions and 4 deletions
|
@ -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")
|
||||
|
|
|
@ -1 +1 @@
|
|||
4,3,17,Only Gtk.ListItem, Gtk.ColumnViewRow, or Gtk.ColumnViewCell is allowed as a type here
|
||||
4,11,6,Only Gtk.ListItem, Gtk.ListHeader, Gtk.ColumnViewRow, or Gtk.ColumnViewCell is allowed as a type here
|
|
@ -1,6 +1,10 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
ColumnView {
|
||||
header-factory: BuilderListItemFactory {
|
||||
template ListHeader {}
|
||||
};
|
||||
|
||||
row-factory: BuilderListItemFactory {
|
||||
template ColumnViewRow {}
|
||||
};
|
||||
|
|
|
@ -7,6 +7,14 @@ corresponding .blp file and regenerate this file with blueprint-compiler.
|
|||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkColumnView">
|
||||
<property name="header-factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="GtkListHeader"></template>
|
||||
</interface>]]></property>
|
||||
</object>
|
||||
</property>
|
||||
<property name="row-factory">
|
||||
<object class="GtkBuilderListItemFactory">
|
||||
<property name="bytes"><![CDATA[<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue