mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
language: Remove inline menus
Inline menus didn't work anyway--menus have to be referenced by ID (though, curiously, you *can* put the <menu> within the <property> tag and immediately reference it--but that's a hack, and not what blueprint-compiler was doing).
This commit is contained in:
parent
f1c3413dc1
commit
447785ec8c
12 changed files with 11 additions and 28 deletions
|
@ -22,11 +22,6 @@ from .values import TypeValue, IdentValue, TranslatedStringValue, FlagsValue, Qu
|
|||
|
||||
from .common import *
|
||||
|
||||
OBJECT_HOOKS.children = [
|
||||
menu,
|
||||
Object,
|
||||
]
|
||||
|
||||
OBJECT_CONTENT_HOOKS.children = [
|
||||
Signal,
|
||||
Property,
|
||||
|
|
|
@ -30,6 +30,5 @@ from ..parse_tree import *
|
|||
from ..xml_emitter import XmlEmitter
|
||||
|
||||
|
||||
OBJECT_HOOKS = AnyOf()
|
||||
OBJECT_CONTENT_HOOKS = AnyOf()
|
||||
VALUE_HOOKS = AnyOf()
|
||||
|
|
|
@ -53,7 +53,7 @@ class Property(AstNode):
|
|||
UseIdent("name"),
|
||||
":",
|
||||
AnyOf(
|
||||
OBJECT_HOOKS,
|
||||
Object,
|
||||
VALUE_HOOKS,
|
||||
).expected("a value"),
|
||||
),
|
||||
|
|
|
@ -17,10 +17,10 @@
|
|||
#
|
||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
import typing as T
|
||||
|
||||
from .attributes import BaseAttribute
|
||||
from .gobject_object import Object, ObjectContent
|
||||
from .ui import UI
|
||||
from .common import *
|
||||
|
||||
|
||||
|
@ -128,7 +128,7 @@ menu_contents.children = [
|
|||
), "}"),
|
||||
]
|
||||
|
||||
menu = Group(
|
||||
menu: Group = Group(
|
||||
Menu,
|
||||
[
|
||||
"menu",
|
||||
|
@ -138,6 +138,7 @@ menu = Group(
|
|||
],
|
||||
)
|
||||
|
||||
from .ui import UI
|
||||
|
||||
@completer(
|
||||
applies_in=[UI],
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
from .. import gir
|
||||
from .imports import GtkDirective, Import
|
||||
from .gtkbuilder_template import Template
|
||||
from .gobject_object import Object
|
||||
from .gtk_menu import menu
|
||||
from .common import *
|
||||
|
||||
|
||||
|
@ -32,7 +34,8 @@ class UI(AstNode):
|
|||
ZeroOrMore(Import),
|
||||
Until(AnyOf(
|
||||
Template,
|
||||
OBJECT_HOOKS,
|
||||
menu,
|
||||
Object,
|
||||
), Eof()),
|
||||
]
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
from .errors import MultipleErrors, PrintableError
|
||||
from .parse_tree import *
|
||||
from .tokenizer import TokenType
|
||||
from .language import OBJECT_HOOKS, OBJECT_CONTENT_HOOKS, VALUE_HOOKS, Template, UI
|
||||
from .language import OBJECT_CONTENT_HOOKS, VALUE_HOOKS, Template, UI
|
||||
|
||||
|
||||
def parse(tokens) -> T.Tuple[UI, T.Optional[MultipleErrors], T.List[PrintableError]]:
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
using Gtk 4.0;
|
||||
|
||||
Button {
|
||||
label: menu {};
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
4,3,15,Cannot assign Gio.Menu to string
|
1
tests/sample_errors/inline_menu.err
Normal file
1
tests/sample_errors/inline_menu.err
Normal file
|
@ -0,0 +1 @@
|
|||
4,15,4,Namespace Gtk does not contain a type called menu
|
|
@ -1,9 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<requires lib="gtk" version="4.0"/>
|
||||
<object class="GtkMenuButton">
|
||||
<property name="menu-model">
|
||||
<menu id="primary_menu"></menu>
|
||||
</property>
|
||||
</object>
|
||||
</interface>
|
|
@ -140,7 +140,6 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample("file_filter")
|
||||
self.assert_sample("flags")
|
||||
self.assert_sample("id_prop")
|
||||
self.assert_sample("inline_menu")
|
||||
self.assert_sample("layout")
|
||||
self.assert_sample("menu")
|
||||
self.assert_sample("numbers")
|
||||
|
@ -167,7 +166,6 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample_error("a11y_prop_obj_dne")
|
||||
self.assert_sample_error("a11y_prop_type")
|
||||
self.assert_sample_error("abstract_class")
|
||||
self.assert_sample_error("assign_inline_menu")
|
||||
self.assert_sample_error("action_widget_float_response")
|
||||
self.assert_sample_error("action_widget_have_no_id")
|
||||
self.assert_sample_error("action_widget_multiple_default")
|
||||
|
@ -188,6 +186,7 @@ class TestSamples(unittest.TestCase):
|
|||
self.assert_sample_error("filters_in_non_file_filter")
|
||||
self.assert_sample_error("gtk_3")
|
||||
self.assert_sample_error("gtk_exact_version")
|
||||
self.assert_sample_error("inline_menu")
|
||||
self.assert_sample_error("invalid_bool")
|
||||
self.assert_sample_error("layout_in_non_widget")
|
||||
self.assert_sample_error("no_import_version")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue