mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
completions: Improve accessibility properties
This commit is contained in:
parent
bcb8e4ea14
commit
72583be267
3 changed files with 86 additions and 58 deletions
|
@ -25,7 +25,7 @@ from .gobject_object import ObjectContent, validate_parent_type
|
|||
from .values import Value
|
||||
|
||||
|
||||
def get_property_types(gir):
|
||||
def get_property_types(gir: gir.GirContext) -> T.Dict[str, T.Optional[GirType]]:
|
||||
# from <https://docs.gtk.org/gtk4/enum.AccessibleProperty.html>
|
||||
return {
|
||||
"autocomplete": gir.get_type("AccessibleAutocomplete", "Gtk"),
|
||||
|
@ -50,7 +50,7 @@ def get_property_types(gir):
|
|||
}
|
||||
|
||||
|
||||
def get_relation_types(gir):
|
||||
def get_relation_types(gir: gir.GirContext) -> T.Dict[str, T.Optional[GirType]]:
|
||||
# from <https://docs.gtk.org/gtk4/enum.AccessibleRelation.html>
|
||||
widget = gir.get_type("Widget", "Gtk")
|
||||
return {
|
||||
|
@ -75,7 +75,7 @@ def get_relation_types(gir):
|
|||
}
|
||||
|
||||
|
||||
def get_state_types(gir):
|
||||
def get_state_types(gir: gir.GirContext) -> T.Dict[str, T.Optional[GirType]]:
|
||||
# from <https://docs.gtk.org/gtk4/enum.AccessibleState.html>
|
||||
return {
|
||||
"busy": BoolType(),
|
||||
|
@ -89,6 +89,20 @@ def get_state_types(gir):
|
|||
}
|
||||
|
||||
|
||||
TRANSLATED = set(
|
||||
[
|
||||
"description",
|
||||
"help-text",
|
||||
"label",
|
||||
"placeholder",
|
||||
"role-description",
|
||||
"value-text",
|
||||
"col-index-text",
|
||||
"row-index-text",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def get_types(gir):
|
||||
return {
|
||||
**get_property_types(gir),
|
||||
|
@ -247,12 +261,14 @@ def a11y_completer(_ctx: CompletionContext):
|
|||
applies_in=[ExtAccessibility],
|
||||
matches=new_statement_patterns,
|
||||
)
|
||||
def a11y_name_completer(ctx: CompletionContext):
|
||||
def a11y_property_completer(ctx: CompletionContext):
|
||||
for name, type in get_types(ctx.ast_node.root.gir).items():
|
||||
yield Completion(
|
||||
yield get_property_completion(
|
||||
name,
|
||||
CompletionItemKind.Property,
|
||||
docs=_get_docs(ctx.ast_node.root.gir, type.name),
|
||||
type,
|
||||
ctx,
|
||||
name in TRANSLATED,
|
||||
_get_docs(ctx.ast_node.root.gir, name),
|
||||
)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue