[gnome-software] trivial: Use custom colors for the age rating button
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] trivial: Use custom colors for the age rating button
- Date: Thu, 22 Sep 2016 13:51:23 +0000 (UTC)
commit 8d973cc23847a129ea73ec07d33c7fbd1878ed97
Author: Richard Hughes <richard hughsie com>
Date: Thu Sep 22 14:50:42 2016 +0100
trivial: Use custom colors for the age rating button
src/gs-content-rating.c | 2 +-
src/gs-shell-details.c | 24 +++++++++++++++---------
src/gtk-style.css | 10 ----------
3 files changed, 16 insertions(+), 20 deletions(-)
---
diff --git a/src/gs-content-rating.c b/src/gs-content-rating.c
index d16e59f..0511cbc 100644
--- a/src/gs-content-rating.c
+++ b/src/gs-content-rating.c
@@ -431,7 +431,7 @@ gs_utils_content_rating_age_to_str (GsContentRatingSystem system, guint age)
return "E10+";
if (age >= 6)
return "E";
- return "EC";
+ return "eC";
}
/* IARC = everything else */
if (age >= 18)
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 7f109e2..8ae27be 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1314,17 +1314,23 @@ gs_shell_details_app_refine2 (GsShellDetails *self)
static void
gs_shell_details_content_rating_set_css (GtkWidget *widget, guint age)
{
- GtkStyleContext *ctx = gtk_widget_get_style_context (widget);
- gtk_style_context_remove_class (ctx, "content-rating-adult");
- gtk_style_context_remove_class (ctx, "content-rating-parental-guidance");
+ g_autoptr(GString) css = g_string_new (NULL);
+ const gchar *color_bg = NULL;
+ const gchar *color_fg = "#ffffff";
if (age >= 18) {
- gtk_style_context_add_class (ctx, "content-rating-adult");
- return;
- }
- if (age >= 5) {
- gtk_style_context_add_class (ctx, "content-parental-guidance");
- return;
+ color_bg = "#ee2222";
+ } else if (age >= 15) {
+ color_bg = "#f1c000";
+ } else if (age >= 12) {
+ color_bg = "#2a97c9";
+ } else if (age >= 5) {
+ color_bg = "#3f756c";
+ } else {
+ color_bg = "#009d66";
}
+ g_string_append_printf (css, "color: %s;\n", color_fg);
+ g_string_append_printf (css, "background-color: %s;\n", color_bg);
+ gs_utils_widget_set_css_simple (widget, css->str);
}
static void
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 45f2ebc..9a76bb0 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -78,16 +78,6 @@
text-shadow: none;
}
-.content-rating-adult {
- color: #ffffff;
- background-color: #ee2222;
-}
-
-.content-rating-parental-guidance {
- color: #ffffff;
- background-color: #4e9a06;
-}
-
.details-license-free,
.details-license-free label,
.details-license-free:backdrop label {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]