[gitg] theme: Detect dark theme with its background color
- From: Alberto Fanjul <albfan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] theme: Detect dark theme with its background color
- Date: Fri, 20 Jul 2018 17:52:06 +0000 (UTC)
commit 04bdad03bfa8d1876db3ba412d3c40d77e78874a
Author: Alberto Fanjul <albertofanjul gmail com>
Date: Fri Jul 20 19:50:06 2018 +0200
theme: Detect dark theme with its background color
gitg/gitg-window.vala | 11 +++++++++++
libgitg/gitg-diff-stat.vala | 11 +++++++++++
2 files changed, 22 insertions(+)
---
diff --git a/gitg/gitg-window.vala b/gitg/gitg-window.vala
index 58904c74..c05dda7a 100644
--- a/gitg/gitg-window.vala
+++ b/gitg/gitg-window.vala
@@ -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");
diff --git a/libgitg/gitg-diff-stat.vala b/libgitg/gitg-diff-stat.vala
index 0b4b986c..f83318fe 100644
--- a/libgitg/gitg-diff-stat.vala
+++ b/libgitg/gitg-diff-stat.vala
@@ -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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]