[gnome-software] Show a guide label for the different star values



commit 4144bbc1d1f2b82979d211ddfdc740f2b1cecda2
Author: Richard Hughes <richard hughsie com>
Date:   Fri Feb 19 16:34:44 2016 +0000

    Show a guide label for the different star values
    
    Not all cultures use 5-stars == awesome.

 src/gs-review-dialog.c  |   40 ++++++++++++++++++++++++++++++++++++++++
 src/gs-review-dialog.ui |   17 +++++++++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-review-dialog.c b/src/gs-review-dialog.c
index dcf2040..264d38e 100644
--- a/src/gs-review-dialog.c
+++ b/src/gs-review-dialog.c
@@ -39,6 +39,7 @@ struct _GsReviewDialog
        GtkDialog        parent_instance;
 
        GtkWidget       *star;
+       GtkWidget       *label_rating_desc;
        GtkWidget       *summary_entry;
        GtkWidget       *post_button;
        GtkWidget       *text_view;
@@ -79,12 +80,50 @@ gs_review_dialog_get_text (GsReviewDialog *dialog)
 }
 
 static void
+gs_review_dialog_update_review_comment (GsReviewDialog *dialog)
+{
+       const gchar *msg = NULL;
+       gint perc;
+
+       /* update the rating description */
+       perc = gs_star_widget_get_rating (GS_STAR_WIDGET (dialog->star));
+       if (perc == 20) {
+               /* TRANSLATORS: lighthearted star rating description;
+                *              A really bad application */
+               msg = _("Hate it");
+       } else if (perc == 40) {
+               /* TRANSLATORS: lighthearted star rating description;
+                *              Not a great application */
+               msg = _("Don't like it");
+       } else if (perc == 60) {
+               /* TRANSLATORS: lighthearted star rating description;
+                *              A fairly-good application */
+               msg = _("It's OK");
+       } else if (perc == 80) {
+               /* TRANSLATORS: lighthearted star rating description;
+                *              A good application */
+               msg = _("Like it");
+       } else if (perc == 100) {
+               /* TRANSLATORS: lighthearted star rating description;
+                *              A really awesome application */
+               msg = _("Love it");
+       } else {
+               /* just reserve space */
+               msg = "";
+       }
+       gtk_label_set_label (GTK_LABEL (dialog->label_rating_desc), msg);
+}
+
+static void
 gs_review_dialog_changed_cb (GsReviewDialog *dialog)
 {
        GtkTextBuffer *buffer;
        gboolean all_okay = TRUE;
        const gchar *msg = NULL;
 
+       /* update review text */
+       gs_review_dialog_update_review_comment (dialog);
+
        /* require rating, summary and long review */
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->text_view));
        if (dialog->timer_id != 0) {
@@ -182,6 +221,7 @@ gs_review_dialog_class_init (GsReviewDialogClass *klass)
        gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/Software/gs-review-dialog.ui");
 
        gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, star);
+       gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, label_rating_desc);
        gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, summary_entry);
        gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, text_view);
        gtk_widget_class_bind_template_child (widget_class, GsReviewDialog, post_button);
diff --git a/src/gs-review-dialog.ui b/src/gs-review-dialog.ui
index 7a1ffb5..7e90f00 100644
--- a/src/gs-review-dialog.ui
+++ b/src/gs-review-dialog.ui
@@ -105,6 +105,23 @@
                     <property name="position">2</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkLabel" id="label_rating_desc">
+                    <property name="height_request">30</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label"></property>
+                    <property name="xalign">0.5</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="expand">False</property>


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