[gnome-software: 9/18] gs-review-row: Use a new enum for review actions
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 9/18] gs-review-row: Use a new enum for review actions
- Date: Wed, 9 Jun 2021 13:45:49 +0000 (UTC)
commit 3f60f5f59e8ebe7f01477deb942464e0e552ac0f
Author: Philip Withnall <pwithnall endlessos org>
Date: Tue May 18 16:59:34 2021 +0100
gs-review-row: Use a new enum for review actions
This makes it a bit easier to remove the old review actions from
`GsPluginAction` in a few commits’ time.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
src/gs-details-page.c | 27 +++++++++++++--------------
src/gs-moderate-page.c | 18 +++++++++---------
src/gs-review-row.c | 26 +++++++++++++-------------
src/gs-review-row.h | 21 +++++++++++++++++++++
4 files changed, 56 insertions(+), 36 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index ce11df501..aeee6f1b5 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1520,7 +1520,7 @@ static void gs_details_page_refresh_reviews (GsDetailsPage *self);
static void
gs_details_page_review_button_clicked_cb (GsReviewRow *row,
- GsPluginAction action,
+ GsReviewAction action,
GsDetailsPage *self)
{
AsReview *review = gs_review_row_get_review (row);
@@ -1530,27 +1530,27 @@ gs_details_page_review_button_clicked_cb (GsReviewRow *row,
/* FIXME: Make this async */
switch (action) {
- case GS_PLUGIN_ACTION_REVIEW_UPVOTE:
+ case GS_REVIEW_ACTION_UPVOTE:
gs_odrs_provider_upvote_review (self->odrs_provider, self->app,
review, self->cancellable,
&local_error);
break;
- case GS_PLUGIN_ACTION_REVIEW_DOWNVOTE:
+ case GS_REVIEW_ACTION_DOWNVOTE:
gs_odrs_provider_downvote_review (self->odrs_provider, self->app,
review, self->cancellable,
&local_error);
break;
- case GS_PLUGIN_ACTION_REVIEW_REPORT:
+ case GS_REVIEW_ACTION_REPORT:
gs_odrs_provider_report_review (self->odrs_provider, self->app,
review, self->cancellable,
&local_error);
break;
- case GS_PLUGIN_ACTION_REVIEW_REMOVE:
+ case GS_REVIEW_ACTION_REMOVE:
gs_odrs_provider_remove_review (self->odrs_provider, self->app,
review, self->cancellable,
&local_error);
break;
- case GS_PLUGIN_ACTION_REVIEW_DISMISS:
+ case GS_REVIEW_ACTION_DISMISS:
/* The dismiss action is only used from the moderate page. */
default:
g_assert_not_reached ();
@@ -1575,12 +1575,11 @@ gs_details_page_refresh_reviews (GsDetailsPage *self)
guint n_reviews = 0;
guint64 possible_actions = 0;
guint i;
- GsPluginAction all_actions[] = {
- GS_PLUGIN_ACTION_REVIEW_UPVOTE,
- GS_PLUGIN_ACTION_REVIEW_DOWNVOTE,
- GS_PLUGIN_ACTION_REVIEW_REPORT,
- GS_PLUGIN_ACTION_REVIEW_SUBMIT,
- GS_PLUGIN_ACTION_REVIEW_REMOVE,
+ GsReviewAction all_actions[] = {
+ GS_REVIEW_ACTION_UPVOTE,
+ GS_REVIEW_ACTION_DOWNVOTE,
+ GS_REVIEW_ACTION_REPORT,
+ GS_REVIEW_ACTION_REMOVE,
};
/* nothing to show */
@@ -1661,10 +1660,10 @@ gs_details_page_refresh_reviews (GsDetailsPage *self)
g_signal_connect (row, "button-clicked",
G_CALLBACK (gs_details_page_review_button_clicked_cb), self);
if (as_review_get_flags (review) & AS_REVIEW_FLAG_SELF) {
- actions = possible_actions & 1 << GS_PLUGIN_ACTION_REVIEW_REMOVE;
+ actions = possible_actions & 1 << GS_REVIEW_ACTION_REMOVE;
show_review_button = FALSE;
} else {
- actions = possible_actions & ~(1u << GS_PLUGIN_ACTION_REVIEW_REMOVE);
+ actions = possible_actions & ~(1u << GS_REVIEW_ACTION_REMOVE);
}
gs_review_row_set_actions (GS_REVIEW_ROW (row), actions);
gtk_container_add (GTK_CONTAINER (self->list_box_reviews), row);
diff --git a/src/gs-moderate-page.c b/src/gs-moderate-page.c
index fa009e5b4..46ca7b50f 100644
--- a/src/gs-moderate-page.c
+++ b/src/gs-moderate-page.c
@@ -87,27 +87,27 @@ gs_moderate_page_review_clicked_cb (GsReviewRow *row,
/* FIXME: Make this async */
switch (action) {
- case GS_PLUGIN_ACTION_REVIEW_UPVOTE:
+ case GS_REVIEW_ACTION_UPVOTE:
gs_odrs_provider_upvote_review (self->odrs_provider, app,
review, self->cancellable,
&local_error);
break;
- case GS_PLUGIN_ACTION_REVIEW_DOWNVOTE:
+ case GS_REVIEW_ACTION_DOWNVOTE:
gs_odrs_provider_downvote_review (self->odrs_provider, app,
review, self->cancellable,
&local_error);
break;
- case GS_PLUGIN_ACTION_REVIEW_REPORT:
+ case GS_REVIEW_ACTION_REPORT:
gs_odrs_provider_report_review (self->odrs_provider, app,
review, self->cancellable,
&local_error);
break;
- case GS_PLUGIN_ACTION_REVIEW_DISMISS:
+ case GS_REVIEW_ACTION_DISMISS:
gs_odrs_provider_dismiss_review (self->odrs_provider, app,
review, self->cancellable,
&local_error);
break;
- case GS_PLUGIN_ACTION_REVIEW_REMOVE:
+ case GS_REVIEW_ACTION_REMOVE:
gs_odrs_provider_remove_review (self->odrs_provider, app,
review, self->cancellable,
&local_error);
@@ -166,10 +166,10 @@ gs_moderate_page_add_app (GsModeratePage *self, GsApp *app)
gtk_widget_set_margin_start (row, 250);
gtk_widget_set_margin_end (row, 250);
gs_review_row_set_actions (GS_REVIEW_ROW (row),
- 1 << GS_PLUGIN_ACTION_REVIEW_UPVOTE |
- 1 << GS_PLUGIN_ACTION_REVIEW_DOWNVOTE |
- 1 << GS_PLUGIN_ACTION_REVIEW_DISMISS |
- 1 << GS_PLUGIN_ACTION_REVIEW_REPORT);
+ 1 << GS_REVIEW_ACTION_UPVOTE |
+ 1 << GS_REVIEW_ACTION_DOWNVOTE |
+ 1 << GS_REVIEW_ACTION_DISMISS |
+ 1 << GS_REVIEW_ACTION_REPORT);
g_signal_connect (row, "button-clicked",
G_CALLBACK (gs_moderate_page_review_clicked_cb), self);
g_object_set_data_full (G_OBJECT (row), "GsApp",
diff --git a/src/gs-review-row.c b/src/gs-review-row.c
index a178e6ff2..c80b43b65 100644
--- a/src/gs-review-row.c
+++ b/src/gs-review-row.c
@@ -76,23 +76,23 @@ gs_review_row_refresh (GsReviewRow *row)
priv->actions = 0;
/* set actions up */
- if ((priv->actions & (1 << GS_PLUGIN_ACTION_REVIEW_UPVOTE |
- 1 << GS_PLUGIN_ACTION_REVIEW_DOWNVOTE |
- 1 << GS_PLUGIN_ACTION_REVIEW_DISMISS)) == 0) {
+ if ((priv->actions & (1 << GS_REVIEW_ACTION_UPVOTE |
+ 1 << GS_REVIEW_ACTION_DOWNVOTE |
+ 1 << GS_REVIEW_ACTION_DISMISS)) == 0) {
gtk_widget_set_visible (priv->box_voting, FALSE);
} else {
gtk_widget_set_visible (priv->box_voting, TRUE);
gtk_widget_set_visible (priv->button_yes,
- priv->actions & 1 << GS_PLUGIN_ACTION_REVIEW_UPVOTE);
+ priv->actions & 1 << GS_REVIEW_ACTION_UPVOTE);
gtk_widget_set_visible (priv->button_no,
- priv->actions & 1 << GS_PLUGIN_ACTION_REVIEW_DOWNVOTE);
+ priv->actions & 1 << GS_REVIEW_ACTION_DOWNVOTE);
gtk_widget_set_visible (priv->button_dismiss,
- priv->actions & 1 << GS_PLUGIN_ACTION_REVIEW_DISMISS);
+ priv->actions & 1 << GS_REVIEW_ACTION_DISMISS);
}
gtk_widget_set_visible (priv->button_remove,
- priv->actions & 1 << GS_PLUGIN_ACTION_REVIEW_REMOVE);
+ priv->actions & 1 << GS_REVIEW_ACTION_REMOVE);
gtk_widget_set_visible (priv->button_report,
- priv->actions & 1 << GS_PLUGIN_ACTION_REVIEW_REPORT);
+ priv->actions & 1 << GS_REVIEW_ACTION_REPORT);
/* mark insensitive if no network */
if (priv->network_available) {
@@ -189,14 +189,14 @@ static void
gs_review_row_button_clicked_upvote_cb (GtkButton *button, GsReviewRow *row)
{
g_signal_emit (row, signals[SIGNAL_BUTTON_CLICKED], 0,
- GS_PLUGIN_ACTION_REVIEW_UPVOTE);
+ GS_REVIEW_ACTION_UPVOTE);
}
static void
gs_review_row_button_clicked_downvote_cb (GtkButton *button, GsReviewRow *row)
{
g_signal_emit (row, signals[SIGNAL_BUTTON_CLICKED], 0,
- GS_PLUGIN_ACTION_REVIEW_DOWNVOTE);
+ GS_REVIEW_ACTION_DOWNVOTE);
}
static void
@@ -204,7 +204,7 @@ gs_review_row_confirm_cb (GtkDialog *dialog, gint response_id, GsReviewRow *row)
{
if (response_id == GTK_RESPONSE_YES) {
g_signal_emit (row, signals[SIGNAL_BUTTON_CLICKED], 0,
- GS_PLUGIN_ACTION_REVIEW_REPORT);
+ GS_REVIEW_ACTION_REPORT);
}
gtk_widget_destroy (GTK_WIDGET (dialog));
}
@@ -258,14 +258,14 @@ static void
gs_review_row_button_clicked_dismiss_cb (GtkButton *button, GsReviewRow *row)
{
g_signal_emit (row, signals[SIGNAL_BUTTON_CLICKED], 0,
- GS_PLUGIN_ACTION_REVIEW_DISMISS);
+ GS_REVIEW_ACTION_DISMISS);
}
static void
gs_review_row_button_clicked_remove_cb (GtkButton *button, GsReviewRow *row)
{
g_signal_emit (row, signals[SIGNAL_BUTTON_CLICKED], 0,
- GS_PLUGIN_ACTION_REVIEW_REMOVE);
+ GS_REVIEW_ACTION_REMOVE);
}
AsReview *
diff --git a/src/gs-review-row.h b/src/gs-review-row.h
index 8f952ba0d..48139ce96 100644
--- a/src/gs-review-row.h
+++ b/src/gs-review-row.h
@@ -14,6 +14,27 @@
G_BEGIN_DECLS
+/**
+ * GsReviewAction:
+ * @GS_REVIEW_ACTION_UPVOTE: Add a vote to the review.
+ * @GS_REVIEW_ACTION_DOWNVOTE: Remove a vote from the review.
+ * @GS_REVIEW_ACTION_DISMISS: Dismiss (ignore) the review when moderating.
+ * @GS_REVIEW_ACTION_REPORT: Report the review for inappropriate content.
+ * @GS_REVIEW_ACTION_REMOVE: Remove one of your own reviews.
+ *
+ * Actions which can be performed on a review.
+ *
+ * Since: 41
+ */
+typedef enum
+{
+ GS_REVIEW_ACTION_UPVOTE,
+ GS_REVIEW_ACTION_DOWNVOTE,
+ GS_REVIEW_ACTION_DISMISS,
+ GS_REVIEW_ACTION_REPORT,
+ GS_REVIEW_ACTION_REMOVE,
+} GsReviewAction;
+
#define GS_TYPE_REVIEW_ROW (gs_review_row_get_type ())
G_DECLARE_DERIVABLE_TYPE (GsReviewRow, gs_review_row, GS, REVIEW_ROW, GtkListBoxRow)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]