[gnome-software] popular tile: Show the star ratings



commit 8a07c176f47c1e1715fbf73ea51a36e56df48571
Author: Kalev Lember <kalevlember gmail com>
Date:   Sun Aug 3 16:08:18 2014 +0200

    popular tile: Show the star ratings
    
    https://bugzilla.gnome.org/show_bug.cgi?id=727998

 src/gs-popular-tile.c |   19 +++++++++++++++++++
 src/popular-tile.ui   |   10 ++++++++++
 2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/src/gs-popular-tile.c b/src/gs-popular-tile.c
index bb5c5e4..305a614 100644
--- a/src/gs-popular-tile.c
+++ b/src/gs-popular-tile.c
@@ -25,6 +25,7 @@
 #include <gtk/gtk.h>
 
 #include "gs-popular-tile.h"
+#include "gs-star-widget.h"
 
 struct _GsPopularTilePrivate
 {
@@ -32,6 +33,7 @@ struct _GsPopularTilePrivate
        GtkWidget       *label;
        GtkWidget       *image;
        GtkWidget       *eventbox;
+       GtkWidget       *stars;
        GtkWidget       *waiting;
 };
 
@@ -114,6 +116,17 @@ gs_popular_tile_set_app (GsPopularTile *tile, GsApp *app)
                return;
        priv->app = g_object_ref (app);
 
+       if (gs_app_get_rating_kind (priv->app) == GS_APP_RATING_KIND_USER) {
+               gs_star_widget_set_rating (GS_STAR_WIDGET (priv->stars),
+                                          GS_APP_RATING_KIND_USER,
+                                          gs_app_get_rating (priv->app));
+       } else {
+               gs_star_widget_set_rating (GS_STAR_WIDGET (priv->stars),
+                                          GS_APP_RATING_KIND_KUDOS,
+                                          gs_app_get_kudos_percentage (priv->app));
+       }
+       gtk_widget_show (priv->stars);
+
         gtk_widget_hide (priv->waiting);
 
        g_signal_connect (priv->app, "notify::state",
@@ -141,8 +154,13 @@ gs_popular_tile_destroy (GtkWidget *widget)
 static void
 gs_popular_tile_init (GsPopularTile *tile)
 {
+       GsPopularTilePrivate *priv;
+
+       priv = gs_popular_tile_get_instance_private (tile);
+
        gtk_widget_set_has_window (GTK_WIDGET (tile), FALSE);
        gtk_widget_init_template (GTK_WIDGET (tile));
+       gs_star_widget_set_icon_size (GS_STAR_WIDGET (priv->stars), 12);
 }
 
 static void
@@ -157,6 +175,7 @@ gs_popular_tile_class_init (GsPopularTileClass *klass)
        gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, label);
        gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, image);
        gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, eventbox);
+       gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, stars);
        gtk_widget_class_bind_template_child_private (widget_class, GsPopularTile, waiting);
 }
 
diff --git a/src/popular-tile.ui b/src/popular-tile.ui
index 48aa028..49e2697 100644
--- a/src/popular-tile.ui
+++ b/src/popular-tile.ui
@@ -80,6 +80,16 @@
                     <property name="fill">True</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GsStarWidget" id="stars">
+                    <property name="visible">False</property>
+                    <property name="halign">center</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                  </packing>
+                </child>
               </object>
             </child>
           </object>


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