Skip to content

Commit

Permalink
Switch to main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
bilelmoussaoui committed Oct 31, 2024
1 parent 3156711 commit 9bd0836
Show file tree
Hide file tree
Showing 31 changed files with 232 additions and 232 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
on:
push:
branches:
- "master"
- "main"
paths:
- ".github/workflows/CI.yml"
- "examples/**"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/book-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: book
on:
push:
branches:
- "master"
- "main"
paths:
- "book/**"

Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: docs

on:
push:
branches: [master]
branches: [main]
paths:
- ".github/workflows/docs.yml"
- "gdk4/**"
Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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
Expand All @@ -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/
Expand All @@ -135,7 +135,7 @@ jobs:
- run: python3 ./gir-rustdoc/gir-rustdoc.py --project-title 'GTK 4 Rust bindings' html-index --early-section 'Book' '<ul><li><a href="stable/latest/book">Latest stable</a></li></ul>'
- 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/
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- cron: "0 1 * * 1"
push:
branches:
- "master"
- "main"
paths:
- "Dockerfile"
- ".github/workflows/image.yml"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/listings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- "book/listings/**"
push:
branches:
- "master"
- "main"
paths:
- "book/listings/**"
release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: macOS

on:
push:
branches: [master]
branches: [main]
paths:
- ".github/workflows/macos.yml"
- "gdk4/**"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
pull_request:
push:
branches:
- "master"
- "main"
jobs:
typos:
name: Spell Check with Typos
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows-msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Windows MSVC

on:
push:
branches: [master]
branches: [main]
paths:
- ".github/workflows/windows-msvc.yml"
- "gdk4/**"
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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/)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion book/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
36 changes: 18 additions & 18 deletions book/src/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/1/main.rs">listings/actions/1/main.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/1/main.rs">listings/actions/1/main.rs</a>

```rust,no_run
{{#rustdoc_include ../listings/actions/1/main.rs:build_ui}}
Expand All @@ -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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/1/main.rs">listings/actions/1/main.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/1/main.rs">listings/actions/1/main.rs</a>

```rust,no_run
{{#rustdoc_include ../listings/actions/1/main.rs:main}}
Expand All @@ -39,15 +39,15 @@ 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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/2/main.rs">listings/actions/2/main.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/2/main.rs">listings/actions/2/main.rs</a>

```rust
{{#rustdoc_include ../listings/actions/2/main.rs:build_ui}}
```

If we bind the accelerator to "custom-group.close", it works just as before.

Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/2/main.rs">listings/actions/2/main.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/2/main.rs">listings/actions/2/main.rs</a>

```rust
{{#rustdoc_include ../listings/actions/2/main.rs:accel}}
Expand All @@ -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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/3/main.rs">listings/actions/3/main.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/3/main.rs">listings/actions/3/main.rs</a>

```rust
{{#rustdoc_include ../listings/actions/3/main.rs:build_ui}}
Expand All @@ -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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/4/main.rs">listings/actions/4/main.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/4/main.rs">listings/actions/4/main.rs</a>

```rust
{{#rustdoc_include ../listings/actions/4/main.rs:button_builder}}
Expand All @@ -103,23 +103,23 @@ 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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/5/resources/window.ui">listings/actions/5/resources/window.ui</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/5/resources/window.ui">listings/actions/5/resources/window.ui</a>

```xml
{{#rustdoc_include ../listings/actions/5/resources/window.ui}}
```

We will connect the actions and add them to the window in the `Window::setup_actions` method.

Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/5/window/mod.rs">listings/actions/5/window/mod.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/5/window/mod.rs">listings/actions/5/window/mod.rs</a>

```rust
{{#rustdoc_include ../listings/actions/5/window/mod.rs:impl_window}}
```

Finally, `setup_actions` will be called within `constructed`.

Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/5/window/imp.rs">listings/actions/5/window/imp.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/5/window/imp.rs">listings/actions/5/window/imp.rs</a>

```rust
{{#rustdoc_include ../listings/actions/5/window/imp.rs:object_impl}}
Expand All @@ -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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/6/window/mod.rs">listings/actions/6/window/mod.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/6/window/mod.rs">listings/actions/6/window/mod.rs</a>

```rust
{{#rustdoc_include ../listings/actions/6/window/mod.rs:action_button_frame}}
Expand All @@ -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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/6/window/mod.rs">listings/actions/6/window/mod.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/6/window/mod.rs">listings/actions/6/window/mod.rs</a>

```rust
{{#rustdoc_include ../listings/actions/6/window/mod.rs:action_orientation}}
Expand All @@ -172,7 +172,7 @@ Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master
Even though [`gio::Menu`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/struct.Menu.html) can also be created with the bindings, the most convenient way is to use the interface builder for that.
We do that by adding the menu in front of the template.

Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/6/resources/window.ui">listings/actions/6/resources/window.ui</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/6/resources/window.ui">listings/actions/6/resources/window.ui</a>

```diff
<?xml version="1.0" encoding="UTF-8"?>
Expand Down Expand Up @@ -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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/7/org.gtk_rs.Actions7.gschema.xml">listings/actions/7/org.gtk_rs.Actions7.gschema.xml</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/7/org.gtk_rs.Actions7.gschema.xml">listings/actions/7/org.gtk_rs.Actions7.gschema.xml</a>

```xml
{{#rustdoc_include ../listings/actions/7/org.gtk_rs.Actions7.gschema.xml}}
Expand All @@ -265,15 +265,15 @@ 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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/7/window/imp.rs">listings/actions/7/window/imp.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/7/window/imp.rs">listings/actions/7/window/imp.rs</a>

```rust
{{#rustdoc_include ../listings/actions/7/window/imp.rs:imp_struct}}
```

Now we create functions to make it easier to access settings.

Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/7/window/mod.rs">listings/actions/7/window/mod.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/7/window/mod.rs">listings/actions/7/window/mod.rs</a>

```rust
{{#rustdoc_include ../listings/actions/7/window/mod.rs:settings}}
Expand All @@ -283,7 +283,7 @@ Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master
Creating stateful actions from setting entries is so common that `Settings` provides a method for that exact purpose.
We create actions with the[ `create_action`](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/prelude/trait.SettingsExt.html#tymethod.create_action) method and then add them to the action group of our window.

Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/7/window/mod.rs">listings/actions/7/window/mod.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/7/window/mod.rs">listings/actions/7/window/mod.rs</a>

```rust
{{#rustdoc_include ../listings/actions/7/window/mod.rs:settings_create_actions}}
Expand All @@ -295,15 +295,15 @@ 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: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/7/window/mod.rs">listings/actions/7/window/mod.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/7/window/mod.rs">listings/actions/7/window/mod.rs</a>

```rust
{{#rustdoc_include ../listings/actions/7/window/mod.rs:bind_settings}}
```

Finally, we make sure that `bind_settings` is called within `constructed`.

Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/master/book/listings/actions/7/window/imp.rs">listings/actions/7/window/imp.rs</a>
Filename: <a class=file-link href="https://github.com/gtk-rs/gtk4-rs/blob/main/book/listings/actions/7/window/imp.rs">listings/actions/7/window/imp.rs</a>

```rust
{{#rustdoc_include ../listings/actions/7/window/imp.rs:object_impl}}
Expand Down
Loading

0 comments on commit 9bd0836

Please sign in to comment.