From d7c7557ece1931c016e448de9ebab64cc84bd271 Mon Sep 17 00:00:00 2001 From: Artem Anufrij Date: Sun, 19 Nov 2017 12:28:44 +0100 Subject: [PATCH] fix custom color --- ...com.github.artemanufrij.webpin.appdata.xml | 10 ++++++- src/Objects/DesktopFile.vala | 27 +++++++++++-------- src/WebWindow.vala | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/data/com.github.artemanufrij.webpin.appdata.xml b/data/com.github.artemanufrij.webpin.appdata.xml index d7218e3..a7b87f0 100644 --- a/data/com.github.artemanufrij.webpin.appdata.xml +++ b/data/com.github.artemanufrij.webpin.appdata.xml @@ -32,7 +32,15 @@ - + + +

Fix:

+
    +
  • Custom settings in .desktop
  • +
+
+
+

Fix:

    diff --git a/src/Objects/DesktopFile.vala b/src/Objects/DesktopFile.vala index 2d3f129..091c941 100644 --- a/src/Objects/DesktopFile.vala +++ b/src/Objects/DesktopFile.vala @@ -63,24 +63,29 @@ namespace Webpin { } } + Gdk.RGBA? _color; public Gdk.RGBA? color { get { - Gdk.RGBA return_value = {0, 0, 0, 255}; - this.file = new GLib.KeyFile(); - try { - file.load_from_file (info.filename, KeyFileFlags.NONE); - var property = file.get_string ("Desktop Entry", "X-Webpin-PrimaryColor"); - if (property == "" || !return_value.parse (property)) { + if (_color == null) { + Gdk.RGBA return_value = {0, 0, 0, 0}; + this.file = new GLib.KeyFile(); + try { + file.load_from_file (info.filename, KeyFileFlags.NONE); + var property = file.get_string ("Desktop Entry", "X-Webpin-PrimaryColor"); + if (property == "" || !return_value.parse (property)) { + return null; + } + } catch (Error e) { + warning (e.message); return null; } - } catch (Error e) { - warning (e.message); - return null; + _color = return_value; } - return return_value; + return _color; } set { if (value != null) { - var color = "#%02x%02x%02x".printf ((int)(value.red * 255), (int)(value.green * 255), (int)(value.blue * 255)); + _color = value; + var color = "rgba (%d,%d,%d,1)".printf ((int)(value.red * 255), (int)(value.green * 255), (int)(value.blue * 255)); edit_propertie ("X-Webpin-PrimaryColor", color); } } diff --git a/src/WebWindow.vala b/src/WebWindow.vala index 313c813..f532380 100644 --- a/src/WebWindow.vala +++ b/src/WebWindow.vala @@ -45,7 +45,7 @@ namespace Webpin { 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.5) { Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true; } Granite.Widgets.Utils.set_color_primary (this, color);