mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
lang: Allow ColumnView widgets to be built
Allow BuilderListItemFactory to contain Gtk.ColumnViewRow or Gtk.ColumnViewCell templates, in addition to Gtk.ListItem templates. This is necessary for people to use Gtk.ColumnView idiomatically in Blueprint. Fixes #157.
This commit is contained in:
parent
84e529a4a8
commit
988e69ab25
6 changed files with 85 additions and 6 deletions
|
@ -39,7 +39,10 @@ class ExtListItemFactory(AstNode):
|
|||
|
||||
@property
|
||||
def gir_class(self):
|
||||
return self.root.gir.get_type("ListItem", "Gtk")
|
||||
if self.type_name is not None:
|
||||
return self.type_name.gir_type
|
||||
else:
|
||||
return self.root.gir.get_type("ListItem", "Gtk")
|
||||
|
||||
@validate("template")
|
||||
def container_is_builder_list(self):
|
||||
|
@ -57,8 +60,14 @@ class ExtListItemFactory(AstNode):
|
|||
@validate()
|
||||
def type_is_list_item(self):
|
||||
if self.type_name is not None:
|
||||
if self.type_name.glib_type_name != "GtkListItem":
|
||||
raise CompileError(f"Only Gtk.ListItem is allowed as a type here")
|
||||
if self.type_name.glib_type_name not in (
|
||||
"GtkListItem",
|
||||
"GtkColumnViewRow",
|
||||
"GtkColumnViewCell",
|
||||
):
|
||||
raise CompileError(
|
||||
f"Only Gtk.ListItem, Gtk.ColumnViewRow, or Gtk.ColumnViewCell is allowed as a type here"
|
||||
)
|
||||
|
||||
@validate("template")
|
||||
def type_name_upgrade(self):
|
||||
|
|
|
@ -377,7 +377,7 @@ class XmlOutput(OutputFormat):
|
|||
elif isinstance(extension, ExtListItemFactory):
|
||||
child_xml = XmlEmitter()
|
||||
child_xml.start_tag("interface")
|
||||
child_xml.start_tag("template", **{"class": "GtkListItem"})
|
||||
child_xml.start_tag("template", **{"class": extension.gir_class})
|
||||
self._emit_object_or_template(extension, child_xml)
|
||||
child_xml.end_tag()
|
||||
child_xml.end_tag()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue