theme: Detect dark theme with its background color

This commit is contained in:
Alberto Fanjul 2018-07-20 19:50:06 +02:00
parent 177a8cf0cc
commit 04bdad03bf
2 changed files with 22 additions and 0 deletions

View file

@ -373,6 +373,17 @@ public class Window : Gtk.ApplicationWindow, GitgExt.Application, Initable
var dark = settings.gtk_application_prefer_dark_theme || (theme != null && theme.has_suffix(":dark"));
if (!dark) {
var stylecontext = get_style_context();
Gdk.RGBA rgba;
var background_set = stylecontext.lookup_color("theme_bg_color", out rgba);
if (background_set && rgba.red + rgba.green + rgba.blue < 1.0)
{
dark = true;
}
}
if (dark)
{
get_style_context().add_class("dark");

View file

@ -90,6 +90,17 @@ public class Gitg.DiffStat : Gtk.DrawingArea
var dark = settings.gtk_application_prefer_dark_theme || (theme != null && theme.has_suffix(":dark"));
if (!dark) {
var stylecontext = get_style_context();
Gdk.RGBA rgba;
var background_set = stylecontext.lookup_color("theme_bg_color", out rgba);
if (background_set && rgba.red + rgba.green + rgba.blue < 1.0)
{
dark = true;
}
}
if (dark)
{
get_style_context().add_class("dark");