gtk4-rs icon indicating copy to clipboard operation
gtk4-rs copied to clipboard

No GSettings schemas are installed on the system

Open Diggsey opened this issue 4 years ago • 10 comments

When I run the text_viewer example, it works fine until I click the "open" button. When it tries to open the file fiewer, I get the above error.

If I copy text_viewer.exe into C:\gnome\bin (the place where gtk is installed) then it works fine, but if I try to do the reverse (copy C:\gnome\share\glib-2.0\schemas to the corresponding relative location for the rust binary, then I get the same error.

How am I supposed to distribute a GTK binary that uses a file viewer?

Diggsey avatar Oct 23 '21 17:10 Diggsey

How did you install GTK?

alatiera avatar Oct 25 '21 15:10 alatiera

I cloned the GTK git repo, configured, built and installed it with meson, to the prefix C:\gnome.

Diggsey avatar Oct 25 '21 15:10 Diggsey

Does the new book chapter helps? https://gtk-rs.org/gtk4-rs/git/book/installation_windows.html

bilelmoussaoui avatar Nov 11 '21 16:11 bilelmoussaoui

No, this is a runtime problem, not a compile-time problem. The program should not be looking for GTK schemas at some fixed path, because that path won't exist on the target machine.

Diggsey avatar Nov 11 '21 17:11 Diggsey

You can probably tweak that with some env variable no?

bilelmoussaoui avatar Nov 11 '21 17:11 bilelmoussaoui

I have no idea 😛

Diggsey avatar Nov 11 '21 19:11 Diggsey

See https://developer-old.gnome.org/gio/stable/glib-compile-schemas.html, seems like you can use XDG_DATA_DIRS env variable for that. Want to give it a try?

bilelmoussaoui avatar Nov 11 '21 19:11 bilelmoussaoui

I've used this with the schemas in the path share/glib-2.0/schemas relative to the executable, which seems to work. Similarly for some other required files.

I believe there's a script somewhere to bundle the necessary files for a gtk application on Windows, and a different one for macOS, but for the System76 Keyboard Configurator I ended up just writing my own scripts. (Though the scripts there aren't necessarily the best either.)

Packaging for Windows and macOS, though doable, is not a strength of gtk.

ids1024 avatar Nov 11 '21 19:11 ids1024

The premise that these schemas exist at all on the target machine is wrong, so either they should not be needed, or there should be instructions for how to bundle these schemas with your application.

edit: Just saw your response @ids1024, I'll try the share/glib-2.0/schema path.

Diggsey avatar Nov 11 '21 22:11 Diggsey

there should be instructions for how to bundle these schemas with your application.

It is documented, but not very well: https://www.gtk.org/docs/installations/windows#building-and-distributing-your-application

For macOS, there's gtk-mac-bundler to bundle all the necessary files for a Gtk application. Not sure if there's something like that for Windows.

I definitely agree and wish gtk could just statically link everything it needs into the binary to avoid bundling any files (and optimize out anything unused), but alas that's not how it works and I don't think that's changing any time soon.

ids1024 avatar Nov 11 '21 22:11 ids1024

Closing as this is not related to the bindings per see

bilelmoussaoui avatar Oct 08 '22 12:10 bilelmoussaoui