feat: add syntax for GtkDialog's action widgets

This commit is contained in:
Gleb Smirnov 2022-02-18 19:03:41 +03:00
parent cd12c94423
commit 736681a841
No known key found for this signature in database
GPG key ID: 559DB6D1D625EFAB
3 changed files with 175 additions and 0 deletions

View file

@ -18,7 +18,10 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from functools import cache
from .gobject_object import Object
from .gtk_dialog import ResponseId
from .common import *
@ -28,11 +31,26 @@ class Child(AstNode):
"[",
Optional(["internal-child", UseLiteral("internal_child", True)]),
UseIdent("child_type").expected("a child type"),
Optional(ResponseId),
"]",
]),
Object,
]
@property
@cache
def response_id(self) -> T.Optional[ResponseId]:
"""Get action widget's response ID.
If child is not action widget, returns `None`.
"""
response_ids = self.children[ResponseId]
if response_ids:
return response_ids[0]
else:
return None
def emit_xml(self, xml: XmlEmitter):
child_type = internal_child = None
if self.tokens["internal_child"]: