aperezdc / revolt

Better desktop integration for Riot.im (not only) for GNOME
GNU General Public License v3.0
92 stars 9 forks source link

Dark GTK+ theme is not used when running in the Flatpak sandbox #11

Open aperezdc opened 8 years ago

aperezdc commented 8 years ago

Despite having the magic incantation needed to choose the dark theme variant:

Gtk.Settings.get_default().set_property("gtk-application-prefer-dark-theme", True)

...when running inside the Flatpak sandbox, Adwaita non-dark is still the chosen theme.

clopez commented 8 years ago

You can use an environment variable for that:

export GTK_THEME=Adwaita:dark

You can set this environment variable on revolt itself before starting the main class.

aperezdc commented 8 years ago

@clopez: That's a hacky workaround. If the Flatpak runtime provided a different default theme, Revolt would still use Adwaita, instead of the dark variant of the current theme. Unfortunately, something like GTK_THEME=:dark or GTK_THEME=*:dark does not work :disappointed:

Builder can use the dark theme while in the Flatpak sandbox, so I am positive that this can be solved without using an environment variable inteded for debugging.

aperezdc commented 7 years ago

This is fixed as of 5f7d4657ddeec5d5906c6413e5534c866fefc6eb — the recent refactoring and reordering of initialization code made it work.

aperezdc commented 7 years ago

Reopening: when “Adwaita” (the default) is the theme chosen by the user, running inside the Flatpak does choose the dark variant, but when using any other theme (like Arc, which includes a dark variant), the dark variant is not chosen.

So, in order to reproduce this:

Of course the non-Adwaita theme is not chosen, because it's not available inside the sandbox: GTK+ picks the light variant of Adwaita, though I would expect that the dark Adwaita variant gets chosen.

mattiasb commented 7 years ago

I have a weird issue as well regarding this. I run stock Gnome (no theme fiddling) but Revolt starts with the dark variant for some reason.

aperezdc commented 7 years ago

@mattiasb: The dark theme is correctly picked when not using the Flatpak builds. Are you using Revolt by installing it in your distro directly, or via Flatpak?

mattiasb commented 7 years ago

I use the Flatpak build. But looking at the code now it looks like you're setting the dark variant unconditionally, so using the dark variant might even be intended? Are you sure you want this?, the dark variant is meant for stuff like photo- and movie applications to make the content stand out more and it looks pretty bad with a dark header and really bright content inside. :/

aperezdc commented 7 years ago

@mattiasb: Actually, using the dark theme is intended — Adwaita is the only theme option so far when running as Flatpak, and the normal (light) variant hurts my eyes badly, especially title bars and header bars, but the dark theme is passable.

At any rate, Riot has just gained a dark theme, so what we may want to do here is trying to pick Riot's setting and choose the GTK+ theme variant depending on what the user has selected in the Riot preferences (or supply a setting in Revolt's settings window which also applies to Riot).

hackel commented 7 years ago

Is there no way for Flatpak apps to access the system-installed themes? This seems like a severe limitation. GTK_THEME=Adwaita:dark helps make it a little less jarring, but since I use Arc, it definitely looks out of place. Not to mention my own personal gtk.css customisations to get rid of the monstrously thick titlebar. It also changes my cursor (from white to black) when hovering over form controls.

Edit: Nevermind, it's a limitation of the platform. https://github.com/flatpak/flatpak/issues/114

Edit 2: A temporary solution is to copy the theme you want, e.g. /usr/share/themes/Arc-Dark into your runtime, e.g. /var/lib/flatpak/runtime/org.gnome.Platform/x86_64/3.24/active/files/share/themes, then run the app with flatpak run --env=GTK_THEME=Arc-Dark org.perezdecastro.Revolt

phw commented 7 years ago

@hackel Themes depend heavily on the version of GTK used, so accessing system wide themes would often cause issues if they are incompatible with the Flatpak runtime used.

But the Flatpak developers are actively working on a solution using extensions, see https://github.com/flatpak/flatpak/issues/114

aperezdc commented 7 years ago

I think the correct thing here is to wait for upstream support handling runtime-external themes in Flatpak, and once that is fixed I can add a note in the README pointing what the solution is. Revolt should not need do anything in this regard.

Note that #38 is still relevant, and should be implemented at some point.

bertin0 commented 6 years ago

I know this is a flatpak thing, but the appropiate github issue on the flatpak repo is closed. i know that there are theme extensions for flatpak now, but i cant get Arc-Dark to set(it sets to adwaita dark..) Could anyone here help me or point me in the right direction?