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



commit 43e6abc24633c8bad013820479c1ed681a6a02b0
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        |  5 +++++
 src/gs-safety-context-dialog.c  | 27 +++++++++++++++++++++++++++
 src/gs-safety-context-dialog.ui | 12 ++++++++++++
 src/gtk-style.css               |  5 +++++
 5 files changed, 54 insertions(+)
---
diff --git a/plugins/flatpak/gs-flatpak.c b/plugins/flatpak/gs-flatpak.c
index f3e77f041..f677ef797 100644
--- a/plugins/flatpak/gs-flatpak.c
+++ b/plugins/flatpak/gs-flatpak.c
@@ -324,6 +324,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 6799a26b4..dcad28bfb 100644
--- a/src/gs-app-context-bar.c
+++ b/src/gs-app-context-bar.c
@@ -393,6 +393,11 @@ update_safety_tile (GsAppContextBar *self)
                                       * It’s used in a context tile, so should be short. */
                                      _("Software developer is verified"));
 
+       if (chosen_rating != SAFETY_UNSAFE &&
+           gs_app_get_runtime (self->app) != NULL &&
+           gs_app_get_metadata_item (gs_app_get_runtime (self->app), "GnomeSoftware::EolReason") != NULL)
+               chosen_rating = SAFETY_UNSAFE;
+
        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 02cc49789..f2917e7e1 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;
 };
 
@@ -326,6 +327,17 @@ 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_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"),
+                           _("Uses an outdated SDK version that is no longer supported and may be insecure"),
+                           NULL, NULL, NULL);
+
        /* Update the UI. */
        switch (chosen_rating) {
        case GS_CONTEXT_DIALOG_ROW_IMPORTANCE_UNIMPORTANT:
@@ -387,8 +399,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
@@ -401,6 +415,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. */
@@ -534,6 +560,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);
 
        gtk_widget_class_bind_template_callback (widget_class, key_press_event_cb);
diff --git a/src/gs-safety-context-dialog.ui b/src/gs-safety-context-dialog.ui
index 3356afb68..d7959bef3 100644
--- a/src/gs-safety-context-dialog.ui
+++ b/src/gs-safety-context-dialog.ui
@@ -250,6 +250,18 @@
                                         </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>
+                                      </object>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
diff --git a/src/gtk-style.css b/src/gtk-style.css
index 3e5a0d474..65b3522b9 100644
--- a/src/gtk-style.css
+++ b/src/gtk-style.css
@@ -809,6 +809,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]