mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
language: a11y: Fix property names
Blueprint uses underscores in property/state/relation names, but GtkBuilder expects dashes because it uses the glib names from the GtkAccessible* enums.
This commit is contained in:
parent
6576e02837
commit
31165b286a
5 changed files with 15 additions and 6 deletions
|
@ -121,6 +121,10 @@ class A11yProperty(BaseTypedAttribute):
|
|||
else:
|
||||
raise CompilerBugError()
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self.tokens["name"].replace("_", "-")
|
||||
|
||||
@property
|
||||
def value_type(self) -> GirType:
|
||||
return get_types(self.root.gir).get(self.tokens["name"])
|
||||
|
@ -181,12 +185,13 @@ def a11y_name_completer(ast_node, match_variables):
|
|||
|
||||
@decompiler("relation", cdata=True)
|
||||
def decompile_relation(ctx, gir, name, cdata):
|
||||
name = name.replace("-", "_")
|
||||
ctx.print_attribute(name, cdata, get_types(ctx.gir).get(name))
|
||||
|
||||
@decompiler("state", cdata=True)
|
||||
def decompile_state(ctx, gir, name, cdata, translatable="false"):
|
||||
if decompile.truthy(translatable):
|
||||
ctx.print(f"{name}: _(\"{_escape_quote(cdata)}\");")
|
||||
ctx.print(f"{name.replace('-', '_')}: _(\"{_escape_quote(cdata)}\");")
|
||||
else:
|
||||
ctx.print_attribute(name, cdata, get_types(ctx.gir).get(name))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue