[gnome-software/wip/rancell/reviews-3-18] Add a write review button instead of hijacking the existing rating system



commit 31d77c5c77d43559d93d9fbd70cc5f27d9ce45d4
Author: Robert Ancell <robert ancell canonical com>
Date:   Thu Jan 28 22:11:36 2016 +1300

    Add a write review button instead of hijacking the existing rating system

 src/gs-shell-details.c  |   28 +++++++++++++++++++++-------
 src/gs-shell-details.ui |   10 ++++++++++
 2 files changed, 31 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 8808c58..924bc09 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -88,6 +88,7 @@ struct _GsShellDetails
        GtkWidget               *label_pending;
        GtkWidget               *list_box_addons;
        GtkWidget               *box_reviews;
+       GtkWidget               *button_review;
        GtkWidget               *list_box_reviews;
        GtkWidget               *scrolledwindow_details;
        GtkWidget               *spinner_details;
@@ -878,6 +879,9 @@ gs_shell_details_refresh_reviews (GsShellDetails *self)
 
        gs_container_remove_all (GTK_CONTAINER (self->list_box_reviews));
 
+       /* If you haven't reviewed it, do it now */
+       gtk_widget_set_visible (self->button_review, !gs_app_get_self_review (self->app));
+
        reviews = gs_app_get_reviews (self->app);
        for (i = 0; i < reviews->len; i++) {
                GsAppReview *review;
@@ -1238,18 +1242,16 @@ gs_shell_details_app_set_review_cb (GObject *source,
 }
 
 /**
- * gs_shell_details_rating_changed_cb:
+ * gs_shell_details_write_review_cb:
  **/
 static void
-gs_shell_details_rating_changed_cb (GsStarWidget *star,
-                                   guint rating,
-                                   GsShellDetails *self)
+gs_shell_details_write_review_cb (GtkButton *button,
+                                 GsShellDetails *self)
 {
        GtkWidget *dialog;
        GtkResponseType response;
 
        dialog = gs_app_review_dialog_new ();
-       gs_app_review_dialog_set_rating (GS_APP_REVIEW_DIALOG (dialog), rating);
 
        gtk_window_set_transient_for (GTK_WINDOW (dialog), gs_shell_get_window (self->shell));
        response = gtk_dialog_run (GTK_DIALOG (dialog));
@@ -1277,7 +1279,16 @@ gs_shell_details_rating_changed_cb (GsStarWidget *star,
                                                   self);
        }
        gtk_widget_destroy (dialog);
-#if 0
+}
+
+/**
+ * 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),
@@ -1291,7 +1302,6 @@ gs_shell_details_rating_changed_cb (GsStarWidget *star,
                                           self->cancellable,
                                           gs_shell_details_app_set_ratings_cb,
                                           self);
-#endif
 }
 
 static void
@@ -1329,6 +1339,9 @@ gs_shell_details_setup (GsShellDetails *self,
        /* Show review widgets if we have plugins that provide them */
        if (gs_plugin_loader_get_supports_reviews (plugin_loader))
                gtk_widget_set_visible (self->box_reviews, TRUE);
+       g_signal_connect (self->button_review, "clicked",
+                         G_CALLBACK (gs_shell_details_write_review_cb),
+                         self);
 
        /* set up star ratings */
        self->star = gs_star_widget_new ();
@@ -1436,6 +1449,7 @@ gs_shell_details_class_init (GsShellDetailsClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, label_pending);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, list_box_addons);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, box_reviews);
+       gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_review);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, list_box_reviews);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, scrolledwindow_details);
        gtk_widget_class_bind_template_child (widget_class, GsShellDetails, spinner_details);
diff --git a/src/gs-shell-details.ui b/src/gs-shell-details.ui
index c4c1571..028ce17 100644
--- a/src/gs-shell-details.ui
+++ b/src/gs-shell-details.ui
@@ -1042,6 +1042,16 @@
                           </object>
                         </child>
                         <child>
+                          <object class="GtkButton" id="button_review">
+                            <property name="use_underline">True</property>
+                            <property name="label" translatable="yes">_Write Review</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">False</property>
+                            <property name="halign">start</property>
+                            <property name="valign">start</property>
+                          </object>
+                        </child>
+                        <child>
                           <object class="GtkListBox" id="list_box_reviews">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>


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