diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 9909e344b8e7..f4eb9dae1fe7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -1,7 +1,7 @@ on: push: branches: - - "master" + - "main" paths: - ".github/workflows/CI.yml" - "examples/**" @@ -175,7 +175,7 @@ jobs: - uses: actions/checkout@v4 with: repository: gtk-rs/checker - ref: master + ref: main path: checker - working-directory: checker run: cargo build --release diff --git a/.github/workflows/book-deploy.yml b/.github/workflows/book-deploy.yml index 901613005c71..f1d41c596af3 100644 --- a/.github/workflows/book-deploy.yml +++ b/.github/workflows/book-deploy.yml @@ -3,7 +3,7 @@ name: book on: push: branches: - - "master" + - "main" paths: - "book/**" diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2f7d293b92fa..edc73919401c 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,7 +2,7 @@ name: docs on: push: - branches: [master] + branches: [main] paths: - ".github/workflows/docs.yml" - "gdk4/**" @@ -61,7 +61,7 @@ jobs: - run: python3 ./generator.py --embed-docs --yes ./ - run: echo "RELEASE=$(echo '${{ github.event.release.tag_name }}' | grep -Po '(\d+)\.(\d+)')" >> ${GITHUB_ENV} - run: echo "DEST=$(if [ "$GITHUB_EVENT_NAME" == "release" ]; then echo 'stable/${{ env.RELEASE }}'; else echo 'git'; fi)" >> ${GITHUB_ENV} - - run: echo "RUSTDOCFLAGS=$(eval python3 ./gir-rustdoc/gir-rustdoc.py --pages-url 'https://gtk-rs.org/gtk4-rs/' --default-branch 'master' pre-docs | xargs)" >> ${GITHUB_ENV} + - run: echo "RUSTDOCFLAGS=$(eval python3 ./gir-rustdoc/gir-rustdoc.py --pages-url 'https://gtk-rs.org/gtk4-rs/' --default-branch 'main' pre-docs | xargs)" >> ${GITHUB_ENV} env: RUSTDOCFLAGS: > --extern-html-root-url=wayland_client=https://smithay.github.io/wayland-rs/ @@ -107,7 +107,7 @@ jobs: sed -i 's|section-tree-widget.html|https://docs.gtk.org/gtk4/section-tree-widget.html|g' target/doc/gtk4/struct.TreeView.html - name: GTK Docs Images - if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'release' }} + if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' }} run: | git clone --depth=1 https://gitlab.gnome.org/GNOME/gtk --no-checkout ./gtk-src cd ./gtk-src @@ -116,16 +116,16 @@ jobs: git checkout main mv ./docs/reference/gtk/images/*.png ../target/doc/gtk4 - name: Grab gtk-rs LOGO - if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'release' }} + if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' }} run: | - wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/master/logo/gtk-rs-16.png -O ./target/doc/favicon-16x16.png - wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/master/logo/gtk-rs-32.png -O ./target/doc/favicon-32x32.png - wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/master/logo/gtk-rs-256.png -O ./target/doc/rust-logo.png - wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/master/logo/gtk-rs.svg -O ./target/doc/rust-logo.svg - wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/master/logo/gtk-rs.svg -O ./target/doc/favicon.svg + wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs-16.png -O ./target/doc/favicon-16x16.png + wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs-32.png -O ./target/doc/favicon-32x32.png + wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs-256.png -O ./target/doc/rust-logo.png + wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs.svg -O ./target/doc/rust-logo.svg + wget https://raw.githubusercontent.com/gtk-rs/gtk-rs.github.io/main/logo/gtk-rs.svg -O ./target/doc/favicon.svg - name: deploy uses: peaceiris/actions-gh-pages@v4 - if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || github.event_name == 'release' }} + if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || github.event_name == 'release' }} with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./target/doc/ @@ -135,7 +135,7 @@ jobs: - run: python3 ./gir-rustdoc/gir-rustdoc.py --project-title 'GTK 4 Rust bindings' html-index --early-section 'Book' '
' - name: deploy index page uses: peaceiris/actions-gh-pages@v4 - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./public/ diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml index 3924d4284cde..d7a717c3725e 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/image.yml @@ -6,7 +6,7 @@ on: - cron: "0 1 * * 1" push: branches: - - "master" + - "main" paths: - "Dockerfile" - ".github/workflows/image.yml" @@ -41,8 +41,8 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | - # set latest tag for master branch - type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'master') }} + # set latest tag for main branch + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - name: Build and push Docker image uses: docker/build-push-action@1a162644f9a7e87d8f4b053101d1d9a712edc18c diff --git a/.github/workflows/listings.yml b/.github/workflows/listings.yml index d927fb232edf..ac8897e62785 100644 --- a/.github/workflows/listings.yml +++ b/.github/workflows/listings.yml @@ -6,7 +6,7 @@ on: - "book/listings/**" push: branches: - - "master" + - "main" paths: - "book/listings/**" release: diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 8f159ac9d402..47e0b03ee6d6 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -2,7 +2,7 @@ name: macOS on: push: - branches: [master] + branches: [main] paths: - ".github/workflows/macos.yml" - "gdk4/**" diff --git a/.github/workflows/typos.yml b/.github/workflows/typos.yml index 74d258d93f7a..24309da9ec8e 100644 --- a/.github/workflows/typos.yml +++ b/.github/workflows/typos.yml @@ -3,7 +3,7 @@ on: pull_request: push: branches: - - "master" + - "main" jobs: typos: name: Spell Check with Typos diff --git a/.github/workflows/windows-msvc.yml b/.github/workflows/windows-msvc.yml index 0980e5523959..68092de43d74 100644 --- a/.github/workflows/windows-msvc.yml +++ b/.github/workflows/windows-msvc.yml @@ -2,7 +2,7 @@ name: Windows MSVC on: push: - branches: [master] + branches: [main] paths: - ".github/workflows/windows-msvc.yml" - "gdk4/**" diff --git a/README.md b/README.md index 3dc211f0acd8..ffac7bf2c5c3 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,11 @@ A group of crates that aims to provide complete [GTK](https://gtk.org/) 4 bindin The GTK 4 crates also depends on other libraries part of the platform like: -- [GLib](https://github.com/gtk-rs/gtk-rs-core/tree/master/glib) -- [Gio](https://github.com/gtk-rs/gtk-rs-core/tree/master/gio) -- [Graphene](https://github.com/gtk-rs/gtk-rs-core/tree/master/graphene) -- [Cairo](https://github.com/gtk-rs/gtk-rs-core/tree/master/cairo) -- [Pango](https://github.com/gtk-rs/gtk-rs-core/tree/master/pango) +- [GLib](https://github.com/gtk-rs/gtk-rs-core/tree/main/glib) +- [Gio](https://github.com/gtk-rs/gtk-rs-core/tree/main/gio) +- [Graphene](https://github.com/gtk-rs/gtk-rs-core/tree/main/graphene) +- [Cairo](https://github.com/gtk-rs/gtk-rs-core/tree/main/cairo) +- [Pango](https://github.com/gtk-rs/gtk-rs-core/tree/main/pango) Those are common with the GTK 3 and GStreamer bindings and are part of the [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core) repository. @@ -27,7 +27,7 @@ Currently, the minimum supported Rust version is `1.70`. ## Documentation -- [Examples](https://github.com/gtk-rs/gtk4-rs/tree/master/examples) +- [Examples](https://github.com/gtk-rs/gtk4-rs/tree/main/examples) - Book [Stable](https://gtk-rs.org/gtk4-rs/stable/latest/book/) - The Rust API [Stable](https://gtk-rs.org/gtk4-rs/stable/latest/docs/) / [Development](https://gtk-rs.org/gtk4-rs/git/docs/) @@ -75,7 +75,7 @@ The bindings are composed of two parts: - Automatically generated ones using [gir] - Manual parts -The automatic ones can be generated using the [`generator.py`](https://github.com/gtk-rs/gir/blob/master/generator.py) script +The automatic ones can be generated using the [`generator.py`](https://github.com/gtk-rs/gir/blob/main/generator.py) script ```bash python3 ./generator.py diff --git a/book/book.toml b/book/book.toml index d0d5d8707b4c..615b809ccb59 100644 --- a/book/book.toml +++ b/book/book.toml @@ -8,7 +8,7 @@ title = "GUI development with Rust and GTK 4" [output.html] default-theme = "Rust" -git-repository-url = "https://github.com/gtk-rs/gtk4-rs/tree/master/book" +git-repository-url = "https://github.com/gtk-rs/gtk4-rs/tree/main/book" git-repository-icon = "fa-github" additional-css = ["theme/style.css"] playground.runnable = false diff --git a/book/src/actions.md b/book/src/actions.md index 194630c8aaf4..332d4743b382 100644 --- a/book/src/actions.md +++ b/book/src/actions.md @@ -7,7 +7,7 @@ Now, we will complete our set by learning about actions. An action is a piece of functionality bound to a certain GObject. Let's check out the simplest case where we activate an action without a parameter. -Filename: listings/actions/1/main.rs +Filename: listings/actions/1/main.rs ```rust,no_run {{#rustdoc_include ../listings/actions/1/main.rs:build_ui}} @@ -17,7 +17,7 @@ First, we created a new [`gio::ActionEntry`](https://gtk-rs.org/gtk-rs-core/stab We also connected a callback which closes the window when the action is activated. Finally, we add the action entry to the window via [`add_action_entries`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/prelude/trait.ActionMapExtManual.html#method.add_action_entries). -Filename: listings/actions/1/main.rs +Filename: listings/actions/1/main.rs ```rust,no_run {{#rustdoc_include ../listings/actions/1/main.rs:main}} @@ -39,7 +39,7 @@ Let's add our action to the action group "custom-group" and add the group then t The action entry isn't specific to our window anymore, the first parameter of the "activate" callback is of type `SimpleActionGroup` instead of `ApplicationWindow`. This means we have to clone `window` into the closure. -Filename: listings/actions/2/main.rs +Filename: listings/actions/2/main.rs ```rust {{#rustdoc_include ../listings/actions/2/main.rs:build_ui}} @@ -47,7 +47,7 @@ Filename: listings/actions/2/main.rs +Filename: listings/actions/2/main.rs ```rust {{#rustdoc_include ../listings/actions/2/main.rs:accel}} @@ -67,7 +67,7 @@ An action, like most functions, can take a parameter. However, unlike most functions it can also be stateful. Let's see how this works. -Filename: listings/actions/3/main.rs +Filename: listings/actions/3/main.rs ```rust {{#rustdoc_include ../listings/actions/3/main.rs:build_ui}} @@ -93,7 +93,7 @@ This way, the action can be specified by setting the "action-name" property. If the action accepts a parameter, it can be set via the "action-target" property. With [`ButtonBuilder`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/builders/struct.ButtonBuilder.html), we can set everything up by calling its methods. -Filename: listings/actions/4/main.rs +Filename: listings/actions/4/main.rs ```rust {{#rustdoc_include ../listings/actions/4/main.rs:button_builder}} @@ -103,7 +103,7 @@ Actionable widgets are also easily accessible through the interface builder. As usual, we build up the window via a composite template. Within the template we can then set the "action-name" and "action-target" properties. -Filename: listings/actions/5/resources/window.ui +Filename: listings/actions/5/resources/window.ui ```xml {{#rustdoc_include ../listings/actions/5/resources/window.ui}} @@ -111,7 +111,7 @@ Filename: listings/actions/5/window/mod.rs +Filename: listings/actions/5/window/mod.rs ```rust {{#rustdoc_include ../listings/actions/5/window/mod.rs:impl_window}} @@ -119,7 +119,7 @@ Filename: listings/actions/5/window/imp.rs +Filename: listings/actions/5/window/imp.rs ```rust {{#rustdoc_include ../listings/actions/5/window/imp.rs:object_impl}} @@ -145,7 +145,7 @@ With the action "button-frame", we manipulate the "has-frame" property of `butto Here, the convention is that actions with no parameter and boolean state should behave like toggle actions. This means that the caller can expect the boolean state to toggle after activating the action. Luckily for us, that is the default behavior for [`gio::PropertyAction`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/struct.PropertyAction.html) with a boolean property. -Filename: listings/actions/6/window/mod.rs +Filename: listings/actions/6/window/mod.rs ```rust {{#rustdoc_include ../listings/actions/6/window/mod.rs:action_button_frame}} @@ -163,7 +163,7 @@ This action can be used to change the orientation of `gtk_box`. Here the convention is that the state should be set to the given parameter. We don't need the action state to implement orientation switching, however it is useful for making the menu display the current orientation. -Filename: listings/actions/6/window/mod.rs +Filename: listings/actions/6/window/mod.rs ```rust {{#rustdoc_include ../listings/actions/6/window/mod.rs:action_orientation}} @@ -172,7 +172,7 @@ Filename: listings/actions/6/resources/window.ui +Filename: listings/actions/6/resources/window.ui ```diff @@ -255,7 +255,7 @@ The menu entries nicely display the state of our stateful actions, but after the As usual, we solve this problem with [`gio::Settings`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/struct.Settings.html). First we create a schema with settings corresponding to the stateful actions we created before. -Filename: listings/actions/7/org.gtk_rs.Actions7.gschema.xml +Filename: listings/actions/7/org.gtk_rs.Actions7.gschema.xml ```xml {{#rustdoc_include ../listings/actions/7/org.gtk_rs.Actions7.gschema.xml}} @@ -265,7 +265,7 @@ Again, we install the schema as described in the settings [chapter](./settings.h Then we add the settings to `imp::Window`. Since [`gio::Settings`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/struct.Settings.html) does not implement `Default`, we wrap it in a [`std::cell::OnceCell`](https://doc.rust-lang.org/std/cell/struct.OnceCell.html). -Filename: listings/actions/7/window/imp.rs +Filename: listings/actions/7/window/imp.rs ```rust {{#rustdoc_include ../listings/actions/7/window/imp.rs:imp_struct}} @@ -273,7 +273,7 @@ Filename: listings/actions/7/window/mod.rs +Filename: listings/actions/7/window/mod.rs ```rust {{#rustdoc_include ../listings/actions/7/window/mod.rs:settings}} @@ -283,7 +283,7 @@ Filename: listings/actions/7/window/mod.rs +Filename: listings/actions/7/window/mod.rs ```rust {{#rustdoc_include ../listings/actions/7/window/mod.rs:settings_create_actions}} @@ -295,7 +295,7 @@ The action "win.button-frame" toggles its state with each activation and the sta We still have to specify what should happen when the actions are activated though. For the stateful actions, instead of adding callbacks to their "activate" signals, we bind the settings to properties we want to manipulate. -Filename: listings/actions/7/window/mod.rs +Filename: listings/actions/7/window/mod.rs ```rust {{#rustdoc_include ../listings/actions/7/window/mod.rs:bind_settings}} @@ -303,7 +303,7 @@ Filename: listings/actions/7/window/imp.rs +Filename: listings/actions/7/window/imp.rs ```rust {{#rustdoc_include ../listings/actions/7/window/imp.rs:object_impl}} diff --git a/book/src/composite_templates.md b/book/src/composite_templates.md index 5c743fc608ce..3e26d9d51c55 100644 --- a/book/src/composite_templates.md +++ b/book/src/composite_templates.md @@ -3,7 +3,7 @@ Until now, whenever we constructed pre-defined widgets we relied on the [builder pattern](https://rust-unofficial.github.io/patterns/patterns/creational/builder.html). As a reminder, that is how we used it to build our trusty "Hello World!" app. -Filename: listings/hello_world/3/main.rs +Filename: listings/hello_world/3/main.rs ```rust {{#rustdoc_include ../listings/hello_world/3/main.rs:all}} ``` @@ -19,7 +19,7 @@ Creating widgets directly from code is fine, but it makes it harder to separate This is why most toolkits allow to describe the user interface with a markup language and GTK is no exception here. For example the following `xml` file describes the window widget of the "Hello World!" app. -Filename: listings/composite_templates/1/resources/window.ui +Filename: listings/composite_templates/1/resources/window.ui ```xml {{#rustdoc_include ../listings/composite_templates/1/resources/window.ui}} ``` @@ -39,7 +39,7 @@ In order to embed the template file into our application we take advantage of [` The files to embed are again described by an `xml` file. For our template file we also add the `compressed` and `preprocess` attribute in order to reduce the final size of the resources. -Filename: listings/composite_templates/1/resources/resources.gresource.xml +Filename: listings/composite_templates/1/resources/resources.gresource.xml ```xml {{#rustdoc_include ../listings/composite_templates/1/resources/resources.gresource.xml}} ``` @@ -56,7 +56,7 @@ cargo add glib-build-tools --build Then, we create a `build.rs` at the root of our package with the following content. This will compile the resources whenever we trigger a build with cargo and then statically link our executable to them. -Filename: listings/build.rs +Filename: listings/build.rs ```rust fn main() { glib_build_tools::compile_resources( @@ -70,13 +70,13 @@ fn main() { Finally, we register and include the resources by calling the macro [`gio::resources_register_include!`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/macro.resources_register_include.html). In your own apps take care to register the resources before creating the `gtk::Application`. -Filename: listings/composite_templates/1/main.rs +Filename: listings/composite_templates/1/main.rs ```rust {{#rustdoc_include ../listings/composite_templates/1/main.rs}} ``` Within our code we create a custom widget inheriting from `gtk::ApplicationWindow` to make use of our template. -Filename: listings/composite_templates/1/window/mod.rs +Filename: listings/composite_templates/1/window/mod.rs ```rust {{#rustdoc_include ../listings/composite_templates/1/window/mod.rs}} ``` @@ -89,7 +89,7 @@ You use it by adding a struct member with the same name as one `id` attribute in [`TemplateChild`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/subclass/widget/struct.TemplateChild.html) then stores a reference to the widget for later use. This will be useful later, when we want to add a callback to our button. -Filename: listings/composite_templates/1/window/imp.rs +Filename: listings/composite_templates/1/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/1/window/imp.rs:object}} ``` @@ -97,7 +97,7 @@ Filename: listings/composite_templates/1/window/imp.rs +Filename: listings/composite_templates/1/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/1/window/imp.rs:subclass}} ``` @@ -105,7 +105,7 @@ Filename: listings/composite_templates/1/window/imp.rs +Filename: listings/composite_templates/1/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/1/window/imp.rs:object_impl}} ``` @@ -117,21 +117,21 @@ First we define `CustomButton` that inherits from `gtk::Button`. As usual, we define the implementation struct within `imp.rs`. Note the `NAME` we define here, we will need it later to refer to it in the template. -Filename: listings/composite_templates/2/custom_button/imp.rs +Filename: listings/composite_templates/2/custom_button/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/2/custom_button/imp.rs:imp}} ``` We also define the public struct in `mod.rs`. -Filename: listings/composite_templates/2/custom_button/mod.rs +Filename: listings/composite_templates/2/custom_button/mod.rs ```rust {{#rustdoc_include ../listings/composite_templates/2/custom_button/mod.rs:mod}} ``` Since we want to refer to a `CustomButton` now we also have to change the type of the template child to it. -Filename: listings/composite_templates/2/window/imp.rs +Filename: listings/composite_templates/2/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/2/window/imp.rs:object}} ``` @@ -139,7 +139,7 @@ Filename: listings/composite_templates/2/resources/window.ui +Filename: listings/composite_templates/2/resources/window.ui ```xml {{#rustdoc_include ../listings/composite_templates/2/resources/window.ui}} ``` @@ -149,7 +149,7 @@ Filename: listings/composite_templates/3/resources/window.ui +Filename: listings/composite_templates/3/resources/window.ui ```xml {{#rustdoc_include ../listings/composite_templates/3/resources/window.ui}} ``` @@ -161,7 +161,7 @@ It takes a function of type `Fn(&Self)`. `Self` refers to our button. This means that `handle_button_clicked` has a single parameter of type `&CustomButton`. -Filename: listings/composite_templates/3/window/imp.rs +Filename: listings/composite_templates/3/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/3/window/imp.rs:template_callbacks}} ``` @@ -169,7 +169,7 @@ Filename: listings/composite_templates/3/window/imp.rs +Filename: listings/composite_templates/3/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/3/window/imp.rs:subclass}} ``` @@ -177,14 +177,14 @@ Filename: listings/composite_templates/4/window/imp.rs +Filename: listings/composite_templates/4/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/4/window/imp.rs:object}} ``` In order to access the widget's state we have to add `swapped="true"` to the `signal` tag. -Filename: listings/composite_templates/4/resources/window.ui +Filename: listings/composite_templates/4/resources/window.ui ```xml {{#rustdoc_include ../listings/composite_templates/4/resources/window.ui}} ``` @@ -192,7 +192,7 @@ Filename: listings/composite_templates/4/window/imp.rs +Filename: listings/composite_templates/4/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/4/window/imp.rs:template_callbacks}} ``` @@ -202,7 +202,7 @@ Filename: listings/composite_templates/5/window/imp.rs +Filename: listings/composite_templates/5/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/5/window/imp.rs:object}} ``` @@ -219,7 +219,7 @@ Turns out adding a template child not only gives a convenient reference to a wid It also ensures that the widget type is registered. Luckily we can also do that by ourselves. -Filename: listings/composite_templates/6/window/imp.rs +Filename: listings/composite_templates/6/window/imp.rs ```rust {{#rustdoc_include ../listings/composite_templates/6/window/imp.rs:subclass}} ``` diff --git a/book/src/css.md b/book/src/css.md index 70809e914054..a07dbf5bb90a 100644 --- a/book/src/css.md +++ b/book/src/css.md @@ -11,7 +11,7 @@ Every type of widget has a corresponding CSS node. In the case of `gtk::Button`, this node is called `button`. Therefore, we create a `style.css` file with the following content: -Filename: listings/css/1/style.css +Filename: listings/css/1/style.css ```css {{#rustdoc_include ../listings/css/1/style.css}} @@ -20,7 +20,7 @@ Filename: listings/css/1/main.rs +Filename: listings/css/1/main.rs ```rust {{#rustdoc_include ../listings/css/1/main.rs:main}} @@ -51,7 +51,7 @@ A [`gtk::Button`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Butt That is why we create a new CSS rule which only applies to `button` nodes with the style class `text_button`. -Filename: listings/css/2/style.css +Filename: listings/css/2/style.css ```css {{#rustdoc_include ../listings/css/2/style.css}} @@ -69,7 +69,7 @@ For example if we have two buttons, but want only one of them to have magenta fo Relying on one of the style classes which GTK adds will not help since both will get the same ones. Which is why we add the style class `button-1` to the first one. -Filename: listings/css/3/main.rs +Filename: listings/css/3/main.rs ```rust {{#rustdoc_include ../listings/css/3/main.rs:buttons}} @@ -77,7 +77,7 @@ Filename: listings/css/3/style.css +Filename: listings/css/3/style.css ```css {{#rustdoc_include ../listings/css/3/style.css}} @@ -98,7 +98,7 @@ This way your intentions are more clear, compared to matching with style classes Again, we have two buttons but want to color only one of them magenta. We set the name of the first one with [`set_widget_name`](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/prelude/trait.WidgetExt.html#tymethod.set_widget_name). -Filename: listings/css/4/main.rs +Filename: listings/css/4/main.rs ```rust {{#rustdoc_include ../listings/css/4/main.rs:buttons}} @@ -107,7 +107,7 @@ Filename: listings/css/4/style.css +Filename: listings/css/4/style.css ```css {{#rustdoc_include ../listings/css/4/style.css}} @@ -125,7 +125,7 @@ For example, if you want to indicate that your button leads to a destructive or All you have to do is to add "destructive-action" or "suggested-action" style class to your button. Most widgets will document these rules in their documentation under [CSS nodes](https://gtk-rs.org/gtk4-rs/stable/latest/docs/gtk4/struct.Button.html#css-nodes). -Filename: listings/css/5/main.rs +Filename: listings/css/5/main.rs ```rust {{#rustdoc_include ../listings/css/5/main.rs:buttons}} @@ -140,7 +140,7 @@ Just add the `