Compare commits

...

3 commits

Author SHA1 Message Date
Giovanni Santini
79e1ce4541 Merge branch 'main' into 'main'
fix: Make `command` required

Closes #122

See merge request GNOME/blueprint-compiler!135
2025-06-07 02:25:52 +00:00
James Westman
5c7fb03da7 Fix incorrect error with Adw.AlertDialog responses 2025-05-07 17:08:26 -05:00
Giovanni Santini
c683254761 fix: Make command required
This solves a weird issue where the help function is executed everytime
even when we specify a command.

Fixes #122.
2023-08-01 11:55:33 +02:00
4 changed files with 34 additions and 6 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

@ -39,8 +39,7 @@ LIBDIR = None
class BlueprintApp:
def main(self):
self.parser = argparse.ArgumentParser()
self.subparsers = self.parser.add_subparsers(metavar="command")
self.parser.set_defaults(func=self.cmd_help)
self.subparsers = self.parser.add_subparsers(metavar="command", required=True)
compile = self.add_subcommand(
"compile", "Compile blueprint files", self.cmd_compile

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>