[gnome-software] gs-review-dialog: Fix suggested-action highlighting of Post button



commit e121974f84b87d66f1286fe2ac4b1c6beb6ad1ad
Author: Philip Withnall <withnall endlessm com>
Date:   Wed Dec 4 14:23:57 2019 +0000

    gs-review-dialog: Fix suggested-action highlighting of Post button
    
    The ‘Post’ button on the review dialog is meant to be highlighted in
    blue as a suggested action, but that wasn’t happening due to logic in
    `GtkDialog`’s `update_suggested_action()` removing that style class for
    any header bar widget which was not the default action.
    
    Fix that by making the ‘Post’ button the default action. Ensure it’s
    insensitive by default.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>

 src/gs-review-dialog.c  | 5 ++---
 src/gs-review-dialog.ui | 7 +++----
 2 files changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-review-dialog.c b/src/gs-review-dialog.c
index 424ced5f..0c607e54 100644
--- a/src/gs-review-dialog.c
+++ b/src/gs-review-dialog.c
@@ -144,7 +144,7 @@ gs_review_dialog_changed_cb (GsReviewDialog *dialog)
        gtk_widget_set_tooltip_text (dialog->post_button, msg);
 
        /* can the user submit this? */
-       gtk_widget_set_sensitive (dialog->post_button, all_okay);
+       gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, all_okay);
 }
 
 static gboolean
@@ -192,8 +192,7 @@ gs_review_dialog_init (GsReviewDialog *dialog)
        g_signal_connect_swapped (buffer, "changed",
                                  G_CALLBACK (gs_review_dialog_changed_cb), dialog);
 
-       gtk_widget_set_sensitive (dialog->post_button, FALSE);
-
+       gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE);
 }
 
 static void
diff --git a/src/gs-review-dialog.ui b/src/gs-review-dialog.ui
index c737c677..b6db5c12 100644
--- a/src/gs-review-dialog.ui
+++ b/src/gs-review-dialog.ui
@@ -5,7 +5,7 @@
   <template class="GsReviewDialog" parent="GtkDialog">
     <action-widgets>
       <action-widget response="cancel">cancel_button</action-widget>
-      <action-widget response="ok">post_button</action-widget>
+      <action-widget response="ok" default="true">post_button</action-widget>
     </action-widgets>
     <property name="title" translatable="yes" comments="Translators: Title of the dialog box where the users 
can write and publish their opinions about the apps.">Post Review</property>
     <property name="modal">True</property>
@@ -34,11 +34,10 @@
             <property name="label" translatable="yes" comments="Translators: A button to publish the 
user&apos;s opinion about the app.">_Post</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
+            <property name="can_default">True</property>
             <property name="receives_default">True</property>
             <property name="use_underline">True</property>
-            <style>
-              <class name="suggested-action"/>
-            </style>
+            <property name="sensitive">False</property>
           </object>
           <packing>
             <property name="pack-type">end</property>


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