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) 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/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: 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/docs/setup.rst b/docs/setup.rst index 914c753..e3c5dbe 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -48,12 +48,19 @@ blueprint-compiler works as a meson subproject. .. code-block:: meson.build + blps = [ + # LIST YOUR BLUEPRINT FILES HERE + ] + + uis = [] + foreach blp : blps + uis += blp.replace('.blp', '.ui') + endforeach + blueprints = custom_target('blueprints', - input: files( - # LIST YOUR BLUEPRINT FILES HERE - ), - output: '.', - command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], + input: blps, + output: uis, + command: [find_program('blueprint-compiler'), 'batch-compile', '@OUTDIR@', '@CURRENT_SOURCE_DIR@', '@INPUT@'], ) #. In the same ``meson.build`` file, add this argument to your ``gnome.compile_resources`` command: diff --git a/meson.build b/meson.build index f298d15..635fac5 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('blueprint-compiler', - version: '0.16.0', + version: '0.17.0', ) prefix = get_option('prefix') 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 @@ + + + + + +