[gnome-software] Allow difference importances to be given to each kudo



commit 0c14acf57150a882d0fe58ab39b75389dfac0725
Author: Richard Hughes <richard hughsie com>
Date:   Thu Feb 27 13:29:51 2014 +0000

    Allow difference importances to be given to each kudo

 src/gs-app-tile.c      |    2 +-
 src/gs-app-widget.c    |    2 +-
 src/gs-app.c           |   30 ++++++++++++++++++++++++++++++
 src/gs-app.h           |    3 +++
 src/gs-shell-details.c |    2 +-
 src/gs-star-widget.c   |    2 +-
 6 files changed, 37 insertions(+), 4 deletions(-)
---
diff --git a/src/gs-app-tile.c b/src/gs-app-tile.c
index df3a533..ea81998 100644
--- a/src/gs-app-tile.c
+++ b/src/gs-app-tile.c
@@ -139,7 +139,7 @@ gs_app_tile_set_app (GsAppTile *tile, GsApp *app)
        } else {
                gs_star_widget_set_rating (GS_STAR_WIDGET (priv->stars),
                                           GS_APP_RATING_KIND_KUDOS,
-                                          gs_app_get_kudos_weight (priv->app));
+                                          gs_app_get_kudos_percentage (priv->app));
        }
 
        gtk_widget_hide (priv->waiting);
diff --git a/src/gs-app-widget.c b/src/gs-app-widget.c
index 33f7038..dd19f9a 100644
--- a/src/gs-app-widget.c
+++ b/src/gs-app-widget.c
@@ -163,7 +163,7 @@ gs_app_widget_refresh (GsAppWidget *app_widget)
                } else {
                        gs_star_widget_set_rating (GS_STAR_WIDGET (priv->star),
                                                   GS_APP_RATING_KIND_KUDOS,
-                                                  gs_app_get_kudos_weight (priv->app));
+                                                  gs_app_get_kudos_percentage (priv->app));
                }
                gtk_label_set_label (GTK_LABEL (priv->version_label),
                                     gs_app_get_version_ui (priv->app));
diff --git a/src/gs-app.c b/src/gs-app.c
index 5a221ac..e6efbf2 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -243,6 +243,8 @@ gs_app_to_string (GsApp *app)
                g_string_append (str, "\tkudo:\tuses-app-menu\n");
        if ((priv->kudos & GS_APP_KUDO_HAS_KEYWORDS) > 0)
                g_string_append (str, "\tkudo:\thas-keywords\n");
+       g_string_append_printf (str, "\tkudo-percentage:\t%i\n",
+                               gs_app_get_kudos_percentage (app));
        if (priv->name != NULL)
                g_string_append_printf (str, "\tname:\t%s\n", priv->name);
        if (priv->icon != NULL)
@@ -1606,6 +1608,34 @@ gs_app_get_kudos_weight (GsApp *app)
 }
 
 /**
+ * gs_app_get_kudos_percentage:
+ */
+guint
+gs_app_get_kudos_percentage (GsApp *app)
+{
+       guint percentage = 0;
+       if ((app->priv->kudos & GS_APP_KUDO_MY_LANGUAGE) > 0)
+               percentage += 20;
+       if ((app->priv->kudos & GS_APP_KUDO_RECENT_RELEASE) > 0)
+               percentage += 20;
+       if ((app->priv->kudos & GS_APP_KUDO_FEATURED_RECOMMENDED) > 0)
+               percentage += 20;
+       if ((app->priv->kudos & GS_APP_KUDO_MODERN_TOOLKIT) > 0)
+               percentage += 20;
+       if ((app->priv->kudos & GS_APP_KUDO_SEARCH_PROVIDER) > 0)
+               percentage += 10;
+       if ((app->priv->kudos & GS_APP_KUDO_INSTALLS_USER_DOCS) > 0)
+               percentage += 10;
+       if ((app->priv->kudos & GS_APP_KUDO_USES_NOTIFICATIONS) > 0)
+               percentage += 20;
+       if ((app->priv->kudos & GS_APP_KUDO_HAS_KEYWORDS) > 0)
+               percentage += 5;
+       if ((app->priv->kudos & GS_APP_KUDO_USES_APP_MENU) > 0)
+               percentage += 10;
+       return MIN (percentage, 100);
+}
+
+/**
  * gs_app_subsume:
  *
  * Imports all the useful data from @other into @app.
diff --git a/src/gs-app.h b/src/gs-app.h
index 929b9e0..540cc90 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -127,6 +127,8 @@ typedef enum {
        GS_APP_QUALITY_LAST
 } GsAppQuality;
 
+#define        GS_APP_KUDOS_WEIGHT_TO_PERCENTAGE(w)    (w * 20)
+
 GQuark          gs_app_error_quark             (void);
 GType           gs_app_get_type                (void);
 
@@ -264,6 +266,7 @@ void                 gs_app_add_kudo                (GsApp          *app,
                                                 GsAppKudo       kudo);
 guint64                 gs_app_get_kudos               (GsApp          *app);
 guint           gs_app_get_kudos_weight        (GsApp          *app);
+guint           gs_app_get_kudos_percentage    (GsApp          *app);
 
 G_END_DECLS
 
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 2309566..43e106a 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -677,7 +677,7 @@ gs_shell_details_refresh_all (GsShellDetails *shell_details)
                } else {
                        gs_star_widget_set_rating (GS_STAR_WIDGET (priv->star),
                                                   GS_APP_RATING_KIND_KUDOS,
-                                                  gs_app_get_kudos_weight (priv->app));
+                                                  gs_app_get_kudos_percentage (priv->app));
                }
                break;
        }
diff --git a/src/gs-star-widget.c b/src/gs-star-widget.c
index bfd3c45..531776a 100644
--- a/src/gs-star-widget.c
+++ b/src/gs-star-widget.c
@@ -51,7 +51,7 @@ enum {
 
 static guint signals [SIGNAL_LAST] = { 0 };
 
-static const gint rate_to_star[] = {1, 25, 50, 75, 100, -1};
+static const gint rate_to_star[] = {20, 40, 60, 80, 100, -1};
 
 /**
  * gs_star_widget_get_rating:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]