Given an app I’m writing, I want to set the theme to the theme downloaded, like embedding it, without installing it in the system.
I’m currently using PyGTK3, and have plans to upgrade to PyGTK 4 someday.
Suppose I download a theme tar (or zip), like one of the variants here material-black COLORS Complete Desktop - pling.com. I created a assets/gtk/themes
folder and extracted the theme tar there.
$ ls assets/gtk/themes/Material-Black-Plum-BE
chrome cinnamon COPYING gnome-shell gtk-2.0 gtk-3.0 gtk-4.0 index.theme INSTALL_GDM_THEME.md metacity-1 plank unity xfwm4
I want to be able to set the global theme to one of the embedded themes at startup.
Suppose the GTK_THEME
environment variable is unset. If setting the variable overrides the one I set in the code, then it is ok, even desirable.
I tried using gtk_rc_set_default_files()
from this post, in Python, but It can’t find the theme.
Gtk.rc_add_default_file("/data/code/project/assets/gtk/")
settings = Gtk.Settings.get_default()
settings.set_property("gtk-theme-name", "Material-Black-Plum-BE")
I tried many variations of the path and I didn’t work (nor selecting by code like in this example, nor showing in Gtk Inspector".
Also, this method is deprecated, so even if it worked, I would have to change it later. But the principle of adding an extra folder to look for themes is exactly what I need.
So, how do you embed themes directly into the app?
Examples can be in C, as long it’s translatable into Python.