How to set the default gsettings schema lookup location on Windows

Hi, I maintain a library so while what I am asking is most likely not necessary for app developers or users of GTK apps, it is for my specific application, which is a sandboxed language binding.

I have a gsettings schema located at path, how do I make such that when GTK loads, it will look at that path to load the settings.

Currently, starting GTK from the windows console, I get:

GLib-GIO-CRITICAL **: 19:51:09.259: g_settings_schema_source_lookup: assertion 'source != NULL' failed

And using things like ColorChooser or FileDialog will crash when attempting to read their settings. I am positive these settings are located at path, which contains

  • gschemas.compiled
  • org.gtk.gtk4.Settings.ColorChooser.gschema.xml
  • org.gtk.gtk4.Settings.FileChooser.gschema.xml
  • etc

How do I tell GTK4 where to find them programmatically, and to use path as the default location? Moving them to a global system location would be bad practice due to the sandboxed nature, they have to stay at path, specifically, and be loaded from there. If it is unavoidable, what would be that path on Windows? Afaik the docs only show the path for unix systems or MSYS, which is /usr/share/glib-2.0/schemas

I tried setting XDG_DATA_DIRS, but that seems to be ignored on Windows. I furthermore know about g_settings_schema_source_new_from_directory, which succeeds, but I am unsure of how to make the resulting GSettingsSchemaSource instance the source all GTK widgets will use on startup.

Thank you


There are those GSettingsSchema and GSettingsSchemaSource features, could they correspond to what you’re looking for?

1 Like

By default resources are looked relative to the exe location. If your exe is inside a bin directory, then GIO expects resources to be under ..\share\glib-2.0\schemas; otherwise it will look in a share directory in the same folder as the exe: share\glib-2.0\schemas

But you can set the GSETTINGS_SCHEMA_DIR environment variable for a custom path: Gio – 2.0: Overview

Let us know if you need something more specific :slight_smile:


Setting GSETTINGS_SCHEMA_DIR was exactly what I was looking for, thank you!

1 Like

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.