[gnome-software] trivial: Do not allow the kudo to be used as a rating



commit 8f4a876609bb0b9da387c1deb098ed0a2895bcb4
Author: Richard Hughes <richard hughsie com>
Date:   Sun Jan 24 17:47:49 2016 +0000

    trivial: Do not allow the kudo to be used as a rating

 src/gs-app-row.c                              |   12 ++--------
 src/gs-app-tile.c                             |    8 ++----
 src/gs-app.c                                  |   27 -------------------------
 src/gs-app.h                                  |   11 ----------
 src/gs-popular-tile.c                         |    8 ++----
 src/gs-shell-details.c                        |    9 ++-----
 src/gs-star-widget.c                          |   22 +------------------
 src/gs-star-widget.h                          |    1 -
 src/gtk-style-hc.css                          |    4 ---
 src/gtk-style.css                             |    4 ---
 src/plugins/gs-plugin-fedora-tagger-ratings.c |    1 -
 src/plugins/gs-plugin-local-ratings.c         |    1 -
 12 files changed, 14 insertions(+), 94 deletions(-)
---
diff --git a/src/gs-app-row.c b/src/gs-app-row.c
index f17c1e4..ed49f25 100644
--- a/src/gs-app-row.c
+++ b/src/gs-app-row.c
@@ -182,19 +182,13 @@ gs_app_row_refresh (GsAppRow *app_row)
        } else {
                gtk_widget_hide (priv->version_label);
                if (gs_app_get_kind (priv->app) == GS_APP_KIND_MISSING ||
-                   (gs_app_get_state (priv->app) == AS_APP_STATE_AVAILABLE_LOCAL && gs_app_get_rating 
(priv->app) < 0))
+                   gs_app_get_rating (priv->app) <= 0) {
                        gtk_widget_hide (priv->star);
-               else
+               } else {
                        gtk_widget_show (priv->star);
-               gtk_widget_set_sensitive (priv->star, FALSE);
-               if (gs_app_get_rating_kind (priv->app) == GS_APP_RATING_KIND_USER) {
+                       gtk_widget_set_sensitive (priv->star, FALSE);
                        gs_star_widget_set_rating (GS_STAR_WIDGET (priv->star),
-                                                  GS_APP_RATING_KIND_USER,
                                                   gs_app_get_rating (priv->app));
-               } else {
-                       gs_star_widget_set_rating (GS_STAR_WIDGET (priv->star),
-                                                  GS_APP_RATING_KIND_KUDOS,
-                                                  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-tile.c b/src/gs-app-tile.c
index 1586fd9..faa45d7 100644
--- a/src/gs-app-tile.c
+++ b/src/gs-app-tile.c
@@ -136,14 +136,12 @@ gs_app_tile_set_app (GsAppTile *tile, GsApp *app)
        if (!app)
                return;
 
-       if (gs_app_get_rating_kind (tile->app) == GS_APP_RATING_KIND_USER) {
+       if (gs_app_get_rating (tile->app) >= 0) {
+               gtk_widget_set_visible (tile->stars, TRUE);
                gs_star_widget_set_rating (GS_STAR_WIDGET (tile->stars),
-                                          GS_APP_RATING_KIND_USER,
                                           gs_app_get_rating (tile->app));
        } else {
-               gs_star_widget_set_rating (GS_STAR_WIDGET (tile->stars),
-                                          GS_APP_RATING_KIND_KUDOS,
-                                          gs_app_get_kudos_percentage (tile->app));
+               gtk_widget_set_visible (tile->stars, FALSE);
        }
 
        gtk_stack_set_visible_child_name (GTK_STACK (tile->stack), "content");
diff --git a/src/gs-app.c b/src/gs-app.c
index 350efe6..3bcd9b0 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -84,7 +84,6 @@ struct _GsApp
        gchar                   *management_plugin;
        gint                     rating;
        gint                     rating_confidence;
-       GsAppRatingKind          rating_kind;
        guint64                  size;
        GsAppKind                kind;
        AsIdKind                 id_kind;
@@ -294,10 +293,6 @@ gs_app_to_string (GsApp *app)
                g_string_append_printf (str, "\trating:\t%i\n", app->rating);
        if (app->rating_confidence != -1)
                g_string_append_printf (str, "\trating-confidence:\t%i\n", app->rating_confidence);
-       if (app->rating_kind != GS_APP_RATING_KIND_UNKNOWN)
-               g_string_append_printf (str, "\trating-kind:\t%s\n",
-                                       app->rating_kind == GS_APP_RATING_KIND_USER ?
-                                               "user" : "system");
        if (app->pixbuf != NULL)
                g_string_append_printf (str, "\tpixbuf:\t%p\n", app->pixbuf);
        if (app->featured_pixbuf != NULL)
@@ -1700,27 +1695,6 @@ gs_app_set_rating_confidence (GsApp *app, gint rating_confidence)
 }
 
 /**
- * gs_app_get_rating_kind:
- */
-GsAppRatingKind
-gs_app_get_rating_kind (GsApp *app)
-{
-       g_return_val_if_fail (GS_IS_APP (app), -1);
-       return app->rating_kind;
-}
-
-/**
- * gs_app_set_rating_kind:
- */
-void
-gs_app_set_rating_kind (GsApp *app, GsAppRatingKind rating_kind)
-{
-       g_return_if_fail (GS_IS_APP (app));
-       app->rating_kind = rating_kind;
-       gs_app_queue_notify (app, "rating");
-}
-
-/**
  * gs_app_get_size:
  */
 guint64
@@ -2444,7 +2418,6 @@ gs_app_init (GsApp *app)
 {
        app->rating = -1;
        app->rating_confidence = -1;
-       app->rating_kind = GS_APP_RATING_KIND_UNKNOWN;
        app->sources = g_ptr_array_new_with_free_func (g_free);
        app->source_ids = g_ptr_array_new_with_free_func (g_free);
        app->categories = g_ptr_array_new_with_free_func (g_free);
diff --git a/src/gs-app.h b/src/gs-app.h
index e26896b..ba3b078 100644
--- a/src/gs-app.h
+++ b/src/gs-app.h
@@ -52,14 +52,6 @@ typedef enum {
 } GsAppKind;
 
 typedef enum {
-       GS_APP_RATING_KIND_UNKNOWN,
-       GS_APP_RATING_KIND_USER,
-       GS_APP_RATING_KIND_SYSTEM,
-       GS_APP_RATING_KIND_KUDOS,
-       GS_APP_RATING_KIND_LAST
-} GsAppRatingKind;
-
-typedef enum {
        GS_APP_KUDO_MY_LANGUAGE                 = 1 << 0,
        GS_APP_KUDO_RECENT_RELEASE              = 1 << 1,
        GS_APP_KUDO_FEATURED_RECOMMENDED        = 1 << 2,
@@ -210,9 +202,6 @@ void                 gs_app_set_rating              (GsApp          *app,
 gint            gs_app_get_rating_confidence   (GsApp          *app);
 void            gs_app_set_rating_confidence   (GsApp          *app,
                                                 gint            rating_confidence);
-GsAppRatingKind         gs_app_get_rating_kind         (GsApp          *app);
-void            gs_app_set_rating_kind         (GsApp          *app,
-                                                GsAppRatingKind rating_kind);
 guint64                 gs_app_get_size                (GsApp          *app);
 void            gs_app_set_size                (GsApp          *app,
                                                 guint64         size);
diff --git a/src/gs-popular-tile.c b/src/gs-popular-tile.c
index ee5a23c..d9c5f4b 100644
--- a/src/gs-popular-tile.c
+++ b/src/gs-popular-tile.c
@@ -113,14 +113,12 @@ gs_popular_tile_set_app (GsPopularTile *tile, GsApp *app)
        if (!app)
                return;
 
-       if (gs_app_get_rating_kind (tile->app) == GS_APP_RATING_KIND_USER) {
+       if (gs_app_get_rating (tile->app) >= 0) {
+               gtk_widget_set_visible (tile->stars, TRUE);
                gs_star_widget_set_rating (GS_STAR_WIDGET (tile->stars),
-                                          GS_APP_RATING_KIND_USER,
                                           gs_app_get_rating (tile->app));
        } else {
-               gs_star_widget_set_rating (GS_STAR_WIDGET (tile->stars),
-                                          GS_APP_RATING_KIND_KUDOS,
-                                          gs_app_get_kudos_percentage (tile->app));
+               gtk_widget_set_visible (tile->stars, FALSE);
        }
        gtk_stack_set_visible_child_name (GTK_STACK (tile->stack), "content");
 
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 06dbcff..ea6e13c 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -724,14 +724,12 @@ gs_shell_details_refresh_all (GsShellDetails *self)
                break;
        default:
                gtk_widget_set_visible (self->star, TRUE);
-               if (gs_app_get_rating_kind (self->app) == GS_APP_RATING_KIND_USER) {
+               if (gs_app_get_rating (self->app) >= 0) {
+                       gtk_widget_set_visible (self->star, TRUE);
                        gs_star_widget_set_rating (GS_STAR_WIDGET (self->star),
-                                                  GS_APP_RATING_KIND_USER,
                                                   gs_app_get_rating (self->app));
                } else {
-                       gs_star_widget_set_rating (GS_STAR_WIDGET (self->star),
-                                                  GS_APP_RATING_KIND_KUDOS,
-                                                  gs_app_get_kudos_percentage (self->app));
+                       gtk_widget_set_visible (self->star, FALSE);
                }
                break;
        }
@@ -1267,7 +1265,6 @@ gs_shell_details_rating_changed_cb (GsStarWidget *star,
 
        /* call into the plugins to set the new value */
        gs_app_set_rating (self->app, rating);
-       gs_app_set_rating_kind (self->app, GS_APP_RATING_KIND_USER);
        gs_plugin_loader_app_action_async (self->plugin_loader, self->app,
                                           GS_PLUGIN_LOADER_ACTION_SET_RATING,
                                           self->cancellable,
diff --git a/src/gs-star-widget.c b/src/gs-star-widget.c
index 2d9f3ab..3537c62 100644
--- a/src/gs-star-widget.c
+++ b/src/gs-star-widget.c
@@ -28,7 +28,6 @@
 
 typedef struct
 {
-       GsAppRatingKind  rating_kind;
        gint             rating;
        GtkWidget       *button1;
        GtkWidget       *button2;
@@ -69,7 +68,7 @@ gs_star_widget_get_rating (GsStarWidget *star)
  * gs_star_widget_set_image_rating:
  **/
 static void
-gs_star_widget_set_image_rating (GtkImage *image, GsAppRatingKind rating_kind,
+gs_star_widget_set_image_rating (GtkImage *image,
                                 gint value, gint lower, gint higher)
 {
        GtkStyleContext *context;
@@ -81,13 +80,7 @@ gs_star_widget_set_image_rating (GtkImage *image, GsAppRatingKind rating_kind,
                icon_name = "starred-symbolic";
 
        context = gtk_widget_get_style_context (GTK_WIDGET (image));
-       if (rating_kind == GS_APP_RATING_KIND_USER) {
-               gtk_style_context_add_class (context, "star-user");
-               gtk_style_context_remove_class (context, "star");
-       } else {
-               gtk_style_context_add_class (context, "star");
-               gtk_style_context_remove_class (context, "star-user");
-       }
+       gtk_style_context_add_class (context, "star");
        gtk_image_set_from_icon_name (image, icon_name, GTK_ICON_SIZE_MENU);
 }
 
@@ -116,23 +109,18 @@ gs_star_widget_refresh (GsStarWidget *star)
        GsStarWidgetPrivate *priv;
        priv = gs_star_widget_get_instance_private (star);
        gs_star_widget_set_image_rating (GTK_IMAGE (priv->image1),
-                                        priv->rating_kind,
                                         priv->rating,
                                         0, rate_to_star[0]);
        gs_star_widget_set_image_rating (GTK_IMAGE (priv->image2),
-                                        priv->rating_kind,
                                         priv->rating,
                                         rate_to_star[0], rate_to_star[1]);
        gs_star_widget_set_image_rating (GTK_IMAGE (priv->image3),
-                                        priv->rating_kind,
                                         priv->rating,
                                         rate_to_star[1], rate_to_star[2]);
        gs_star_widget_set_image_rating (GTK_IMAGE (priv->image4),
-                                        priv->rating_kind,
                                         priv->rating,
                                         rate_to_star[2], rate_to_star[3]);
        gs_star_widget_set_image_rating (GTK_IMAGE (priv->image5),
-                                        priv->rating_kind,
                                         priv->rating,
                                         rate_to_star[3], rate_to_star[4]);
 }
@@ -142,14 +130,12 @@ gs_star_widget_refresh (GsStarWidget *star)
  **/
 void
 gs_star_widget_set_rating (GsStarWidget *star,
-                          GsAppRatingKind rating_kind,
                           gint rating)
 {
        GsStarWidgetPrivate *priv;
        g_return_if_fail (GS_IS_STAR_WIDGET (star));
        priv = gs_star_widget_get_instance_private (star);
        priv->rating = rating;
-       priv->rating_kind = rating_kind;
        gs_star_widget_refresh (star);
 }
 
@@ -174,10 +160,6 @@ gs_star_widget_button_clicked_cb (GtkButton *button, GsStarWidget *star)
        priv = gs_star_widget_get_instance_private (star);
        rating = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
                                                     "GsStarWidget::value"));
-       if (rating == priv->rating &&
-           priv->rating_kind == GS_APP_RATING_KIND_USER)
-               return;
-       priv->rating_kind = GS_APP_RATING_KIND_USER;
        priv->rating = rating;
        g_signal_emit (star, signals[RATING_CHANGED], 0, priv->rating);
        gs_star_widget_refresh (star);
diff --git a/src/gs-star-widget.h b/src/gs-star-widget.h
index 8db1563..8ac11f0 100644
--- a/src/gs-star-widget.h
+++ b/src/gs-star-widget.h
@@ -42,7 +42,6 @@ struct _GsStarWidgetClass
 GtkWidget      *gs_star_widget_new                     (void);
 gint            gs_star_widget_get_rating              (GsStarWidget   *star);
 void            gs_star_widget_set_rating              (GsStarWidget   *star,
-                                                        GsAppRatingKind rating_kind,
                                                         gint            rating);
 void            gs_star_widget_set_icon_size           (GsStarWidget   *star,
                                                         guint           pixel_size);
diff --git a/src/gtk-style-hc.css b/src/gtk-style-hc.css
index 318185b..a44213e 100644
--- a/src/gtk-style-hc.css
+++ b/src/gtk-style-hc.css
@@ -157,10 +157,6 @@ button.star, .button.star {
        color: #000000;
 }
 
-.star-user {
-       color: @theme_selected_bg_color;
-}
-
 .counter-label {
        text-shadow: none;
        color: @theme_selected_fg_color;
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 94c4ea3..a7aca4b 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -161,10 +161,6 @@ button.star, .button.star {
        color: #888a85;
 }
 
-.star-user {
-       color: @theme_selected_bg_color;
-}
-
 .counter-label {
        text-shadow: none;
        color: @theme_selected_fg_color;
diff --git a/src/plugins/gs-plugin-fedora-tagger-ratings.c b/src/plugins/gs-plugin-fedora-tagger-ratings.c
index 6f72a72..9471dd6 100644
--- a/src/plugins/gs-plugin-fedora-tagger-ratings.c
+++ b/src/plugins/gs-plugin-fedora-tagger-ratings.c
@@ -613,7 +613,6 @@ gs_plugin_refine (GsPlugin *plugin,
                                         pkgname, rating, confidence);
                                gs_app_set_rating (app, rating);
                                gs_app_set_rating_confidence (app, confidence);
-                               gs_app_set_rating_kind (app, GS_APP_RATING_KIND_SYSTEM);
                                if (confidence > 50 && rating > 80) {
                                        g_debug ("%s is popular [confidence %i]",
                                                 gs_app_get_source_default (app),
diff --git a/src/plugins/gs-plugin-local-ratings.c b/src/plugins/gs-plugin-local-ratings.c
index b38bfc2..91a0cc3 100644
--- a/src/plugins/gs-plugin-local-ratings.c
+++ b/src/plugins/gs-plugin-local-ratings.c
@@ -235,7 +235,6 @@ gs_plugin_refine (GsPlugin *plugin,
                if (rating != -1) {
                        gs_app_set_rating (app, rating);
                        gs_app_set_rating_confidence (app, 100);
-                       gs_app_set_rating_kind (app, GS_APP_RATING_KIND_USER);
                        if (rating > 80)
                                gs_app_add_kudo (app, GS_APP_KUDO_POPULAR);
                }


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