mirror of
https://gitlab.gnome.org/GNOME/gitg
synced 2024-10-02 14:13:48 +00:00
theme: Detect dark theme with its background color
This commit is contained in:
parent
177a8cf0cc
commit
04bdad03bf
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue