get system theme

Since several xojo controls don’t theme-aware. How can we detect that the OS has dark or light theme?

I’m not a Linux person… but what do the values of TingeColor (and related variables) tell you (if anything)??

Unfortunately, it’s not so cut and dry as a theme can be all over the map as to color assignments. Additionally, themes change the definitions of colors depending on the desktop manager employed. I’ve been digging through this for quite some time and it’s just not going to be possible to get that level of control colors with Xojo in exchange for cross-platform capabilities.

The only cross-platform development frameworks that I’ve seen come close to properly solving this are Java/JavaFX and Angular 2/Electron.

Here’s the result.

So, I think we can use FillColor to determine the theme.

[quote=347871:@Tim Jones]Unfortunately, it’s not so cut and dry as a theme can be all over the map as to color assignments. Additionally, themes change the definitions of colors depending on the desktop manager employed. I’ve been digging through this for quite some time and it’s just not going to be possible to get that level of control colors with Xojo in exchange for cross-platform capabilities.

The only cross-platform development frameworks that I’ve seen come close to properly solving this are Java/JavaFX and Angular 2/Electron.[/quote]
Sorry, if my question is not clear enough. I just want to know that current used theme is dark or light?

I’ve been playing with Gtk2 API to get native color of a widget without creating the widget, but never come close. Something that easy to achieve on Windows OS but not on Linux. Probably, by using Gtk3 we can get native color of the widget. In Gtk2, we need to listen to realise event to get the widget color.

dim MyShell as new Shell
dim cmd as string
cmd = “gsettings get org.gnome.desktop.interface gtk-theme”
dim result as string

MyShell.Execute(cmd)
result = MyShell.Result

Result => ‘Adwaita’

Login to your linux system. Open a terminal and set another theme like this
gsettings set org.gnome.desktop.interface gtk-theme Adwaita-dark
run gsettings get org.gnome.desktop.interface gtk-theme
you get ‘Adwaita-dark’ as result.

[quote=347877:@Asis Patisahusiwa]
Sorry, if my question is not clear enough. I just want to know that current used theme is dark or light?[/quote]

[quote=347967:@Horst Jehle]
run gsettings get org.gnome.desktop.interface gtk-theme[/quote]
This is gnome-way to define DM theme. Not all distro support this. You will be amazed that on my machine, the command give Adwaita as a result, while I’m using Arc-Dark as default OS theme.

You can find the system default settings in /etc/gtk-3.0/settings.ini

cat /etc/gtk-3.0/settings.ini
[Settings]
gtk-theme-name = Ambiance
gtk-icon-theme-name = ubuntu-mono-dark
gtk-sound-theme-name = ubuntu
gtk-icon-sizes = panel-menu-bar=24,24

If the user has a different setting this command shows the theme (on ubuntu 14/16, RedHat Linux, CentOS and elementaryOS

gsettings get org.gnome.desktop.interface gtk-theme
‘Ambiance’

You can also use the “dconf” utility.

dconf read /org/gnome/desktop/interface/gtk-theme