[gnome-software] Ensure that the application ratings are set correctly



commit e80d751ae0768a8969ff52e1cfc29a692a79bda0
Author: Richard Hughes <richard hughsie com>
Date:   Thu Dec 19 09:56:46 2013 +0000

    Ensure that the application ratings are set correctly

 src/gs-app-widget.c  |    3 +++
 src/gs-app.c         |    2 ++
 src/gs-star-widget.c |    4 +++-
 3 files changed, 8 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-app-widget.c b/src/gs-app-widget.c
index eef42fe..d825634 100644
--- a/src/gs-app-widget.c
+++ b/src/gs-app-widget.c
@@ -281,6 +281,9 @@ gs_app_widget_set_app (GsAppWidget *app_widget, GsApp *app)
        g_signal_connect_object (app_widget->priv->app, "notify::state",
                                 G_CALLBACK (gs_app_widget_notify_props_changed_cb),
                                 app_widget, 0);
+       g_signal_connect_object (app_widget->priv->app, "notify::rating",
+                                G_CALLBACK (gs_app_widget_notify_props_changed_cb),
+                                app_widget, 0);
        gs_app_widget_refresh (app_widget);
 }
 
diff --git a/src/gs-app.c b/src/gs-app.c
index 2e6adac..f176e94 100644
--- a/src/gs-app.c
+++ b/src/gs-app.c
@@ -1255,6 +1255,7 @@ gs_app_set_rating (GsApp *app, gint rating)
 {
        g_return_if_fail (GS_IS_APP (app));
        app->priv->rating = rating;
+       g_object_notify (G_OBJECT (app), "rating");
 }
 
 /**
@@ -1275,6 +1276,7 @@ gs_app_set_rating_kind (GsApp *app, GsAppRatingKind rating_kind)
 {
        g_return_if_fail (GS_IS_APP (app));
        app->priv->rating_kind = rating_kind;
+       g_object_notify (G_OBJECT (app), "rating");
 }
 
 /**
diff --git a/src/gs-star-widget.c b/src/gs-star-widget.c
index 82e5e91..79c185f 100644
--- a/src/gs-star-widget.c
+++ b/src/gs-star-widget.c
@@ -159,8 +159,10 @@ 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)
+       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);


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