[gnome-software/gnome-40: 3/4] gs-details-page: Show icons in the Permissions popover only when used




commit 275db0eae358f5e0e4d82f03609bb1bf3a3169d7
Author: Milan Crha <mcrha redhat com>
Date:   Tue May 18 12:29:03 2021 +0200

    gs-details-page: Show icons in the Permissions popover only when used
    
    Otherwise there's a weird gap on the left, used for the icons, which are
    all transparent.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1236

 src/gs-details-page.c | 29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index aa05a7571..1b64d0009 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1153,8 +1153,19 @@ populate_permission_details (GsDetailsPage *self, GsAppPermissions permissions)
                gtk_widget_show (label);
                gtk_container_add (GTK_CONTAINER (self->box_permissions_details), label);
        } else {
-               for (gsize i = 0; i < G_N_ELEMENTS (permission_display_data); i++) {
-                       GtkWidget *row, *image, *box, *label;
+               gboolean with_icons = FALSE;
+               gsize i;
+
+               for (i = 0; i < G_N_ELEMENTS (permission_display_data); i++) {
+                       if ((permissions & permission_display_data[i].permission) != 0 &&
+                           (permission_display_data[i].permission & ~MEDIUM_PERMISSIONS) != 0) {
+                               with_icons = TRUE;
+                               break;
+                       }
+               }
+
+               for (i = 0; i < G_N_ELEMENTS (permission_display_data); i++) {
+                       GtkWidget *row, *box, *label;
 
                        if ((permissions & permission_display_data[i].permission) == 0)
                                continue;
@@ -1162,12 +1173,16 @@ populate_permission_details (GsDetailsPage *self, GsAppPermissions permissions)
                        row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
                        gtk_widget_show (row);
 
-                       image = gtk_image_new_from_icon_name ("dialog-warning-symbolic", GTK_ICON_SIZE_MENU);
-                       if ((permission_display_data[i].permission & ~MEDIUM_PERMISSIONS) == 0)
-                               gtk_widget_set_opacity (image, 0);
+                       if (with_icons) {
+                               GtkWidget *image;
 
-                       gtk_widget_show (image);
-                       gtk_container_add (GTK_CONTAINER (row), image);
+                               image = gtk_image_new_from_icon_name ("dialog-warning-symbolic", 
GTK_ICON_SIZE_MENU);
+                               if ((permission_display_data[i].permission & ~MEDIUM_PERMISSIONS) == 0)
+                                       gtk_widget_set_opacity (image, 0);
+
+                               gtk_widget_show (image);
+                               gtk_container_add (GTK_CONTAINER (row), image);
+                       }
 
                        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
                        gtk_widget_show (box);


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