[gnome-software: 2/3] age-rating-context-dialog: Sort unimportant attributes last




commit 5daac62171e9f74dbe26a0a93deeff1cf460c142
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Feb 8 15:16:55 2022 +0100

    age-rating-context-dialog: Sort unimportant attributes last
    
    This sorts neutral attributes before unimportant ones to restore the
    desired behavior since the enum's ordering was changed in the previous
    commit.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1631

 src/gs-age-rating-context-dialog.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/src/gs-age-rating-context-dialog.c b/src/gs-age-rating-context-dialog.c
index c904338ec..d1fa9c30c 100644
--- a/src/gs-age-rating-context-dialog.c
+++ b/src/gs-age-rating-context-dialog.c
@@ -574,6 +574,14 @@ attributes_compare (GsAgeRatingAttribute *attributes1,
                     GsAgeRatingAttribute *attributes2)
 {
        if (attributes1->importance != attributes2->importance) {
+               /* Sort neutral attributes before unimportant ones. */
+               if (attributes1->importance == GS_CONTEXT_DIALOG_ROW_IMPORTANCE_NEUTRAL &&
+                   attributes2->importance == GS_CONTEXT_DIALOG_ROW_IMPORTANCE_UNIMPORTANT)
+                       return -1;
+               if (attributes1->importance == GS_CONTEXT_DIALOG_ROW_IMPORTANCE_UNIMPORTANT &&
+                   attributes2->importance == GS_CONTEXT_DIALOG_ROW_IMPORTANCE_NEUTRAL)
+                       return 1;
+
                /* Important attributes come first */
                return attributes2->importance - attributes1->importance;
        } else {


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