[gnome-software: 7/7] trivial: Add fudge factor so that app ratings of >90% display five stars
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 7/7] trivial: Add fudge factor so that app ratings of >90% display five stars
- Date: Wed, 27 Jul 2016 11:27:57 +0000 (UTC)
commit 41aa835798cf189104d9d80134b7466f8a38a667
Author: Richard Hughes <richard hughsie com>
Date: Wed Jul 27 12:22:50 2016 +0100
trivial: Add fudge factor so that app ratings of >90% display five stars
src/gs-star-widget.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-star-widget.c b/src/gs-star-widget.c
index e0f9fb1..e6dbf32 100644
--- a/src/gs-star-widget.c
+++ b/src/gs-star-widget.c
@@ -23,6 +23,7 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <math.h>
#include "gs-common.h"
#include "gs-star-widget.h"
@@ -89,10 +90,16 @@ gs_star_widget_refresh (GsStarWidget *star)
{
GsStarWidgetPrivate *priv = gs_star_widget_get_instance_private (star);
guint i;
+ gdouble rating;
/* remove all existing widgets */
gs_container_remove_all (GTK_CONTAINER (priv->box1));
+ /* add fudge factor so we can actually get 5 stars in reality,
+ * and round up to nearest power of 10 */
+ rating = priv->rating + 10;
+ rating = 10 * ceil (rating / 10);
+
for (i = 0; i < 5; i++) {
GtkWidget *w;
GtkWidget *im;
@@ -118,7 +125,7 @@ gs_star_widget_refresh (GsStarWidget *star)
gtk_widget_set_sensitive (w, priv->interactive);
gtk_style_context_add_class (gtk_widget_get_style_context (w), "star");
gtk_style_context_add_class (gtk_widget_get_style_context (im),
- priv->rating >= rate_to_star[i] ?
+ rating >= rate_to_star[i] ?
"star-enabled" : "star-disabled");
gtk_widget_set_visible (w, TRUE);
gtk_container_add (GTK_CONTAINER (priv->box1), w);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]