Fix incorrect error with Adw.AlertDialog responses

This commit is contained in:
James Westman 2025-05-07 17:08:26 -05:00
parent 2e42dc6848
commit 5c7fb03da7
3 changed files with 33 additions and 4 deletions

View file

@ -60,19 +60,21 @@ class ScopeCtx:
passed = {}
for obj in self._iter_recursive(self.node):
if obj.tokens["id"] is None:
from .gtk_menu import Menu
if not (isinstance(obj, Object) or isinstance(obj, Menu)) or obj.id is None:
continue
if obj.tokens["id"] in passed:
if obj.id in passed:
token = obj.group.tokens["id"]
if not isinstance(obj, Template) and not isinstance(
obj, ExtListItemFactory
):
raise CompileError(
f"Duplicate object ID '{obj.tokens['id']}'",
f"Duplicate object ID '{obj.id}'",
token.range,
)
passed[obj.tokens["id"]] = obj
passed[obj.id] = obj
def _iter_recursive(self, node: AstNode):
yield node

View file

@ -0,0 +1,11 @@
using Gtk 4.0;
using Adw 1;
Adw.AlertDialog dialog1 {
responses [
ok: "Ok",
cancel: "Cancel",
]
}
Button cancel {}

View file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
DO NOT EDIT!
This file was @generated by blueprint-compiler. Instead, edit the
corresponding .blp file and regenerate this file with blueprint-compiler.
-->
<interface>
<requires lib="gtk" version="4.0"/>
<object class="AdwAlertDialog" id="dialog1">
<responses>
<response id="ok">Ok</response>
<response id="cancel">Cancel</response>
</responses>
</object>
<object class="GtkButton" id="cancel"></object>
</interface>