fix custom color

This commit is contained in:
Artem Anufrij 2017-11-19 12:28:44 +01:00
parent 906ff06140
commit d7c7557ece
3 changed files with 26 additions and 13 deletions

View file

@ -32,7 +32,15 @@
</screenshot> </screenshot>
</screenshots> </screenshots>
<releases> <releases>
<release version="0.2.2" date="2017-11-18"> <release version="0.2.3" date="2017-11-20">
<description>
<p>Fix:</p>
<ul>
<li>Custom settings in .desktop</li>
</ul>
</description>
</release>
<release version="0.2.2" date="2017-11-20">
<description> <description>
<p>Fix:</p> <p>Fix:</p>
<ul> <ul>

View file

@ -63,24 +63,29 @@ namespace Webpin {
} }
} }
Gdk.RGBA? _color;
public Gdk.RGBA? color { public Gdk.RGBA? color {
get { get {
Gdk.RGBA return_value = {0, 0, 0, 255}; if (_color == null) {
this.file = new GLib.KeyFile(); Gdk.RGBA return_value = {0, 0, 0, 0};
try { this.file = new GLib.KeyFile();
file.load_from_file (info.filename, KeyFileFlags.NONE); try {
var property = file.get_string ("Desktop Entry", "X-Webpin-PrimaryColor"); file.load_from_file (info.filename, KeyFileFlags.NONE);
if (property == "" || !return_value.parse (property)) { 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; return null;
} }
} catch (Error e) { _color = return_value;
warning (e.message);
return null;
} }
return return_value; return _color;
} set { } set {
if (value != null) { 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); edit_propertie ("X-Webpin-PrimaryColor", color);
} }
} }

View file

@ -45,7 +45,7 @@ namespace Webpin {
var color = desktop_file.color; var color = desktop_file.color;
if (color != null) { if (color != null) {
var mid = color.red + color.blue + color.green; 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; Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;
} }
Granite.Widgets.Utils.set_color_primary (this, color); Granite.Widgets.Utils.set_color_primary (this, color);