Follow

So you think creating a @gnome application is necessarily done with C and you need to fight the compiler for hours before getting anything?

Quite the opposite! This thread shows you how to get started quickly to create a GNOME friendly GTK Rust app!
⬇️

I'm running a Fedora, because it's what I find to be as close to upstream as possible.

Fedora disables flathub, to ship its own flatpak repository.

Let's remove it, and configure back flathub and gnome-nightlies branches.

This allows us to download GNOME Builder, the go to IDE to create GNOME friendly apps.

Show thread

You can then install Builder by typing

flatpak install Builder

I personnally use the nightly version, to get the last features (things move fast in Rust tooling world), and install it user-wide: it would be odd for someone else on your computer to see a new app they never installed, wouldn't it?

Show thread

You can then create a Lab directory (or name it the way you want) to store the code of the application

Show thread

Go to @bilelmoussaoui's awesome Rust App Template application repository.

Click on the Clone blue button, which opens a popover. Then copy the HTTPS url (for the sake of simplicity)

gitlab.gnome.org/bilelmoussaou

Show thread

Open Builder, and click on the "Clone Repository" button at the bottom right

Show thread

Type in the directory name in which your project will be placed. Click on the "Clone Project" button on the bottom right

Show thread

Builder does the cloning magic (actually it just uses git), and opens the project view

Show thread

Click in the middle of the top bar, where "gtk-rust-template" should appear.

It will open a popover. Click on the arrow pointing upwards. If you leave your pointer on it, a tooltip should say "Update project dependencies"

Show thread

It will probably fail, because as good as Builder and Flatpaks are, they can't do everything quite yet (but people are working on it).

You can click on the terminal icon at the right of the popover (same height as "Build status: Failed")

Show thread

This will display the terminal at the bottom and tell us why it failed. Apparently, we don't have an extension thingy that Builder needs to compile our app

Show thread

Alright then, let's install it! We ask flatpak to do it for us:

flatpak install org.freedesktop.Sdk.Extension.rust-stable

It will ask whether to install it system-wide or user-wide. Same as previously, I like to install it user-wide

Show thread

It then asks which version it should install. It's simple: pick the latest (in my case 19.08)

Show thread

Let's update the dependencies again by clicking the very same arrow pointing upwards.

Now Builder should tell us the "Build is configured".

We can click on the "play" button to tell Builder we want to launch our app

Show thread

Some activity happens at the bottom of the screen. This is our app being compiled

Show thread

Tada 🎉🎉🎉

A simple window is launched, with the usual hamburger menu!

It doesn't do much yet, but at least we have built and launch our first app!

I'm going to create a thread in the coming days (hopefully) to show you how to create your actual project, and start adding fields and buttons to create a simple app

Show thread

@thibaultamartin Good toot guides! I am trying to develop a gtk vpn app which would use openvpn in the backend to connect but offers a gui to let users import multiple server configs. But I am having trouble with finding good documentation on how to execute openvpn with sudo permissions from gtk. I have found that I need to to use polkit but couldn't find much documentation about it. Do you have any pointers?

@thibaultamartin good guide :) it looks like rust's uptake by the gnome community is increasing. Some documentation for gnome libraries aren't quite there yet, but for small gnome applications, rust is fun to use.

@thibaultamartin Builder assumes a Projects directory by default so I’d recommend that instead of Lab.

@thibaultamartin Almost completed this!

bwrap: execvp gtk-rust-template: No such file or directory

@joshfowler Glad it could help you getting started! When does this happen?

@thibaultamartin It happens after a successful compile when I click on the run button.

@thibaultamartin Aha, may have found the culprit!

A Meson-based project is loaded but Ninja could not be found.

Sign in to participate in the conversation
La Quadrature du Net - Mastodon - Media Fédéré

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!