mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
parent
f6eacaa3d9
commit
b9fdc5a5f1
4 changed files with 9 additions and 10 deletions
|
@ -97,13 +97,15 @@ class Object(AstNode):
|
||||||
if child.response_id
|
if child.response_id
|
||||||
]
|
]
|
||||||
|
|
||||||
def emit_xml(self, xml: XmlEmitter):
|
def emit_start_tag(self, xml: XmlEmitter):
|
||||||
from .gtkbuilder_child import Child
|
|
||||||
|
|
||||||
xml.start_tag("object", **{
|
xml.start_tag("object", **{
|
||||||
"class": self.gir_class or self.tokens["class_name"],
|
"class": self.gir_class or self.tokens["class_name"],
|
||||||
"id": self.tokens["id"],
|
"id": self.tokens["id"],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
def emit_xml(self, xml: XmlEmitter):
|
||||||
|
self.emit_start_tag(xml)
|
||||||
|
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
child.emit_xml(xml)
|
child.emit_xml(xml)
|
||||||
|
|
||||||
|
|
|
@ -41,15 +41,12 @@ class Template(Object):
|
||||||
def unique_in_parent(self):
|
def unique_in_parent(self):
|
||||||
self.validate_unique_in_parent(f"Only one template may be defined per file, but this file contains {len(self.parent.children[Template])}",)
|
self.validate_unique_in_parent(f"Only one template may be defined per file, but this file contains {len(self.parent.children[Template])}",)
|
||||||
|
|
||||||
def emit_xml(self, xml: XmlEmitter):
|
def emit_start_tag(self, xml: XmlEmitter):
|
||||||
xml.start_tag(
|
xml.start_tag(
|
||||||
"template",
|
"template",
|
||||||
**{"class": self.tokens["name"]},
|
**{"class": self.tokens["name"]},
|
||||||
parent=self.gir_class or self.tokens["class_name"]
|
parent=self.gir_class or self.tokens["class_name"]
|
||||||
)
|
)
|
||||||
for child in self.children:
|
|
||||||
child.emit_xml(xml)
|
|
||||||
xml.end_tag()
|
|
||||||
|
|
||||||
|
|
||||||
@decompiler("template")
|
@decompiler("template")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using Gtk 4.0;
|
using Gtk 4.0;
|
||||||
|
|
||||||
Dialog {
|
template MyDialog : Dialog {
|
||||||
[action response=cancel]
|
[action response=cancel]
|
||||||
Button cancel_button {
|
Button cancel_button {
|
||||||
label: _("Cancel");
|
label: _("Cancel");
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface>
|
<interface>
|
||||||
<requires lib="gtk" version="4.0"/>
|
<requires lib="gtk" version="4.0"/>
|
||||||
<object class="GtkDialog">
|
<template class="MyDialog" parent="GtkDialog">
|
||||||
<child type="action">
|
<child type="action">
|
||||||
<object class="GtkButton" id="cancel_button">
|
<object class="GtkButton" id="cancel_button">
|
||||||
<property name="label" translatable="true">Cancel</property>
|
<property name="label" translatable="true">Cancel</property>
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<action-widget response="9">custom_response_button</action-widget>
|
<action-widget response="9">custom_response_button</action-widget>
|
||||||
<action-widget response="ok" default="True">ok_button</action-widget>
|
<action-widget response="ok" default="True">ok_button</action-widget>
|
||||||
</action-widgets>
|
</action-widgets>
|
||||||
</object>
|
</template>
|
||||||
<object class="GtkInfoBar">
|
<object class="GtkInfoBar">
|
||||||
<child type="action">
|
<child type="action">
|
||||||
<object class="GtkButton" id="ok_info_button">
|
<object class="GtkButton" id="ok_info_button">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue