[gnome-control-center/wip/new-design: 18/18] panels: firmware-security: new panel UX design implementation
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/new-design: 18/18] panels: firmware-security: new panel UX design implementation
- Date: Thu, 4 Aug 2022 19:46:30 +0000 (UTC)
commit 784f83eb4423594a84ddd42da65b8eb49517b0cd
Author: Kate Hsuan <hpa redhat com>
Date: Tue Jul 26 17:20:50 2022 +0800
panels: firmware-security: new panel UX design implementation
The new UX implementation includes
1. Showing the security level using a number.
2. Showing descriptions of events and HSI checking items.
3. Change the style of the security level number.
4. Add the status icon and label for each HSI checking item.
Signed-off-by: Kate Hsuan <hpa redhat com>
.../cc-firmware-security-boot-dialog.c | 1 +
.../cc-firmware-security-boot-dialog.ui | 2 +-
.../cc-firmware-security-dialog.c | 153 +++++++++++++--------
.../cc-firmware-security-dialog.ui | 97 +++++++++++--
.../firmware-security/cc-firmware-security-panel.c | 78 +++++++----
.../cc-firmware-security-panel.ui | 24 +++-
.../firmware-security/cc-firmware-security-utils.c | 79 +++++++++++
.../firmware-security/cc-firmware-security-utils.h | 9 +-
panels/firmware-security/security-level.css | 66 ++++++++-
9 files changed, 402 insertions(+), 107 deletions(-)
---
diff --git a/panels/firmware-security/cc-firmware-security-boot-dialog.c
b/panels/firmware-security/cc-firmware-security-boot-dialog.c
index 0752026a4..bf8a0e755 100644
--- a/panels/firmware-security/cc-firmware-security-boot-dialog.c
+++ b/panels/firmware-security/cc-firmware-security-boot-dialog.c
@@ -70,6 +70,7 @@ cc_firmware_security_boot_dialog_new (SecureBootState secure_boot_state)
case SECURE_BOOT_STATE_ACTIVE:
/* TRANSLATORS: secure boot refers to the system firmware security mode */
gtk_label_set_text (GTK_LABEL(dialog->secure_boot_title), _("Secure Boot is Active"));
+ gtk_image_set_from_icon_name (GTK_IMAGE (dialog->secure_boot_icon), "channel-secure-symbolic");
gtk_widget_add_css_class (dialog->secure_boot_icon, "good");
status_description = g_strdup_printf ("%s",
/* TRANSLATORS: this is the first section of the decription */
diff --git a/panels/firmware-security/cc-firmware-security-boot-dialog.ui
b/panels/firmware-security/cc-firmware-security-boot-dialog.ui
index 1e46ccf28..8b8957e73 100644
--- a/panels/firmware-security/cc-firmware-security-boot-dialog.ui
+++ b/panels/firmware-security/cc-firmware-security-boot-dialog.ui
@@ -30,7 +30,7 @@
<property name="pixel-size">32</property>
<property name="halign">center</property>
<property name="valign">center</property>
- <property name="icon-name">system-reboot-symbolic</property>
+ <property name="icon-name">channel-insecure</property>
<style>
<class name="security-level-icon"/>
</style>
diff --git a/panels/firmware-security/cc-firmware-security-dialog.c
b/panels/firmware-security/cc-firmware-security-dialog.c
index 633d4908c..313240570 100644
--- a/panels/firmware-security/cc-firmware-security-dialog.c
+++ b/panels/firmware-security/cc-firmware-security-dialog.c
@@ -32,7 +32,16 @@ struct _CcFirmwareSecurityDialog
{
AdwWindow parent;
- GtkWidget *firmware_security_dialog_icon;
+ GtkWidget *dialog_hsi_circle_box;
+ GtkWidget *dialog_hsi_circle_number;
+
+ GtkWidget *hsi1_icon;
+ GtkWidget *hsi2_icon;
+ GtkWidget *hsi3_icon;
+ GtkWidget *hsi1_title;
+ GtkWidget *hsi2_title;
+ GtkWidget *hsi3_title;
+
GtkWidget *firmware_security_dialog_title_label;
GtkWidget *firmware_security_dialog_body_label;
GtkWidget *firmware_security_dialog_min_row;
@@ -59,17 +68,58 @@ G_DEFINE_TYPE (CcFirmwareSecurityDialog, cc_firmware_security_dialog, ADW_TYPE_W
static void
set_dialog_item_layer1 (CcFirmwareSecurityDialog *self,
- const gchar *icon_name,
- const gchar *style,
+ const int hsi_number,
const gchar *title,
const gchar *body)
{
g_autofree gchar *str = NULL;
+ g_autofree gchar *hsi_str = NULL;
/* TRANSLATORS: HSI stands for Host Security ID and device refers to the computer as a whole */
str = g_strdup_printf (_("Device conforms to HSI level %d"), self->hsi_number);
- gtk_image_set_from_icon_name (GTK_IMAGE (self->firmware_security_dialog_icon), icon_name);
- gtk_widget_add_css_class (self->firmware_security_dialog_icon, style);
+ hsi_str = g_strdup_printf ("%u", self->hsi_number);
+
+ gtk_label_set_label (GTK_LABEL (self->dialog_hsi_circle_number), hsi_str);
+
+ gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi1_icon), hsi_number >= 1 ? "emblem-ok" : "process-stop");
+ gtk_label_set_text (GTK_LABEL (self->hsi1_title), hsi_number >= 1 ? _("Passed") : _("Failed"));
+ gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi2_icon), hsi_number >= 2 ? "emblem-ok" : "process-stop");
+ gtk_label_set_text (GTK_LABEL (self->hsi2_title), hsi_number >= 2 ? _("Passed") : _("Failed"));
+ gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi3_icon), hsi_number >= 3 ? "emblem-ok" : "process-stop");
+ gtk_label_set_text (GTK_LABEL (self->hsi3_title), hsi_number >= 3 ? _("Passed") : _("Failed"));
+
+ gtk_widget_add_css_class (self->firmware_security_dialog_min_row, hsi_number >= 1 ? "success-hsi-icon" :
"error-hsi-icon");
+ gtk_widget_add_css_class (self->firmware_security_dialog_min_row, hsi_number >= 1 ? "success-title" :
"error-title");
+ gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, hsi_number >= 2 ? "success-hsi-icon" :
"error-hsi-icon");
+ gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, hsi_number >= 2 ? "success-title" :
"error-title");
+ gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, hsi_number >= 3 ? "success-hsi-icon"
: "error-hsi-icon");
+ gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, hsi_number >= 3 ? "success-title" :
"error-title");
+
+ switch (hsi_number)
+ {
+ case 0:
+ gtk_widget_add_css_class (self->dialog_hsi_circle_box, "level0");
+ gtk_widget_add_css_class (self->dialog_hsi_circle_number, "hsi0");
+
+
+ break;
+ case 1:
+ gtk_widget_add_css_class (self->dialog_hsi_circle_box, "level1");
+ gtk_widget_add_css_class (self->dialog_hsi_circle_number, "hsi1");
+
+ break;
+ case 2:
+ gtk_widget_add_css_class (self->dialog_hsi_circle_box, "level2");
+ gtk_widget_add_css_class (self->dialog_hsi_circle_number, "hsi2");
+
+ break;
+ case 3:
+ case 4:
+ gtk_widget_add_css_class (self->dialog_hsi_circle_box, "level3");
+ gtk_widget_add_css_class (self->dialog_hsi_circle_number, "hsi3");
+ break;
+ }
+
gtk_label_set_text (GTK_LABEL (self->firmware_security_dialog_title_label), title);
gtk_label_set_text (GTK_LABEL (self->firmware_security_dialog_body_label), body);
gtk_label_set_text (GTK_LABEL (self->firmware_security_dialog_hsi_label), str);
@@ -78,72 +128,39 @@ set_dialog_item_layer1 (CcFirmwareSecurityDialog *self,
static void
update_dialog (CcFirmwareSecurityDialog *self)
{
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_min_row),
"dialog-error-symbolic");
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_basic_row),
"dialog-error-symbolic");
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_extend_row),
"dialog-error-symbolic");
-
- if (self->hsi_number < 1)
- gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "gray-icon");
- if (self->hsi_number < 2)
- gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "gray-icon");
- if (self->hsi_number < 3)
- gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "gray-icon");
-
switch (self->hsi_number)
{
case 0:
set_dialog_item_layer1 (self,
- "dialog-warning-symbolic",
- "error",
- _("No Protection"),
+ 0,
+ _("Security Level 0"),
_("This device has no protection against hardware security issues. This could "
"be because of a hardware or firmware configuration issue. It is "
"recommended to contact your IT support provider."));
break;
case 1:
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_min_row),
- "emblem-default-symbolic");
- gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-icon");
set_dialog_item_layer1 (self,
- "security-low-symbolic",
- "neutral",
- _("Minimal Protection"),
+ 1,
+ _("Security Level 1"),
_("This device has minimal protection against hardware security issues. This "
"is the lowest device security level and only provides protection against "
"simple security threats."));
break;
case 2:
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_min_row),
- "emblem-default-symbolic");
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_basic_row),
- "emblem-default-symbolic");
- gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-icon");
- gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "success-icon");
set_dialog_item_layer1 (self,
- "security-medium-symbolic",
- "warning",
- _("Basic Protection"),
+ 2,
+ _("Security Level 2"),
_("This device has basic protection against hardware security issues. This "
"provides protection against some common security threats."));
break;
case 3:
case 4:
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_min_row),
- "emblem-default-symbolic");
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_basic_row),
- "emblem-default-symbolic");
- adw_action_row_set_icon_name (ADW_ACTION_ROW (self->firmware_security_dialog_extend_row),
- "emblem-default-symbolic");
- gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-icon");
- gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "success-icon");
- gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "success-icon");
set_dialog_item_layer1 (self,
- "security-high-symbolic",
- "good",
- _("Extended Protection"),
+ 3,
+ _("Security Level 3"),
_("This device has extended protection against hardware security issues. This "
"is the highest device security level and provides protection against "
"advanced security threats."));
@@ -151,8 +168,7 @@ update_dialog (CcFirmwareSecurityDialog *self)
default:
set_dialog_item_layer1 (self,
- "dialog-warning-symbolic",
- "error",
+ 0,
_("Error: unable to determine HSI level."),
_("Error: unable to determine Incorrect HSI level."));
}
@@ -209,11 +225,29 @@ hsi_create_pg_row (const gchar *icon_name,
FwupdSecurityAttr *attr)
{
GtkWidget *row;
+ GtkWidget *status_icon;
+ GtkWidget *status_label;
+ const gchar *result_str = NULL;
row = adw_expander_row_new ();
- adw_expander_row_set_icon_name (ADW_EXPANDER_ROW (row), icon_name);
adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), attr->title);
+ result_str = fwupd_security_attr_result_to_string(attr->result);
+ if (result_str)
+ {
+ status_label = gtk_label_new (result_str);
+ if (firmware_security_attr_has_flag (attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS))
+ status_icon = gtk_image_new_from_icon_name ("emblem-ok");
+ else
+ status_icon = gtk_image_new_from_icon_name ("process-stop");
+
+ adw_expander_row_add_action (ADW_EXPANDER_ROW (row), status_label);
+ adw_expander_row_add_action (ADW_EXPANDER_ROW (row), status_icon);
+
+ gtk_widget_add_css_class (status_icon, "icon");
+ gtk_widget_add_css_class (status_label, "hsi_label");
+ }
+
if (attr->description != NULL)
{
GtkWidget *subrow = adw_action_row_new ();
@@ -269,13 +303,15 @@ update_hsi_listbox (CcFirmwareSecurityDialog *self,
continue;
if (firmware_security_attr_has_flag (attr, FWUPD_SECURITY_ATTR_FLAG_SUCCESS))
{
- pg_row = hsi_create_pg_row ("emblem-default-symbolic", "color_green", attr);
+ pg_row = hsi_create_pg_row ("emblem-ok", "color_green", attr);
gtk_widget_add_css_class (pg_row, "success-icon");
+ gtk_widget_add_css_class (pg_row, "success-title");
}
else
{
- pg_row = hsi_create_pg_row ("dialog-error-symbolic", "color_dim", attr);
+ pg_row = hsi_create_pg_row ("process-stop", "color_dim", attr);
gtk_widget_add_css_class (pg_row, "error-icon");
+ gtk_widget_add_css_class (pg_row, "error-title");
}
adw_preferences_group_add (ADW_PREFERENCES_GROUP (hsi_pg), GTK_WIDGET (pg_row));
}
@@ -299,17 +335,17 @@ on_hsi_clicked_cb (GtkWidget *widget,
if (widget == self->firmware_security_dialog_min_row)
{
- adw_window_title_set_title (self->second_page_title, _("Minimal Security Protections"));
+ adw_window_title_set_title (self->second_page_title, _("Security Level 1"));
gtk_widget_set_visible (self->firmware_security_dialog_hsi1_pg, TRUE);
}
else if (widget == self->firmware_security_dialog_basic_row)
{
- adw_window_title_set_title (self->second_page_title, _("Basic Security Protections"));
+ adw_window_title_set_title (self->second_page_title, _("Security Level 2"));
gtk_widget_set_visible (self->firmware_security_dialog_hsi2_pg, TRUE);
}
else if (widget == self->firmware_security_dialog_extend_row)
{
- adw_window_title_set_title (self->second_page_title, _("Extended Security Protections"));
+ adw_window_title_set_title (self->second_page_title, _("Security Level 3"));
gtk_widget_set_visible (self->firmware_security_dialog_hsi3_pg, TRUE);
}
}
@@ -334,7 +370,14 @@ cc_firmware_security_dialog_class_init (CcFirmwareSecurityDialogClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/firmware-security/cc-firmware-security-dialog.ui");
- gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog,
firmware_security_dialog_icon);
+ gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog, dialog_hsi_circle_box);
+ gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog, dialog_hsi_circle_number);
+ gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog, hsi1_icon);
+ gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog, hsi2_icon);
+ gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog, hsi3_icon);
+ gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog, hsi1_title);
+ gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog, hsi2_title);
+ gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog, hsi3_title);
gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog,
firmware_security_dialog_title_label);
gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog,
firmware_security_dialog_body_label);
gtk_widget_class_bind_template_child (widget_class, CcFirmwareSecurityDialog,
firmware_security_dialog_hsi_label);
diff --git a/panels/firmware-security/cc-firmware-security-dialog.ui
b/panels/firmware-security/cc-firmware-security-dialog.ui
index edf3317fb..f584e4f45 100644
--- a/panels/firmware-security/cc-firmware-security-dialog.ui
+++ b/panels/firmware-security/cc-firmware-security-dialog.ui
@@ -32,16 +32,24 @@
<child>
<object class="AdwPreferencesGroup">
<child>
- <object class="GtkImage" id="firmware_security_dialog_icon">
- <property name="margin-start">16</property>
- <property name="margin-end">16</property>
- <property name="margin-top">16</property>
- <property name="pixel-size">32</property>
+ <object class="GtkBox" id="dialog_hsi_circle_box">
+ <property name="orientation">vertical</property>
<property name="halign">center</property>
<property name="valign">center</property>
- <property name="icon-name">security-high-symbolic</property>
+ <child>
+ <object class="GtkLabel" id="dialog_hsi_circle_number">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ <property name="justify">center</property>
+ <property name="label">9</property>
+ <style>
+ <class name="hsi-level-font" />
+ </style>
+ </object>
+ </child>
<style>
- <class name="security-level-icon"/>
+ <class name="hsi-level-box" />
</style>
</object>
</child>
@@ -77,9 +85,30 @@
<object class="AdwActionRow" id="firmware_security_dialog_min_row">
<property name="use-underline">True</property>
<property name="activatable">True</property>
- <property name="title" translatable="yes">Minimal Protection</property>
- <property name="icon-name">emblem-default-symbolic</property>
+ <property name="title" translatable="yes">Level 1</property>
<signal name="activated" handler="on_hsi_clicked_cb" swapped="no" />
+ <child>
+ <object class="GtkImage" id="hsi1_icon">
+ <property name="icon-name">process-stop</property>
+ <style>
+ <class name="hsi_icon" />
+ <class name="error-hsi-icon" />
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="hsi1_title">
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ <property name="justify">left</property>
+ <property name="label">Failed</property>
+ <style>
+ <class name="hsi_label" />
+ <class name="error-title" />
+ </style>
+ </object>
+ </child>
<child>
<object class="GtkImage">
<property name="icon-name">go-next-symbolic</property>
@@ -91,9 +120,30 @@
<object class="AdwActionRow" id="firmware_security_dialog_basic_row">
<property name="use-underline">True</property>
<property name="activatable">True</property>
- <property name="title" translatable="yes">Basic Protection</property>
- <property name="icon-name">emblem-default-symbolic</property>
+ <property name="title" translatable="yes">Level 2</property>
<signal name="activated" handler="on_hsi_clicked_cb" swapped="no" />
+ <child>
+ <object class="GtkImage" id="hsi2_icon">
+ <property name="icon-name">process-stop</property>
+ <style>
+ <class name="hsi_icon" />
+ <class name="error-hsi-icon" />
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="hsi2_title">
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ <property name="justify">left</property>
+ <property name="label">Failed</property>
+ <style>
+ <class name="hsi_label" />
+ <class name="error-title" />
+ </style>
+ </object>
+ </child>
<child>
<object class="GtkImage">
<property name="icon-name">go-next-symbolic</property>
@@ -105,9 +155,30 @@
<object class="AdwActionRow" id="firmware_security_dialog_extend_row">
<property name="use-underline">True</property>
<property name="activatable">True</property>
- <property name="title" translatable="yes">Extended Protection</property>
- <property name="icon-name">emblem-default-symbolic</property>
+ <property name="title" translatable="yes">Level 3</property>
<signal name="activated" handler="on_hsi_clicked_cb" swapped="no" />
+ <child>
+ <object class="GtkImage" id="hsi3_icon">
+ <property name="icon-name">process-stop</property>
+ <style>
+ <class name="hsi_icon" />
+ <class name="error-hsi-icon" />
+ </style>
+ </object>
+ </child>
+ <child>
+ <object class="GtkLabel" id="hsi3_title">
+ <property name="halign">start</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ <property name="justify">left</property>
+ <property name="label">Failed</property>
+ <style>
+ <class name="hsi_label" />
+ <class name="error-title" />
+ </style>
+ </object>
+ </child>
<child>
<object class="GtkImage">
<property name="icon-name">go-next-symbolic</property>
diff --git a/panels/firmware-security/cc-firmware-security-panel.c
b/panels/firmware-security/cc-firmware-security-panel.c
index 0a3db4002..fccfadd79 100644
--- a/panels/firmware-security/cc-firmware-security-panel.c
+++ b/panels/firmware-security/cc-firmware-security-panel.c
@@ -41,7 +41,10 @@ struct _CcfirmwareSecurityPanel
/* HSI button */
GtkWidget *hsi_grid;
- GtkWidget *hsi_icon;
+
+ GtkWidget *hsi_circle_box;
+ GtkWidget *hsi_circle_number;
+
GtkWidget *hsi_label;
GtkWidget *hsi_description;
@@ -115,7 +118,7 @@ set_secure_boot_button_view (CcfirmwareSecurityPanel *self)
}
else
{
- gtk_label_set_text (GTK_LABEL (self->secure_boot_label), _("Secure Boot is Turned Off"));
+ gtk_label_set_text (GTK_LABEL (self->secure_boot_label), _("Secure Boot is Off"));
gtk_label_set_text (GTK_LABEL (self->secure_boot_description), _("No protection when the device is
started."));
gtk_widget_add_css_class (self->secure_boot_icon, "error");
}
@@ -177,13 +180,13 @@ parse_event_variant_iter (CcfirmwareSecurityPanel *self,
row = adw_expander_row_new ();
if (attr->flags & FWUPD_SECURITY_ATTR_FLAG_SUCCESS)
{
- adw_expander_row_set_icon_name (ADW_EXPANDER_ROW (row), "emblem-default-symbolic");
+ adw_expander_row_set_icon_name (ADW_EXPANDER_ROW (row), "emblem-ok");
gtk_widget_add_css_class (row, "success-icon");
}
else
{
- adw_expander_row_set_icon_name (ADW_EXPANDER_ROW (row), "dialog-warning-symbolic");
- gtk_widget_add_css_class (row, "warning-icon");
+ adw_expander_row_set_icon_name (ADW_EXPANDER_ROW (row), "process-stop");
+ gtk_widget_add_css_class (row, "error-icon");
}
if (attr->description != NULL)
@@ -423,13 +426,36 @@ on_secure_boot_button_clicked_cb (GtkWidget *widget,
static void
set_hsi_button_view_contain (CcfirmwareSecurityPanel *self,
- const gchar *icon_name,
- const gchar *style,
+ const int hsi_number,
+
gchar *title,
const gchar *description)
{
- gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi_icon), icon_name);
- gtk_widget_add_css_class (self->hsi_icon, style);
+ switch (hsi_number)
+ {
+ case 0:
+ gtk_label_set_label (GTK_LABEL (self->hsi_circle_number), "0");
+ gtk_widget_add_css_class (self->hsi_circle_box, "level0");
+ gtk_widget_add_css_class (self->hsi_circle_number, "hsi0");
+ break;
+ case 1:
+ gtk_label_set_label (GTK_LABEL (self->hsi_circle_number), "1");
+ gtk_widget_add_css_class (self->hsi_circle_box, "level1");
+ gtk_widget_add_css_class (self->hsi_circle_number, "hsi1");
+ break;
+ case 2:
+ gtk_label_set_label (GTK_LABEL (self->hsi_circle_number), "2");
+ gtk_widget_add_css_class (self->hsi_circle_box, "level2");
+ gtk_widget_add_css_class (self->hsi_circle_number, "hsi2");
+ break;
+ case 3:
+ case 4:
+ gtk_label_set_label (GTK_LABEL (self->hsi_circle_number), "3");
+ gtk_widget_add_css_class (self->hsi_circle_box, "level3");
+ gtk_widget_add_css_class (self->hsi_circle_number, "hsi3");
+ break;
+ }
+
gtk_label_set_text (GTK_LABEL (self->hsi_label), title);
gtk_label_set_text (GTK_LABEL (self->hsi_description), description);
}
@@ -440,36 +466,37 @@ set_hsi_button_view (CcfirmwareSecurityPanel *self)
switch (self->hsi_number)
{
case 0:
- set_hsi_button_view_contain (self, "dialog-warning-symbolic",
- "error",
+ set_hsi_button_view_contain (self,
+ self->hsi_number,
/* TRANSLATORS: in reference to firmware protection: 0/4 stars */
- _("No Protection"),
- _("Highly exposed to security threats."));
+ _("Security Level 0"),
+ _("Exposed to serious security threats."));
break;
case 1:
- set_hsi_button_view_contain (self, "security-low-symbolic",
- "neutral",
+ set_hsi_button_view_contain (self,
+ self->hsi_number,
/* TRANSLATORS: in reference to firmware protection: 1/4 stars */
- _("Minimal Protection"),
+ _("Security Level 1"),
_("Limited protection against simple security threats."));
break;
case 2:
- set_hsi_button_view_contain (self, "security-medium-symbolic",
- "warning",
+ set_hsi_button_view_contain (self,
+ self->hsi_number,
/* TRANSLATORS: in reference to firmware protection: 2/4 stars */
- _("Basic Protection"),
+ _("Security Level 2"),
_("Protected against common security threats."));
break;
case 3:
- set_hsi_button_view_contain (self, "security-high-symbolic",
- "good",
+ set_hsi_button_view_contain (self,
+ self->hsi_number,
/* TRANSLATORS: in reference to firmware protection: 3/4 stars */
- _("Extended Protection"),
+ _("Security Level 3"),
_("Protected against a wide range of security threats."));
break;
case 4:
- set_hsi_button_view_contain (self, "security-high-symbolic",
- "good",
+ set_hsi_button_view_contain (self,
+ /* Based on current HSI definition, the max HSI value would be 3. */
+ 3,
/* TRANSLATORS: in reference to firmware protection: 4/4 stars */
_("Comprehensive Protection"),
_("Protected against a wide range of security threats."));
@@ -617,7 +644,8 @@ cc_firmware_security_panel_class_init (CcfirmwareSecurityPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, firmware_security_log_stack);
gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, hsi_button);
gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, hsi_description);
- gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, hsi_icon);
+ gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, hsi_circle_box);
+ gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, hsi_circle_number);
gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, hsi_label);
gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, secure_boot_button);
gtk_widget_class_bind_template_child (widget_class, CcfirmwareSecurityPanel, secure_boot_description);
diff --git a/panels/firmware-security/cc-firmware-security-panel.ui
b/panels/firmware-security/cc-firmware-security-panel.ui
index 359e39477..f975ee77f 100644
--- a/panels/firmware-security/cc-firmware-security-panel.ui
+++ b/panels/firmware-security/cc-firmware-security-panel.ui
@@ -15,6 +15,7 @@
<object class="GtkButton" id="hsi_button">
<property name="receives-default">True</property>
<property name="sensitive">True</property>
+ <property name="vexpand-set">True</property>
<signal name="clicked" handler="on_hsi_button_clicked_cb" swapped="no" />
<style>
<class name="card" />
@@ -30,14 +31,25 @@
<property name="margin-bottom">24</property>
<property name="spacing">6</property>
<child>
- <object class="GtkImage" id="hsi_icon">
+ <object class="GtkBox" id="hsi_circle_box">
+ <property name="orientation">vertical</property>
<property name="halign">center</property>
<property name="valign">center</property>
- <property name="icon-name">security-low-symbolic</property>
- <property name="pixel-size">32</property>
<property name="margin-bottom">6</property>
+ <child>
+ <object class="GtkLabel" id="hsi_circle_number">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="vexpand">True</property>
+ <property name="justify">center</property>
+ <property name="label">9</property>
+ <style>
+ <class name="hsi-level-font" />
+ </style>
+ </object>
+ </child>
<style>
- <class name="security-level-icon"/>
+ <class name="hsi-level-box" />
</style>
</object>
</child>
@@ -87,10 +99,10 @@
<property name="pixel-size">32</property>
<property name="halign">center</property>
<property name="valign">center</property>
- <property name="icon-name">system-reboot-symbolic</property>
+ <property name="icon-name">channel-insecure</property>
<property name="margin-bottom">6</property>
<style>
- <class name="security-level-icon"/>
+ <class name="security-level-icon" />
</style>
</object>
</child>
diff --git a/panels/firmware-security/cc-firmware-security-utils.c
b/panels/firmware-security/cc-firmware-security-utils.c
index 4b65b9e92..224567b19 100644
--- a/panels/firmware-security/cc-firmware-security-utils.c
+++ b/panels/firmware-security/cc-firmware-security-utils.c
@@ -228,6 +228,83 @@ fu_security_attr_get_title_fallback (const gchar *appstream_id)
return NULL;
}
+const gchar *
+fwupd_security_attr_result_to_string (FwupdSecurityAttrResult result)
+{
+ if (result == FWUPD_SECURITY_ATTR_RESULT_VALID)
+ {
+ /* TRANSLATORS: if the stauts is valid. For example security check is valid and key is valid. */
+ return _("Valid");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_NOT_VALID)
+ {
+ /* TRANSLATORS: if the status or key is not valid. */
+ return _("Not Valid");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_ENABLED)
+ {
+ /* TRANSLATORS: if the function is enabled through BIOS or OS settings. */
+ return _("Enabled");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_NOT_ENABLED)
+ {
+ /* TRANSLATORS: if the function is not enabled through BIOS or OS settings. */
+ return _("Not Enabled");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_LOCKED)
+ {
+ /* TRANSLATORS: the memory space or system mode is locked to prevent from malicious modification. */
+ return _("Locked");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_NOT_LOCKED)
+ {
+ /* TRANSLATORS: the memory space or system mode is not locked. */
+ return _("Not Locked");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_ENCRYPTED)
+ {
+ /* TRANSLATORS: The data is encrypted to prevent from malicious reading. */
+ return _("Encrypted");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_NOT_ENCRYPTED)
+ {
+ /* TRANSLATORS: the data in memory is plane text. */
+ return _("Not Encrypted");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_TAINTED)
+ {
+ /* TRANSLATORS: Linux kernel is tainted by third party kernel module. */
+ return _("Tainted");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_NOT_TAINTED)
+ {
+ /* TRANSLATORS: All the loaded kernel module are licensed. */
+ return _("Not Tainted");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_FOUND)
+ {
+ /* TRANSLATORS: the feature can be detected. */
+ return _("Found");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_NOT_FOUND)
+ {
+ /* TRANSLATORS: the feature can't be detected. */
+ return _("Not Found");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_SUPPORTED)
+ {
+ /* TRANSLATORS: the function is supported by hardware. */
+ return _("Supported");
+ }
+ if (result == FWUPD_SECURITY_ATTR_RESULT_NOT_SUPPORTED)
+ {
+ /* TRANSLATORS: the function isn't supported by hardware. */
+ return _("Not Supported");
+ }
+ return NULL;
+}
+
+
/* ->summary and ->description are translated */
FwupdSecurityAttr *
fu_security_attr_new_from_variant (GVariantIter *iter)
@@ -244,6 +321,8 @@ fu_security_attr_new_from_variant (GVariantIter *iter)
attr->flags = g_variant_get_uint64(value);
else if (g_strcmp0 (key, "HsiLevel") == 0)
attr->hsi_level = g_variant_get_uint32 (value);
+ else if (g_strcmp0 (key, "HsiResult") == 0)
+ attr->result = g_variant_get_uint32 (value);
else if (g_strcmp0 (key, "Created") == 0)
attr->timestamp = g_variant_get_uint64 (value);
else if (g_strcmp0 (key, "Description") == 0)
diff --git a/panels/firmware-security/cc-firmware-security-utils.h
b/panels/firmware-security/cc-firmware-security-utils.h
index ef844c001..6c895da87 100644
--- a/panels/firmware-security/cc-firmware-security-utils.h
+++ b/panels/firmware-security/cc-firmware-security-utils.h
@@ -123,9 +123,10 @@ void fu_security_attr_free (FwupdSecurityAttr *attr);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FwupdSecurityAttr, fu_security_attr_free)
-gboolean firmware_security_attr_has_flag (FwupdSecurityAttr *attr,
- FwupdSecurityAttrFlags flag);
-void load_custom_css (const char *path);
-
+gboolean firmware_security_attr_has_flag (FwupdSecurityAttr *attr,
+ FwupdSecurityAttrFlags flag);
+void load_custom_css (const char *path);
+const gchar *fwupd_security_attr_result_to_string (FwupdSecurityAttrResult result);
+gboolean fwupd_get_result_status (FwupdSecurityAttrResult result);
G_END_DECLS
diff --git a/panels/firmware-security/security-level.css b/panels/firmware-security/security-level.css
index 33be08778..282412d98 100644
--- a/panels/firmware-security/security-level.css
+++ b/panels/firmware-security/security-level.css
@@ -1,3 +1,47 @@
+.hsi-level-box {
+ border-radius: 9999px;
+ min-width: 64px;
+ min-height: 64px;
+
+}
+
+.hsi-level-box.level0 {
+ background-color: alpha(@error_color, .25);
+}
+
+.hsi-level-box.level1 {
+ background-color: alpha(@light_4, .25);
+}
+
+.hsi-level-box.level2 {
+ background-color: alpha(@warning_color, .25);
+}
+
+.hsi-level-box.level3 {
+ background-color: alpha(@success_color, .25);
+}
+
+.hsi-level-font {
+ font-size: 32px;
+ font-weight: 800;
+}
+
+.hsi-level-font.hsi0 {
+ color: @error_color;
+}
+
+.hsi-level-font.hsi1 {
+ color: @light_4;
+}
+
+.hsi-level-font.hsi2 {
+ color: @warning_color;
+}
+
+.hsi-level-font.hsi3 {
+ color: @success_color;
+}
+
.security-level-icon {
border-radius: 9999px;
min-width: 64px;
@@ -32,18 +76,34 @@
color: @light_4f;
}
-row.success-icon image {
+row.success-icon image.icon {
color: @success_color;
}
-row.warning-icon image {
+row.warning-icon image.icon {
color: @warning_color;
}
-row.error-icon image {
+row.error-icon image.icon {
color: @error_color;
}
row.gray-icon image {
color: @light_4;
}
+
+row.success-hsi-icon image.hsi_icon {
+ color: @success_color;
+}
+
+row.error-hsi-icon image.hsi_icon {
+ color: @error_color;
+}
+
+row.success-title label.hsi_label {
+ color: @success_color;
+}
+
+row.error-title label.hsi_label {
+ color: @error_color;
+}
\ No newline at end of file
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]