gtk4-rs
gtk4-rs copied to clipboard
No GSettings schemas are installed on the system
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?
How did you install GTK?
I cloned the GTK git repo, configured, built and installed it with meson, to the prefix C:\gnome.
Does the new book chapter helps? https://gtk-rs.org/gtk4-rs/git/book/installation_windows.html
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.
You can probably tweak that with some env variable no?
I have no idea 😛
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?
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.
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.
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.
Closing as this is not related to the bindings per see