From eb16b364056e6d55bb1381ba8ce3510b4f1f389f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 4 Jun 2025 17:42:17 +0200 Subject: [PATCH 1/4] build: Make tests optional When used as a subproject, there is little point in adding tests to the parent project's test suite. Even if the tests caught an error, it wouldn't be in the position of fixing it. So add a build option that allows parent projects to turn off tests. --- meson.build | 4 +++- meson_options.txt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index f298d15..305601f 100644 --- a/meson.build +++ b/meson.build @@ -42,4 +42,6 @@ else install_subdir('blueprintcompiler', install_dir: py.get_install_dir()) endif -subdir('tests') +if get_option('tests') + subdir('tests') +endif diff --git a/meson_options.txt b/meson_options.txt index c3c5661..5154d24 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1 +1,2 @@ option('docs', type: 'boolean', value: false) +option('tests', type: 'boolean', value: true) From 71dcc02198f6e61e00d0bd9890bfd236e2bc0ae9 Mon Sep 17 00:00:00 2001 From: James Westman Date: Sat, 14 Jun 2025 10:27:45 -0500 Subject: [PATCH 2/4] Allow inline menus Newer versions of GTK allow menus to be specified inline in properties. --- blueprintcompiler/language/gobject_property.py | 5 ++++- blueprintcompiler/language/gtk_menu.py | 5 ----- blueprintcompiler/outputs/xml/__init__.py | 5 +++++ docs/reference/objects.rst | 2 +- tests/sample_errors/inline_menu.err | 1 - tests/sample_errors/menu_no_id.err | 1 - tests/{sample_errors => samples}/inline_menu.blp | 0 tests/samples/inline_menu.ui | 14 ++++++++++++++ tests/{sample_errors => samples}/menu_no_id.blp | 0 tests/samples/menu_no_id.ui | 10 ++++++++++ 10 files changed, 34 insertions(+), 9 deletions(-) delete mode 100644 tests/sample_errors/inline_menu.err delete mode 100644 tests/sample_errors/menu_no_id.err rename tests/{sample_errors => samples}/inline_menu.blp (100%) create mode 100644 tests/samples/inline_menu.ui rename tests/{sample_errors => samples}/menu_no_id.blp (100%) create mode 100644 tests/samples/menu_no_id.ui diff --git a/blueprintcompiler/language/gobject_property.py b/blueprintcompiler/language/gobject_property.py index 50a7512..c782d2e 100644 --- a/blueprintcompiler/language/gobject_property.py +++ b/blueprintcompiler/language/gobject_property.py @@ -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 diff --git a/blueprintcompiler/language/gtk_menu.py b/blueprintcompiler/language/gtk_menu.py index c7ef5f2..bc38f37 100644 --- a/blueprintcompiler/language/gtk_menu.py +++ b/blueprintcompiler/language/gtk_menu.py @@ -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: diff --git a/blueprintcompiler/outputs/xml/__init__.py b/blueprintcompiler/outputs/xml/__init__.py index 15850f7..32291ee 100644 --- a/blueprintcompiler/outputs/xml/__init__.py +++ b/blueprintcompiler/outputs/xml/__init__.py @@ -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) diff --git a/docs/reference/objects.rst b/docs/reference/objects.rst index 6f76da6..d759abe 100644 --- a/docs/reference/objects.rst +++ b/docs/reference/objects.rst @@ -58,7 +58,7 @@ Properties .. rst-class:: grammar-block - Property = `> ':' ( :ref:`Binding` | :ref:`ExprValue` | :ref:`ObjectValue` | :ref:`Value` ) ';' + Property = `> ':' ( :ref:`Binding` | :ref:`ExprValue` | :ref:`Menu` | :ref:`ObjectValue` | :ref:`Value` ) ';' Properties specify the details of each object, like a label's text, an image's icon name, or the margins on a container. diff --git a/tests/sample_errors/inline_menu.err b/tests/sample_errors/inline_menu.err deleted file mode 100644 index 3115750..0000000 --- a/tests/sample_errors/inline_menu.err +++ /dev/null @@ -1 +0,0 @@ -4,15,4,Namespace Gtk does not contain a type called menu \ No newline at end of file diff --git a/tests/sample_errors/menu_no_id.err b/tests/sample_errors/menu_no_id.err deleted file mode 100644 index e97f033..0000000 --- a/tests/sample_errors/menu_no_id.err +++ /dev/null @@ -1 +0,0 @@ -3,1,4,Menu requires an ID \ No newline at end of file diff --git a/tests/sample_errors/inline_menu.blp b/tests/samples/inline_menu.blp similarity index 100% rename from tests/sample_errors/inline_menu.blp rename to tests/samples/inline_menu.blp diff --git a/tests/samples/inline_menu.ui b/tests/samples/inline_menu.ui new file mode 100644 index 0000000..2910b14 --- /dev/null +++ b/tests/samples/inline_menu.ui @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/tests/sample_errors/menu_no_id.blp b/tests/samples/menu_no_id.blp similarity index 100% rename from tests/sample_errors/menu_no_id.blp rename to tests/samples/menu_no_id.blp diff --git a/tests/samples/menu_no_id.ui b/tests/samples/menu_no_id.ui new file mode 100644 index 0000000..934f6da --- /dev/null +++ b/tests/samples/menu_no_id.ui @@ -0,0 +1,10 @@ + + + + + + From 5a951696a73493c0ddb0430829acc9132c919ca6 Mon Sep 17 00:00:00 2001 From: Matthijs Velsink Date: Fri, 13 Jun 2025 01:51:05 +0200 Subject: [PATCH 3/4] docs: Small improvements for extensions - Add Gtk.Scale mark example - Add ExtScaleMarks to the index - Keep the index alphabetically sorted - Use the same order in the text --- docs/reference/extensions.rst | 52 +++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 20 deletions(-) diff --git a/docs/reference/extensions.rst b/docs/reference/extensions.rst index 2fd5dbb..3a9ad36 100644 --- a/docs/reference/extensions.rst +++ b/docs/reference/extensions.rst @@ -16,14 +16,15 @@ Properties are the main way to set values on objects, but they are limited by th Extension = :ref:`ExtAccessibility` | :ref:`ExtAdwAlertDialog` - | :ref:`ExtAdwMessageDialog` | :ref:`ExtAdwBreakpoint` + | :ref:`ExtAdwMessageDialog` | :ref:`ExtComboBoxItems` | :ref:`ExtFileFilterMimeTypes` | :ref:`ExtFileFilterPatterns` | :ref:`ExtFileFilterSuffixes` | :ref:`ExtLayout` | :ref:`ExtListItemFactory` + | :ref:`ExtScaleMarks` | :ref:`ExtSizeGroupWidgets` | :ref:`ExtStringListStrings` | :ref:`ExtStyles` @@ -47,25 +48,6 @@ The ``accessibility`` block defines values relevant to accessibility software. T Relations which allow for a list of values, for example `labelled-by`, must be given as a single relation with a list of values instead of duplicating the relation like done in Gtk.Builder. -.. _Syntax ExtAdwBreakpoint: - -Adw.Breakpoint --------------- - -.. rst-class:: grammar-block - - ExtAdwBreakpointCondition = 'condition' '(' `> ')' - ExtAdwBreakpoint = 'setters' '{' ExtAdwBreakpointSetter* '}' - ExtAdwBreakpointSetter = `> '.' `> ':' :ref:`Value ` ';' - -Valid in `Adw.Breakpoint `_. - -Defines the condition for a breakpoint and the properties that will be set at that breakpoint. See the documentation for `Adw.Breakpoint `_. - -.. note:: - - The `Adw.Breakpoint:condition `_ property has type `Adw.BreakpointCondition `_, which GtkBuilder doesn't know how to parse from a string. Therefore, the ``condition`` syntax is used instead. - .. _Syntax ExtAdwAlertDialog: @@ -96,6 +78,26 @@ The ``responses`` block defines the buttons that will be added to the dialog. Th } +.. _Syntax ExtAdwBreakpoint: + +Adw.Breakpoint +-------------- + +.. rst-class:: grammar-block + + ExtAdwBreakpointCondition = 'condition' '(' `> ')' + ExtAdwBreakpoint = 'setters' '{' ExtAdwBreakpointSetter* '}' + ExtAdwBreakpointSetter = `> '.' `> ':' :ref:`Value ` ';' + +Valid in `Adw.Breakpoint `_. + +Defines the condition for a breakpoint and the properties that will be set at that breakpoint. See the documentation for `Adw.Breakpoint `_. + +.. note:: + + The `Adw.Breakpoint:condition `_ property has type `Adw.BreakpointCondition `_, which GtkBuilder doesn't know how to parse from a string. Therefore, the ``condition`` syntax is used instead. + + .. _Syntax ExtAdwMessageDialog: Adw.MessageDialog Responses @@ -262,6 +264,16 @@ Valid in `Gtk.Scale `_. The ``marks`` block defines the marks on a scale. A single ``mark`` has up to three arguments: a value, an optional position, and an optional label. The position can be ``left``, ``right``, ``top``, or ``bottom``. The label may be translated. +.. code-block:: blueprint + + Scale { + marks [ + mark (-1, bottom), + mark (0, top, _("Origin")), + mark (2), + ] + } + .. _Syntax ExtSizeGroupWidgets: From 6e010148b2b340876a8d1ac456819d4232c0ef93 Mon Sep 17 00:00:00 2001 From: James Westman Date: Sat, 14 Jun 2025 15:11:39 -0500 Subject: [PATCH 4/4] Remove donate link from README --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 503d7a3..f01ecf9 100644 --- a/README.md +++ b/README.md @@ -82,10 +82,6 @@ Visual Studio Code - [Blueprint Language Plugin by bodil](https://github.com/bodil/vscode-blueprint) -## Donate - -You can support my work on GitHub Sponsors! - ## Getting in Touch Matrix room: [#blueprint-language:matrix.org](https://matrix.to/#/#blueprint-language:matrix.org)