[gnome-software] Show the 'More Reviews' button in the details panel
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software] Show the 'More Reviews' button in the details panel
- Date: Wed, 29 Jun 2016 08:16:29 +0000 (UTC)
commit 4d470110ca35b29cd05854228d91cbd5e99356ee
Author: Richard Hughes <richard hughsie com>
Date: Wed Jun 29 09:15:16 2016 +0100
Show the 'More Reviews' button in the details panel
This only shows when there are more than 4 reviews, and once clicked makes all
the reviews visible.
src/gs-shell-details.c | 22 +++++++++++++++++++++-
src/plugins/gs-plugin-odrs.c | 2 +-
2 files changed, 22 insertions(+), 2 deletions(-)
---
diff --git a/src/gs-shell-details.c b/src/gs-shell-details.c
index 3321ac6..3599aa9 100644
--- a/src/gs-shell-details.c
+++ b/src/gs-shell-details.c
@@ -39,6 +39,9 @@
#include "gs-review-dialog.h"
#include "gs-review-row.h"
+/* the number of reviews to show before clicking the 'More Reviews' button */
+#define SHOW_NR_REVIEWS_INITIAL 4
+
static void gs_shell_details_refresh_all (GsShellDetails *self);
typedef enum {
@@ -76,6 +79,7 @@ struct _GsShellDetails
GtkWidget *button_details_website;
GtkWidget *button_install;
GtkWidget *button_remove;
+ GtkWidget *button_more_reviews;
GtkWidget *infobar_details_app_norepo;
GtkWidget *infobar_details_app_repo;
GtkWidget *infobar_details_package_baseos;
@@ -1315,6 +1319,10 @@ gs_shell_details_refresh_reviews (GsShellDetails *self)
}
}
+ /* only show the button if there are more to show */
+ gtk_widget_set_visible (self->button_more_reviews,
+ n_reviews > SHOW_NR_REVIEWS_INITIAL);
+
/* add all the reviews */
gs_container_remove_all (GTK_CONTAINER (self->list_box_reviews));
reviews = gs_app_get_reviews (self->app);
@@ -1333,7 +1341,7 @@ gs_shell_details_refresh_reviews (GsShellDetails *self)
}
gs_review_row_set_actions (GS_REVIEW_ROW (row), actions);
gtk_container_add (GTK_CONTAINER (self->list_box_reviews), row);
- gtk_widget_show (row);
+ gtk_widget_set_visible (row, i < SHOW_NR_REVIEWS_INITIAL);
}
/* show the button only if the user never reviewed */
@@ -1707,6 +1715,14 @@ gs_shell_details_app_removed (GsPage *page, GsApp *app)
gs_shell_details_reload (page);
}
+static void
+gs_shell_details_more_reviews_button_cb (GtkWidget *widget, GsShellDetails *self)
+{
+ gtk_container_foreach (GTK_CONTAINER (self->list_box_reviews),
+ (GtkCallback) gtk_widget_show, NULL);
+ gtk_widget_set_visible (self->button_more_reviews, FALSE);
+}
+
void
gs_shell_details_setup (GsShellDetails *self,
GsShell *shell,
@@ -1739,6 +1755,9 @@ gs_shell_details_setup (GsShellDetails *self,
g_signal_connect (self->button_remove, "clicked",
G_CALLBACK (gs_shell_details_app_remove_button_cb),
self);
+ g_signal_connect (self->button_more_reviews, "clicked",
+ G_CALLBACK (gs_shell_details_more_reviews_button_cb),
+ self);
g_signal_connect (self->label_details_updated_value, "activate-link",
G_CALLBACK (gs_shell_details_history_cb),
self);
@@ -1815,6 +1834,7 @@ gs_shell_details_class_init (GsShellDetailsClass *klass)
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_details_website);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_install);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_remove);
+ gtk_widget_class_bind_template_child (widget_class, GsShellDetails, button_more_reviews);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, infobar_details_app_norepo);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, infobar_details_app_repo);
gtk_widget_class_bind_template_child (widget_class, GsShellDetails, infobar_details_package_baseos);
diff --git a/src/plugins/gs-plugin-odrs.c b/src/plugins/gs-plugin-odrs.c
index 8cef273..e7da265 100644
--- a/src/plugins/gs-plugin-odrs.c
+++ b/src/plugins/gs-plugin-odrs.c
@@ -31,7 +31,7 @@
*/
#define ODRS_REVIEW_CACHE_AGE_MAX 237000 /* 1 week */
-#define ODRS_REVIEW_NUMBER_RESULTS_MAX 5
+#define ODRS_REVIEW_NUMBER_RESULTS_MAX 20
struct GsPluginData {
GSettings *settings;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]