[gnome-software] Do not allow the user to submit ratings without a review



commit 7f48ed4447a0e0069e80e5513ca31912c0485de5
Author: Richard Hughes <richard hughsie com>
Date:   Thu Feb 18 16:58:36 2016 +0000

    Do not allow the user to submit ratings without a review
    
    Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=762276

 src/gs-review-dialog.c |    1 +
 src/gs-shell-details.c |   45 ---------------------------------------------
 src/gs-star-widget.c   |   16 ++++++++++++++++
 src/gs-star-widget.h   |    2 ++
 4 files changed, 19 insertions(+), 45 deletions(-)
---
diff --git a/src/gs-review-dialog.c b/src/gs-review-dialog.c
index a00dc9e..4af9440 100644
--- a/src/gs-review-dialog.c
+++ b/src/gs-review-dialog.c
@@ -147,6 +147,7 @@ gs_review_dialog_init (GsReviewDialog *dialog)
                                                  dialog);
 
        /* update UI */
+       gs_star_widget_set_interactive (GS_STAR_WIDGET (dialog->star), TRUE);
        g_signal_connect_swapped (dialog->star, "rating-changed",
                                  G_CALLBACK (gs_review_dialog_changed_cb), dialog);
        g_signal_connect_swapped (dialog->summary_entry, "notify::text",
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index d47eb2d..22b6140 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -1398,24 +1398,6 @@ gs_shell_details_app_history_button_cb (GtkWidget *widget, GsShellDetails *self)
 }
 
 /**
- * gs_shell_details_app_set_ratings_cb:
- **/
-static void
-gs_shell_details_app_set_ratings_cb (GObject *source,
-                               GAsyncResult *res,
-                               gpointer user_data)
-{
-       GsPluginLoader *plugin_loader = GS_PLUGIN_LOADER (source);
-       GsShellDetails *self = GS_SHELL_DETAILS (user_data);
-       g_autoptr(GError) error = NULL;
-
-       if (!gs_plugin_loader_app_action_finish (plugin_loader, res, &error)) {
-               g_warning ("failed to set rating %s: %s",
-                          gs_app_get_id (self->app), error->message);
-       }
-}
-
-/**
  * gs_shell_details_write_review_cb:
  **/
 static void
@@ -1455,28 +1437,6 @@ gs_shell_details_write_review_cb (GtkButton *button,
        gtk_widget_destroy (dialog);
 }
 
-/**
- * gs_shell_details_rating_changed_cb:
- **/
-static void
-gs_shell_details_rating_changed_cb (GsStarWidget *star,
-                                   guint rating,
-                                   GsShellDetails *self)
-{
-       g_debug ("%s rating changed from %i%% to %i%%",
-                gs_app_get_id (self->app),
-                gs_app_get_rating (self->app),
-                rating);
-
-       /* call into the plugins to set the new value */
-       gs_app_set_rating (self->app, rating);
-       gs_plugin_loader_app_action_async (self->plugin_loader, self->app,
-                                          GS_PLUGIN_LOADER_ACTION_SET_RATING,
-                                          self->cancellable,
-                                          gs_shell_details_app_set_ratings_cb,
-                                          self);
-}
-
 static void
 gs_shell_details_app_installed (GsPage *page, GsApp *app)
 {
@@ -1517,11 +1477,6 @@ gs_shell_details_setup (GsShellDetails *self,
                          G_CALLBACK (gs_shell_details_write_review_cb),
                          self);
 
-       /* set up star ratings */
-       g_signal_connect (self->star, "rating-changed",
-                         G_CALLBACK (gs_shell_details_rating_changed_cb),
-                         self);
-
        /* setup details */
        g_signal_connect (self->button_install, "clicked",
                          G_CALLBACK (gs_shell_details_app_install_button_cb),
diff --git a/src/gs-star-widget.c b/src/gs-star-widget.c
index 3537c62..1b4db71 100644
--- a/src/gs-star-widget.c
+++ b/src/gs-star-widget.c
@@ -28,6 +28,7 @@
 
 typedef struct
 {
+       gboolean         interactive;
        gint             rating;
        GtkWidget       *button1;
        GtkWidget       *button2;
@@ -101,6 +102,18 @@ gs_star_widget_set_icon_size (GsStarWidget *star, guint pixel_size)
 }
 
 /**
+ * gs_star_widget_set_interactive:
+ **/
+void
+gs_star_widget_set_interactive (GsStarWidget *star, gboolean interactive)
+{
+       GsStarWidgetPrivate *priv;
+       g_return_if_fail (GS_IS_STAR_WIDGET (star));
+       priv = gs_star_widget_get_instance_private (star);
+       priv->interactive = interactive;
+}
+
+/**
  * gs_star_widget_refresh:
  **/
 static void
@@ -158,6 +171,9 @@ gs_star_widget_button_clicked_cb (GtkButton *button, GsStarWidget *star)
        gint rating;
 
        priv = gs_star_widget_get_instance_private (star);
+       if (!priv->interactive)
+               return;
+
        rating = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (button),
                                                     "GsStarWidget::value"));
        priv->rating = rating;
diff --git a/src/gs-star-widget.h b/src/gs-star-widget.h
index 8ac11f0..60b19e2 100644
--- a/src/gs-star-widget.h
+++ b/src/gs-star-widget.h
@@ -45,6 +45,8 @@ void           gs_star_widget_set_rating              (GsStarWidget   *star,
                                                         gint            rating);
 void            gs_star_widget_set_icon_size           (GsStarWidget   *star,
                                                         guint           pixel_size);
+void            gs_star_widget_set_interactive         (GsStarWidget   *star,
+                                                        gboolean        interactive);
 
 G_END_DECLS
 


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