[gnome-software] Show a confirmation dialog before reporting a review



commit 013999a8318809d90b389b56076a536973a06980
Author: Richard Hughes <richard hughsie com>
Date:   Tue Feb 23 16:06:52 2016 +0000

    Show a confirmation dialog before reporting a review
    
    This matches the new mockups from Allan.

 src/gs-review-row.c  |   52 ++++++++++++++++++++++++++++++++++++++++++++++++-
 src/gs-review-row.ui |   24 +++++++++++++++++++---
 src/gtk-style.css    |    4 +++
 3 files changed, 74 insertions(+), 6 deletions(-)
---
diff --git a/src/gs-review-row.c b/src/gs-review-row.c
index 496ca4f..4ca4989 100644
--- a/src/gs-review-row.c
+++ b/src/gs-review-row.c
@@ -184,10 +184,58 @@ gs_review_row_button_clicked_downvote_cb (GtkButton *button, GsReviewRow *row)
 }
 
 static void
+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_REVIEW_ACTION_REPORT);
+       }
+       gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+static void
 gs_review_row_button_clicked_report_cb (GtkButton *button, GsReviewRow *row)
 {
-       g_signal_emit (row, signals[SIGNAL_BUTTON_CLICKED], 0,
-                      GS_REVIEW_ACTION_REPORT);
+       GtkWidget *dialog;
+       GtkWidget *toplevel;
+       GtkWidget *widget;
+       g_autoptr(GString) str = NULL;
+
+       str = g_string_new ("");
+
+       /* TRANSLATORS: we explain what the action is going to do */
+       g_string_append (str, _("You can report reviews for abusive, rude, or "
+                               "discriminatory behavior."));
+       g_string_append (str, " ");
+
+       /* TRANSLATORS: we ask the user if they really want to do this */
+       g_string_append (str, _("Once reported, a review will be hidden until "
+                               "it has been checked by an administrator."));
+
+       toplevel = gtk_widget_get_toplevel (GTK_WIDGET (button));
+       dialog = gtk_message_dialog_new (GTK_WINDOW (toplevel),
+                                        GTK_DIALOG_MODAL |
+                                        GTK_DIALOG_DESTROY_WITH_PARENT |
+                                        GTK_DIALOG_USE_HEADER_BAR,
+                                        GTK_MESSAGE_QUESTION,
+                                        GTK_BUTTONS_CANCEL,
+                                        "%s",
+                                        /* TRANSLATORS: window title when
+                                         * reporting a user-submitted review
+                                         * for moderation */
+                                        _("Report Review?"));
+       widget = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                       /* TRANSLATORS: button text when
+                                        * sending a review for moderation */
+                                       _("Report"),
+                                       GTK_RESPONSE_YES);
+       gtk_style_context_add_class (gtk_widget_get_style_context (widget),
+                                    "destructive-action");
+       gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+                                                 "%s", str->str);
+       g_signal_connect (dialog, "response",
+                         G_CALLBACK (gs_review_row_confirm_cb), row);
+       gtk_window_present (GTK_WINDOW (dialog));
 }
 
 static void
diff --git a/src/gs-review-row.ui b/src/gs-review-row.ui
index b018f91..f825baf 100644
--- a/src/gs-review-row.ui
+++ b/src/gs-review-row.ui
@@ -98,6 +98,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="spacing">9</property>
+            <property name="halign">start</property>
             <child>
               <object class="GtkLabel">
                 <property name="visible">True</property>
@@ -119,6 +120,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <style>
+                  <class name="naked-button"/>
+                </style>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -132,6 +136,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <style>
+                  <class name="naked-button"/>
+                </style>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -145,6 +152,9 @@
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
+                <style>
+                  <class name="naked-button"/>
+                </style>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -167,11 +177,14 @@
             <property name="halign">end</property>
             <child>
               <object class="GtkButton" id="button_report">
-                <property name="label" translatable="yes">Report Abuse</property>
+                <property name="label" translatable="yes">Report…</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="width_request">150</property>
+                <property name="halign">end</property>
+                <style>
+                  <class name="naked-button"/>
+                </style>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -181,11 +194,14 @@
             </child>
             <child>
               <object class="GtkButton" id="button_remove">
-                <property name="label" translatable="yes">Remove</property>
+                <property name="label" translatable="yes">Remove…</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="width_request">150</property>
+                <property name="halign">end</property>
+                <style>
+                  <class name="naked-button"/>
+                </style>
               </object>
               <packing>
                 <property name="expand">False</property>
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 79b6224..8f30f14 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -198,6 +198,10 @@ button.star, .button.star {
        outline-offset: -1px;
 }
 
+.naked-button {
+       all: unset;
+}
+
 /* for the review dialog */
 .star-enabled {
        color: @theme_selected_bg_color;


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