[gnome-software/1925-app-page-odd-styling-on-the-right-side-when-there-is-no-open-button] gs-details-page: Style 'Uninstall' button differently when it's alone



commit f1cc55dbdf1a8e4ca4a59ba1fdb00c03bbc78884
Author: Milan Crha <mcrha redhat com>
Date:   Tue Sep 27 17:44:24 2022 +0200

    gs-details-page: Style 'Uninstall' button differently when it's alone
    
    Let the 'Uninstall;' button be a text button, not an icon button with a destructive
    CSS class, to not be prominent in the view.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1925

 src/gs-details-page.c  | 19 ++++++++++++++++---
 src/gs-details-page.ui |  1 +
 2 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 50b80e159..70db690a4 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -857,6 +857,7 @@ gs_details_page_refresh_buttons (GsDetailsPage *self)
                self->button_remove,
        };
        GtkWidget *highlighted_button = NULL;
+       gboolean remove_is_destructive = TRUE;
 
        state = gs_app_get_state (self->app);
 
@@ -970,6 +971,15 @@ gs_details_page_refresh_buttons (GsDetailsPage *self)
                gtk_widget_set_visible (self->button_remove, FALSE);
        }
 
+       if (!gtk_widget_get_visible (self->button_details_launch) &&
+           !gtk_widget_get_visible (self->button_install) &&
+           !gtk_widget_get_visible (self->button_update)) {
+               remove_is_destructive = FALSE;
+               gtk_button_set_label (GTK_BUTTON (self->button_remove), _("_Uninstall"));
+       } else {
+               gtk_button_set_icon_name (GTK_BUTTON (self->button_remove), "user-trash-symbolic");
+       }
+
        /* Update the styles so that the first visible button gets
         * `suggested-action` or `destructive-action` and the rest are
         * unstyled. This draws the user’s attention to the most likely
@@ -981,9 +991,12 @@ gs_details_page_refresh_buttons (GsDetailsPage *self)
                } else if (gtk_widget_get_visible (buttons_in_order[i])) {
                        highlighted_button = buttons_in_order[i];
 
-                       if (buttons_in_order[i] == self->button_remove)
-                               gtk_style_context_add_class (gtk_widget_get_style_context 
(buttons_in_order[i]), "destructive-action");
-                       else
+                       if (buttons_in_order[i] == self->button_remove) {
+                               if (remove_is_destructive)
+                                       gtk_style_context_add_class (gtk_widget_get_style_context 
(buttons_in_order[i]), "destructive-action");
+                               else
+                                       gtk_style_context_remove_class (gtk_widget_get_style_context 
(buttons_in_order[i]), "destructive-action");
+                       } else
                                gtk_style_context_add_class (gtk_widget_get_style_context 
(buttons_in_order[i]), "suggested-action");
                }
        }
diff --git a/src/gs-details-page.ui b/src/gs-details-page.ui
index 6e12e0a1b..eebd19fe3 100644
--- a/src/gs-details-page.ui
+++ b/src/gs-details-page.ui
@@ -270,6 +270,7 @@
                                                     <property name="receives_default">True</property>
                                                     <property name="halign">start</property>
                                                     <property name="valign">center</property>
+                                                    <property name="use_underline">True</property>
                                                     <signal name="clicked" 
handler="gs_details_page_app_remove_button_cb"/>
                                                     <child>
                                                       <object class="GtkImage">


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