[gnome-control-center/wip/new-design] flip icon and css settings.



commit 9bea651b649d3aca7362eda62a3b8bef30c0359e
Author: Kate Hsuan <hpa redhat com>
Date:   Mon Aug 1 19:31:22 2022 +0800

    flip icon and css settings.

 .../cc-firmware-security-dialog.c                  | 80 ++++++----------------
 1 file changed, 22 insertions(+), 58 deletions(-)
---
diff --git a/panels/firmware-security/cc-firmware-security-dialog.c 
b/panels/firmware-security/cc-firmware-security-dialog.c
index 6893f6e1f..82acdeef3 100644
--- a/panels/firmware-security/cc-firmware-security-dialog.c
+++ b/panels/firmware-security/cc-firmware-security-dialog.c
@@ -73,78 +73,50 @@ set_dialog_item_layer1 (CcFirmwareSecurityDialog *self,
                         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);
+  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_label_set_label (self->dialog_hsi_circle_number, "0");
         gtk_widget_add_css_class (self->dialog_hsi_circle_box, "level0");
         gtk_widget_add_css_class (self->dialog_hsi_circle_number, "hsi0");
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi1_icon), "process-stop");
-        gtk_label_set_text (GTK_LABEL (self->hsi1_title), _("Failed"));
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi2_icon), "process-stop");
-        gtk_label_set_text (GTK_LABEL (self->hsi2_title), _("Failed"));
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi3_icon), "process-stop");
-        gtk_label_set_text (GTK_LABEL (self->hsi3_title), _("Failed"));
-        gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "error-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "error-title");
-        gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "error-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "error-title");
-        gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "error-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "error-title");
+
+
         break;
       case 1:
-        gtk_label_set_label (self->dialog_hsi_circle_number, "1");
         gtk_widget_add_css_class (self->dialog_hsi_circle_box, "level1");
         gtk_widget_add_css_class (self->dialog_hsi_circle_number, "hsi1");
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi1_icon), "emblem-ok");
-        gtk_label_set_text (GTK_LABEL (self->hsi1_title), _("Passed"));
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi2_icon), "process-stop");
-        gtk_label_set_text (GTK_LABEL (self->hsi2_title), _("Failed"));
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi3_icon), "process-stop");
-        gtk_label_set_text (GTK_LABEL (self->hsi3_title), _("Failed"));
-        gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-title");
-        gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "error-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "error-title");
-        gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "error-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "error-title");
+
         break;
       case 2:
-        gtk_label_set_label (self->dialog_hsi_circle_number, "2");
         gtk_widget_add_css_class (self->dialog_hsi_circle_box, "level2");
         gtk_widget_add_css_class (self->dialog_hsi_circle_number, "hsi2");
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi1_icon), "emblem-ok");
-        gtk_label_set_text (GTK_LABEL (self->hsi1_title), _("Passed"));
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi2_icon), "emblem-ok");
-        gtk_label_set_text (GTK_LABEL (self->hsi2_title), _("Passed"));
-        gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-title");
-        gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "success-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "success-title");
-        gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "error-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "error-title");
+
         break;
       case 3:
       case 4:
-        gtk_label_set_label (self->dialog_hsi_circle_number, "3");
         gtk_widget_add_css_class (self->dialog_hsi_circle_box, "level3");
         gtk_widget_add_css_class (self->dialog_hsi_circle_number, "hsi3");
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi1_icon), "emblem-ok");
-        gtk_label_set_text (GTK_LABEL (self->hsi1_title), _("Passed"));
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi2_icon), "emblem-ok");
-        gtk_label_set_text (GTK_LABEL (self->hsi2_title), _("Passed"));
-        gtk_image_set_from_icon_name (GTK_IMAGE (self->hsi3_icon), "emblem-ok");
-        gtk_label_set_text (GTK_LABEL (self->hsi3_title), _("Passed"));
-        gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_min_row, "success-title");
-        gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "success-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "success-title");
-        gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "success-hsi-icon");
-        gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "success-title");
         break;
     }
 
@@ -156,11 +128,9 @@ set_dialog_item_layer1 (CcFirmwareSecurityDialog *self,
 static void
 update_dialog (CcFirmwareSecurityDialog *self)
 {
-self->hsi_number = 0;
   switch (self->hsi_number)
     {
     case 0:
-      
       set_dialog_item_layer1 (self,
                               0,
                               _("Security Level 0"),
@@ -188,10 +158,6 @@ self->hsi_number = 0;
 
     case 3:
     case 4:
-      gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "error-hsi-icon");
-      gtk_widget_add_css_class (self->firmware_security_dialog_basic_row, "error-title");
-      gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "success-hsi-icon");
-      gtk_widget_add_css_class (self->firmware_security_dialog_extend_row, "success-title");
       set_dialog_item_layer1 (self,
                               3,
                               _("Security Level 3"),
@@ -262,8 +228,6 @@ hsi_create_pg_row (const gchar *icon_name,
   GtkWidget *status_icon;
   GtkWidget *status_label;
 
-  printf("result->%d %s\n", attr->result, fwupd_security_attr_result_to_string(attr->result));
-
   row = adw_expander_row_new ();
   adw_preferences_row_set_title (ADW_PREFERENCES_ROW (row), attr->title);
   status_label = gtk_label_new (fwupd_security_attr_result_to_string(attr->result));


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