diff --git a/blueprintcompiler/language/gobject_property.py b/blueprintcompiler/language/gobject_property.py index c782d2e..50a7512 100644 --- a/blueprintcompiler/language/gobject_property.py +++ b/blueprintcompiler/language/gobject_property.py @@ -21,15 +21,12 @@ 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, menu, ObjectValue, Value, ArrayValue), + UseIdent("name"), ":", AnyOf(Binding, ExprValue, ObjectValue, Value, ArrayValue) ) @property diff --git a/blueprintcompiler/language/gtk_menu.py b/blueprintcompiler/language/gtk_menu.py index bc38f37..c7ef5f2 100644 --- a/blueprintcompiler/language/gtk_menu.py +++ b/blueprintcompiler/language/gtk_menu.py @@ -60,6 +60,11 @@ 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 cb18a3a..27bd38a 100644 --- a/blueprintcompiler/outputs/xml/__init__.py +++ b/blueprintcompiler/outputs/xml/__init__.py @@ -139,11 +139,6 @@ 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 a160191..b186c45 100644 --- a/docs/reference/extensions.rst +++ b/docs/reference/extensions.rst @@ -16,8 +16,8 @@ Properties are the main way to set values on objects, but they are limited by th Extension = :ref:`ExtAccessibility` | :ref:`ExtAdwAlertDialog` - | :ref:`ExtAdwBreakpoint` | :ref:`ExtAdwMessageDialog` + | :ref:`ExtAdwBreakpoint` | :ref:`ExtComboBoxItems` | :ref:`ExtFileFilterMimeTypes` | :ref:`ExtFileFilterPatterns` @@ -25,7 +25,6 @@ Properties are the main way to set values on objects, but they are limited by th | :ref:`ExtLayout` | :ref:`ExtLevelBarOffsets` | :ref:`ExtListItemFactory` - | :ref:`ExtScaleMarks` | :ref:`ExtSizeGroupWidgets` | :ref:`ExtStringListStrings` | :ref:`ExtStyles` @@ -49,6 +48,25 @@ 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: @@ -79,26 +97,6 @@ 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 @@ -290,16 +288,6 @@ 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 d759abe..6f76da6 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:`Menu` | :ref:`ObjectValue` | :ref:`Value` ) ';' + Property = `> ':' ( :ref:`Binding` | :ref:`ExprValue` | :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/meson.build b/meson.build index 635fac5..f298d15 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('blueprint-compiler', - version: '0.17.0', + version: '0.16.0', ) prefix = get_option('prefix') diff --git a/tests/samples/inline_menu.blp b/tests/sample_errors/inline_menu.blp similarity index 100% rename from tests/samples/inline_menu.blp rename to tests/sample_errors/inline_menu.blp diff --git a/tests/sample_errors/inline_menu.err b/tests/sample_errors/inline_menu.err new file mode 100644 index 0000000..3115750 --- /dev/null +++ b/tests/sample_errors/inline_menu.err @@ -0,0 +1 @@ +4,15,4,Namespace Gtk does not contain a type called menu \ No newline at end of file diff --git a/tests/samples/menu_no_id.blp b/tests/sample_errors/menu_no_id.blp similarity index 100% rename from tests/samples/menu_no_id.blp rename to tests/sample_errors/menu_no_id.blp diff --git a/tests/sample_errors/menu_no_id.err b/tests/sample_errors/menu_no_id.err new file mode 100644 index 0000000..e97f033 --- /dev/null +++ b/tests/sample_errors/menu_no_id.err @@ -0,0 +1 @@ +3,1,4,Menu requires an ID \ No newline at end of file diff --git a/tests/samples/inline_menu.ui b/tests/samples/inline_menu.ui deleted file mode 100644 index 2910b14..0000000 --- a/tests/samples/inline_menu.ui +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - diff --git a/tests/samples/menu_no_id.ui b/tests/samples/menu_no_id.ui deleted file mode 100644 index 934f6da..0000000 --- a/tests/samples/menu_no_id.ui +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -