[gnome-software/1335-highlight-when-a-runtime-is-out-of-date: 121/121] gs-safety-context-dialog: Highlight when a runtime is End-Of-Life




commit 09341aca3262e671e62fa0195e96c8a8e31b6fdc
Author: Milan Crha <mcrha redhat com>
Date:   Tue Sep 7 18:50:54 2021 +0200

    gs-safety-context-dialog: Highlight when a runtime is End-Of-Life
    
    Read the data on the Flatpak side and use it in the safety context
    dialog and the safety tile.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1335

 plugins/flatpak/gs-flatpak.c    |  5 +++++
 src/gs-app-context-bar.c        |  9 +++++++++
 src/gs-safety-context-dialog.c  | 28 ++++++++++++++++++++++++++++
 src/gs-safety-context-dialog.ui | 17 +++++++++++++++++
 src/gtk-style.css               |  5 +++++
 5 files changed, 64 insertions(+)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index d5c1a6dc1..bd87d57ed 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -328,6 +328,11 @@ gs_flatpak_set_metadata (GsFlatpak *self, GsApp *app, FlatpakRef *xref)
            gs_app_get_kind (app) == AS_COMPONENT_KIND_GENERIC) {
                gs_flatpak_set_kind_from_flatpak (app, xref);
        }
+
+       if (FLATPAK_IS_REMOTE_REF (xref) && flatpak_remote_ref_get_eol (FLATPAK_REMOTE_REF (xref)) != NULL)
+               gs_app_set_metadata (app, "GnomeSoftware::EolReason", flatpak_remote_ref_get_eol 
(FLATPAK_REMOTE_REF (xref)));
+       else if (FLATPAK_IS_INSTALLED_REF (xref) && flatpak_installed_ref_get_eol (FLATPAK_INSTALLED_REF 
(xref)) != NULL)
+               gs_app_set_metadata (app, "GnomeSoftware::EolReason", flatpak_installed_ref_get_eol 
(FLATPAK_INSTALLED_REF (xref)));
 }
 
 static GsApp *
diff --git a/src/gs-app-context-bar.c b/src/gs-app-context-bar.c
index 7eab047a2..da5f23ec1 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -405,6 +405,15 @@ update_safety_tile (GsAppContextBar *self)
                                       * It’s used in a context tile, so should be short. */
                                      _("Software developer is verified"));
 
+       if (gs_app_get_metadata_item (self->app, "GnomeSoftware::EolReason") != NULL || (
+           gs_app_get_runtime (self->app) != NULL &&
+           gs_app_get_metadata_item (gs_app_get_runtime (self->app), "GnomeSoftware::EolReason") != NULL))
+               add_to_safety_rating (&chosen_rating, descriptions,
+                                     SAFETY_UNSAFE,
+                                     /* Translators: This indicates an app or its runtime reached its end of 
life.
+                                      * It’s used in a context tile, so should be short. */
+                                     _("Software no longer supported"));
+
        g_assert (descriptions->len > 0);
 
        g_ptr_array_add (descriptions, NULL);
diff --git a/src/gs-safety-context-dialog.c b/src/gs-safety-context-dialog.c
index 5e67aa6e4..3136bd206 100644
--- a/src/gs-safety-context-dialog.c
+++ b/src/gs-safety-context-dialog.c
@@ -61,6 +61,7 @@ struct _GsSafetyContextDialog
        GtkLabel                *source_label;
        GBinding                *source_label_binding;  /* (owned) (nullable) */
        GtkLabel                *sdk_label;
+       GtkImage                *sdk_eol_image;
        GtkWidget               *sdk_row;
 };
 
@@ -321,6 +322,18 @@ update_permissions_list (GsSafetyContextDialog *self)
                            _("The developer of this app has been verified to be who they say they are"),
                            NULL, NULL, NULL);
 
+       add_permission_row (self->permissions_list, &chosen_rating,
+                           gs_app_get_metadata_item (self->app, "GnomeSoftware::EolReason") != NULL || (
+                           gs_app_get_runtime (self->app) != NULL &&
+                           gs_app_get_metadata_item (gs_app_get_runtime (self->app), 
"GnomeSoftware::EolReason") != NULL),
+                           GS_CONTEXT_DIALOG_ROW_IMPORTANCE_IMPORTANT,
+                           "dialog-warning-symbolic",
+                           /* Translators: This indicates an app uses an outdated SDK.
+                            * It’s used in a context tile, so should be short. */
+                           _("Insecure Dependencies"),
+                           _("Software or its dependencies are no longer supported and may be insecure"),
+                           NULL, NULL, NULL);
+
        /* Update the UI. */
        switch (chosen_rating) {
        case GS_CONTEXT_DIALOG_ROW_IMPORTANCE_UNIMPORTANT:
@@ -382,8 +395,10 @@ update_sdk (GsSafetyContextDialog *self)
        runtime = gs_app_get_runtime (self->app);
 
        if (runtime != NULL) {
+               GtkStyleContext *context;
                g_autofree gchar *label = NULL;
                const gchar *version = gs_app_get_version_ui (runtime);
+               gboolean is_eol = gs_app_get_metadata_item (runtime, "GnomeSoftware::EolReason") != NULL;
 
                if (version != NULL) {
                        /* Translators: The first placeholder is an app runtime
@@ -396,6 +411,18 @@ update_sdk (GsSafetyContextDialog *self)
                }
 
                gtk_label_set_label (self->sdk_label, label);
+
+               context = gtk_widget_get_style_context (GTK_WIDGET (self->sdk_label));
+
+               if (is_eol) {
+                       gtk_style_context_add_class (context, "eol-red");
+                       gtk_style_context_remove_class (context, "dim-label");
+               } else {
+                       gtk_style_context_add_class (context, "dim-label");
+                       gtk_style_context_remove_class (context, "eol-red");
+               }
+
+               gtk_widget_set_visible (GTK_WIDGET (self->sdk_eol_image), is_eol);
        }
 
        /* Only show the row if a runtime was found. */
@@ -500,6 +527,7 @@ gs_safety_context_dialog_class_init (GsSafetyContextDialogClass *klass)
        gtk_widget_class_bind_template_child (widget_class, GsSafetyContextDialog, license_label);
        gtk_widget_class_bind_template_child (widget_class, GsSafetyContextDialog, source_label);
        gtk_widget_class_bind_template_child (widget_class, GsSafetyContextDialog, sdk_label);
+       gtk_widget_class_bind_template_child (widget_class, GsSafetyContextDialog, sdk_eol_image);
        gtk_widget_class_bind_template_child (widget_class, GsSafetyContextDialog, sdk_row);
 }
 
diff --git a/src/gs-safety-context-dialog.ui b/src/gs-safety-context-dialog.ui
index ed864950d..3ae35f797 100644
--- a/src/gs-safety-context-dialog.ui
+++ b/src/gs-safety-context-dialog.ui
@@ -228,6 +228,23 @@
                                     </accessibility>
                                   </object>
                                 </child>
+                                <child>
+                                  <object class="GtkImage" id="sdk_eol_image">
+                                    <property name="icon-name">dialog-warning-symbolic</property>
+                                    <property name="visible">True</property>
+                                    <style>
+                                      <class name="eol-red"/>
+                                    </style>
+                                    <accessibility>
+                                      <relation target="sdk_title" type="labelled-by"/>
+                                    </accessibility>
+                                    <child internal-child="accessible">
+                                      <object class="AtkObject">
+                                        <property name="accessible-name" translatable="yes">Outdated SDK 
version</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                </child>
                               </object>
                             </child>
                           </object>
diff --git a/src/gtk-style.css b/src/gtk-style.css
index e220ff2e3..c1cff0a8e 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -810,6 +810,11 @@ app-context-bar .context-tile-description { font-size: smaller }
 .context-tile-lozenge.yellow, .context-tile-lozenge.details-rating-12 { background-color: #f7eb9f; color: 
#9c7107 }
 .context-tile-lozenge.blue, .context-tile-lozenge.details-rating-5 { background-color: #d1e4fb; color: 
#294d7a }
 
+.eol-red {
+       font-weight: bold;
+       color: #ab3342;
+}
+
 window.toolbox button.titlebutton:not(:hover) {
   background: @theme_bg_color;
 }


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