Don't use old syntax in docs

This commit is contained in:
Olivier Goffart 2023-04-06 16:58:07 +02:00
parent 4bc741a04c
commit fd3f974d7e
8 changed files with 23 additions and 23 deletions

View file

@ -115,7 +115,7 @@ similar to API that's created for your `.slint` component.
For example the following `.slint` markup defines a global `Logic` singleton that's also exported:
```slint,ignore
export global Logic := {
export global Logic {
callback to_uppercase(string) -> string;
}
```

View file

@ -31,7 +31,7 @@ code.
For example, this `struct` in a `.slint` file
```slint,ignore
export struct MyStruct := {
export struct MyStruct {
foo: int,
bar: string,
}

View file

@ -729,8 +729,8 @@ public:
///
/// Example: imagine the .slint file contains the given global:
/// ```slint,no-preview
/// export global Logic := {
/// callback to_uppercase(string) -> string;
/// export global Logic {
/// pure callback to_uppercase(string) -> string;
/// }
/// ```
/// Then you can set the callback handler

View file

@ -114,7 +114,7 @@ as a struct with the same name as the component.
For example, if you have
```slint,no-preview
export MyComponent := Window { /*...*/ }
export component MyComponent inherits Window { /*...*/ }
```
in the .slint file, it will create a
@ -189,7 +189,7 @@ The follow table summarizes the entire mapping:
For user defined structures in the .slint, an extra struct is generated.
For example, if the `.slint` contains
```slint,ignore
export struct MyStruct := {
export struct MyStruct {
foo: int,
bar: string,
}

View file

@ -443,8 +443,8 @@ In Rust you can set the callback like this:
slint::slint!{
import { HorizontalBox, VerticalBox, LineEdit } from "std-widgets.slint";
export global Logic := {
callback to-upper-case(string) -> string;
export global Logic {
pure callback to-upper-case(string) -> string;
// You can collect other global properties here
}
@ -546,9 +546,9 @@ This example uses [gettext-rs](https://docs.rs/gettext-rs):
slint::slint!{
import { HorizontalBox , Button } from "std-widgets.slint";
export global Tr := {
export global Tr {
// Do the translation of the first argument, with an array of string as supstitution
callback gettext(string, [string]) -> string;
pure callback gettext(string, [string]) -> string;
}
Example := Window {

View file

@ -1,6 +1,6 @@
# Global Singletons
Declare a global singleton with `global Name := { /* .. properties or callbacks .. */ }` to
Declare a global singleton with `global Name { /* .. properties or callbacks .. */ }` to
make properties and callbacks available throughout the entire project. Access them using `Name.property`.
For example, this can be useful for a common color palette:
@ -35,12 +35,12 @@ export global Logic {
```rust
slint::slint!{
export global Logic := {
property <int> the-value;
callback magic-operation(int) -> int;
export global Logic {
in-out property <int> the-value;
pure callback magic-operation(int) -> int;
}
export App := Window {
export component App inherits Window {
// ...
}
}

View file

@ -492,12 +492,12 @@ pub use crate::SharedString;
/// ```rust
/// # i_slint_backend_testing::init();
/// slint::slint!{
/// export global Palette := {
/// property<color> foreground-color;
/// property<color> background-color;
/// export global Palette {
/// in property<color> foreground-color;
/// in property<color> background-color;
/// }
///
/// export App := Window {
/// export component App inherits Window {
/// background: Palette.background-color;
/// Text {
/// text: "Hello";
@ -647,7 +647,7 @@ mod weak_handle {
/// # Example
/// ```rust
/// # i_slint_backend_testing::init();
/// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
/// slint::slint! { export component MyApp inherits Window { in property <int> foo; /* ... */ } }
/// let handle = MyApp::new().unwrap();
/// let handle_weak = handle.as_weak();
/// let thread = std::thread::spawn(move || {
@ -701,7 +701,7 @@ pub use weak_handle::*;
///
/// # Example
/// ```rust
/// slint::slint! { MyApp := Window { property <int> foo; /* ... */ } }
/// slint::slint! { export component MyApp inherits Window { in property <int> foo; /* ... */ } }
/// # i_slint_backend_testing::init();
/// let handle = MyApp::new().unwrap();
/// let handle_weak = handle.as_weak();

View file

@ -1390,7 +1390,7 @@ fn call_functions() {
let definition = spin_on::spin_on(
compiler.build_from_source(
r#"
export global Gl := {
export global Gl {
out property<string> q;
public function foo-bar(a-a: string, b-b:int) -> string {
q = a-a;
@ -1436,7 +1436,7 @@ fn component_definition_struct_properties() {
let comp_def = spin_on::spin_on(
compiler.build_from_source(
r#"
export struct Settings := {
export struct Settings {
string_value: string,
}
export Dummy := Rectangle {