Skip to content

Commit

Permalink
fix custom color
Browse files Browse the repository at this point in the history
  • Loading branch information
artemanufrij committed Nov 19, 2017
1 parent 906ff06 commit d7c7557
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
10 changes: 9 additions & 1 deletion data/com.github.artemanufrij.webpin.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@
</screenshot>
</screenshots>
<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>
<p>Fix:</p>
<ul>
Expand Down
27 changes: 16 additions & 11 deletions src/Objects/DesktopFile.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/WebWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d7c7557

Please sign in to comment.