mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-06-21 23:19:24 -04:00
Allow inline menus
Newer versions of GTK allow menus to be specified inline in properties.
This commit is contained in:
parent
4d42bd68c1
commit
71dcc02198
10 changed files with 34 additions and 9 deletions
|
@ -21,12 +21,15 @@
|
|||
from .binding import Binding
|
||||
from .common import *
|
||||
from .contexts import ValueTypeCtx
|
||||
from .gtk_menu import menu
|
||||
from .values import ArrayValue, ExprValue, ObjectValue, Value
|
||||
|
||||
|
||||
class Property(AstNode):
|
||||
grammar = Statement(
|
||||
UseIdent("name"), ":", AnyOf(Binding, ExprValue, ObjectValue, Value, ArrayValue)
|
||||
UseIdent("name"),
|
||||
":",
|
||||
AnyOf(Binding, ExprValue, menu, ObjectValue, Value, ArrayValue),
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -60,11 +60,6 @@ class Menu(AstNode):
|
|||
def items(self) -> T.List[T.Union["Menu", "MenuAttribute"]]:
|
||||
return self.children
|
||||
|
||||
@validate("menu")
|
||||
def has_id(self):
|
||||
if self.tokens["tag"] == "menu" and self.tokens["id"] is None:
|
||||
raise CompileError("Menu requires an ID")
|
||||
|
||||
@validate("id")
|
||||
def object_id_not_reserved(self):
|
||||
if self.id in RESERVED_IDS:
|
||||
|
|
|
@ -139,6 +139,11 @@ class XmlOutput(OutputFormat):
|
|||
self._emit_expression(value.expression, xml)
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(value, Menu):
|
||||
xml.start_tag("property", **props)
|
||||
self._emit_menu(value, xml)
|
||||
xml.end_tag()
|
||||
|
||||
elif isinstance(value, ObjectValue):
|
||||
xml.start_tag("property", **props)
|
||||
self._emit_object(value.object, xml)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue