"Correct" way to reset Style / CssProvider to default style/theme in GTKMM4

18 Views Asked by At

I'm trying to allow for dynamic style switching in an application and I want to allow for the default "light" and default "dark" styles. I'm currently using a CssProvider, which offers the load_named method which takes a "name" and "variant" string, and seems to be what I should use to achieve this. I have found that, given a CssProvider, I seem to be able to set the default "light" and "dark" themes as follows:

// Initialize provider
Glib::RefPtr<Gtk::CssProvider> provider;
provider = Gtk::CssProvider::create();

// Set to default "light" theme
provider->load_named("", "");

// Set to default "dark" theme
provider->load_named("", "dark");

The thing is I'm not sure if this is actually the proper way to do this or if this is just a hack that I've stumbled upon that's exploiting a fallback. For instance, is there a standard string that I should pass to "name" rather than an empty string, like "default" or "system"?

It also occurs to me that I don't know if there is a standard naming/variant tagging system at all. For example, is it the case that default theme could be different on different distributions; such that a default that's being fallen back to with the variant set to "" may actually be dark? Or, could the default variant naming for the dark version may not actually be "dark"?

0

There are 0 best solutions below