improved color check

This commit is contained in:
Artem Anufrij 2017-11-19 01:34:39 +01:00
parent 58674f1217
commit 906ff06140

View file

@ -41,12 +41,14 @@ namespace Webpin {
public WebWindow (DesktopFile desktop_file) { public WebWindow (DesktopFile desktop_file) {
this.desktop_file = desktop_file; this.desktop_file = desktop_file;
this.events |= Gdk.EventMask.STRUCTURE_MASK; this.events |= Gdk.EventMask.STRUCTURE_MASK;
if (desktop_file.color != null) {
var mid = desktop_file.color.red + desktop_file.color.blue + desktop_file.color.green; var color = desktop_file.color;
if (color != null) {
var mid = color.red + color.blue + color.green;
if (mid / 3 < 0.3) { if (mid / 3 < 0.3) {
Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true; Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;
} }
Granite.Widgets.Utils.set_color_primary (this, desktop_file.color); Granite.Widgets.Utils.set_color_primary (this, color);
} }
set_wmclass (desktop_file.url, desktop_file.url); set_wmclass (desktop_file.url, desktop_file.url);