mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Add Adw.MessageDialog responses extension
This commit is contained in:
parent
749ee03e86
commit
0cf9a8e4fc
7 changed files with 221 additions and 14 deletions
|
@ -126,14 +126,17 @@ class XmlOutput(OutputFormat):
|
|||
xml.end_tag()
|
||||
|
||||
def _translated_string_attrs(
|
||||
self, translated: Translated
|
||||
self, translated: T.Union[QuotedLiteral, Translated]
|
||||
) -> T.Dict[str, T.Optional[str]]:
|
||||
return {
|
||||
"translatable": "true",
|
||||
"context": translated.child.context
|
||||
if isinstance(translated.child, TranslatedWithContext)
|
||||
else None,
|
||||
}
|
||||
if isinstance(translated, QuotedLiteral):
|
||||
return {}
|
||||
else:
|
||||
return {
|
||||
"translatable": "true",
|
||||
"context": translated.child.context
|
||||
if isinstance(translated.child, TranslatedWithContext)
|
||||
else None,
|
||||
}
|
||||
|
||||
def _emit_signal(self, signal: Signal, xml: XmlEmitter):
|
||||
name = signal.name
|
||||
|
@ -270,6 +273,24 @@ class XmlOutput(OutputFormat):
|
|||
self._emit_attribute("property", "name", prop.name, prop.value, xml)
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(extension, Responses):
|
||||
xml.start_tag("responses")
|
||||
for response in extension.responses:
|
||||
# todo: translated
|
||||
xml.start_tag(
|
||||
"response",
|
||||
id=response.id,
|
||||
**self._translated_string_attrs(response.value),
|
||||
enabled=None if response.enabled else "false",
|
||||
appearance=response.appearance,
|
||||
)
|
||||
if isinstance(response.value, Translated):
|
||||
xml.put_text(response.value.child.string)
|
||||
else:
|
||||
xml.put_text(response.value.value)
|
||||
xml.end_tag()
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(extension, Strings):
|
||||
xml.start_tag("items")
|
||||
for prop in extension.children:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue