Skip to content

Commit

Permalink
Add primary color for elementary theme (tkashkin#170)
Browse files Browse the repository at this point in the history
More verbose logging for Humble Trove with `--verbose` option (tkashkin#32)
  • Loading branch information
tkashkin committed Jan 23, 2019
1 parent e380a84 commit 3c67adf
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
5 changes: 3 additions & 2 deletions data/com.github.tkashkin.gamehub.gresource.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/com/github/tkashkin/gamehub">
<file alias="GameHub.css" compressed="true">GameHub.css</file>
<gresource prefix="/com/github/tkashkin/gamehub/css">
<file alias="app.css" compressed="true">css/app.css</file>
<file alias="themes/elementary.css" compressed="true">css/themes/elementary.css</file>
</gresource>
</gresources>
4 changes: 0 additions & 4 deletions data/GameHub.css → data/css/app.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
@define-color colorAccent #a56de2;
@define-color selected_bg_color @colorAccent;
@define-color theme_selected_bg_color @colorAccent;

.gamecard
{
opacity: 0.75;
Expand Down
5 changes: 5 additions & 0 deletions data/css/themes/elementary.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@define-color colorPrimary mix(#7239b3, @titlebar_color, 0.2);
@define-color colorAccent #8c53cb;
@define-color theme_selected_bg_color @colorAccent;
@define-color textColorPrimary mix(@colorPrimary, #fafafa, 0.95);
@define-color textColorPrimaryShadow alpha(#7239b3, 0.4);
25 changes: 22 additions & 3 deletions src/app.vala
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,28 @@ namespace GameHub
weak IconTheme default_theme = IconTheme.get_default();
default_theme.add_resource_path("/com/github/tkashkin/gamehub/icons");

var provider = new CssProvider();
provider.load_from_resource("/com/github/tkashkin/gamehub/GameHub.css");
StyleContext.add_provider_for_screen(Screen.get_default(), provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
var screen = Screen.get_default();

var app_provider = new CssProvider();
app_provider.load_from_resource("/com/github/tkashkin/gamehub/css/app.css");

var elementary_provider = new CssProvider();
elementary_provider.load_from_resource("/com/github/tkashkin/gamehub/css/themes/elementary.css");

StyleContext.add_provider_for_screen(screen, app_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);

var settings = Gtk.Settings.get_for_screen(screen);
settings.notify["gtk-theme-name"].connect(() => {
if(settings.gtk_theme_name == "elementary")
{
StyleContext.add_provider_for_screen(screen, elementary_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
}
else
{
StyleContext.remove_provider_for_screen(screen, elementary_provider);
}
});
settings.notify_property("gtk-theme-name");
}

protected override void activate()
Expand Down
10 changes: 7 additions & 3 deletions src/data/sources/humble/HumbleGame.vala
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ namespace GameHub.Data.Sources.Humble

public bool is_url_update_required()
{
if(part.url == null || part.url.length == 0) return true;
if(part.url == null || part.url.length == 0 || part.url.has_prefix("humble-trove-unsigned://")) return true;
if(!part.url.contains("&ttl=")) return false;
var ttl_string = part.url.split("&ttl=")[1].split("&")[0];
var ttl = new DateTime.from_unix_utc(int64.parse(ttl_string));
Expand All @@ -432,9 +432,13 @@ namespace GameHub.Data.Sources.Humble
{
if(!(game.source is Trove) || !is_url_update_required()) return null;

//debug("[HumbleGame.Installer.update_url] Old URL: '%s'; (%s)", part.url, game.full_id);
var new_url = Trove.sign_url(id, dl_id, ((Humble) game.source).user_token);
//debug("[HumbleGame.Installer.update_url] New URL: '%s'; (%s)", new_url, game.full_id);

if(GameHub.Application.log_verbose)
{
debug("[HumbleGame.Installer.update_url] Old URL: '%s'; (%s)", part.url, game.full_id);
debug("[HumbleGame.Installer.update_url] New URL: '%s'; (%s)", new_url, game.full_id);
}

if(new_url != null) part.url = new_url;

Expand Down
9 changes: 8 additions & 1 deletion src/data/sources/humble/Trove.vala
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,14 @@ namespace GameHub.Data.Sources.Humble
var signed_node = Parser.parse_remote_json_file(Trove.SIGN_URL, "POST", null, headers, data);
var signed = signed_node != null && signed_node.get_node_type() == Json.NodeType.OBJECT ? signed_node.get_object() : null;

return signed != null && signed.has_member("signed_url") ? signed.get_string_member("signed_url") : null;
var signed_url = signed != null && signed.has_member("signed_url") ? signed.get_string_member("signed_url") : null;

if(GameHub.Application.log_verbose)
{
debug("[Trove.sign_url] '%s':'%s' -> '%s'", machine_name, filename, signed_url);
}

return signed_url;
}
}
}

0 comments on commit 3c67adf

Please sign in to comment.