[gnome-control-center/wip/kate/about-firmware-security] panel: firmware-security: About dialog for showing the panel description




commit e283b393c534108619ea66d45554a85408acb41a
Author: Kate Hsuan <hpa redhat com>
Date:   Tue Oct 4 17:36:27 2022 +0800

    panel: firmware-security: About dialog for showing the panel description
    
    An about dialog is used to show the description of the device security panel.
    
    Signed-off-by: Kate Hsuan <hpa redhat com>

 .../cc-firmware-security-help-dialog.c             | 62 ++++++++++++++++++++++
 .../cc-firmware-security-help-dialog.h             | 35 ++++++++++++
 .../cc-firmware-security-help-dialog.ui            | 47 ++++++++++++++++
 .../firmware-security/cc-firmware-security-panel.c | 18 +++++++
 .../cc-firmware-security-panel.ui                  | 12 +++++
 .../firmware-security.gresource.xml                |  1 +
 panels/firmware-security/meson.build               |  2 +
 7 files changed, 177 insertions(+)
---
diff --git a/panels/firmware-security/cc-firmware-security-help-dialog.c 
b/panels/firmware-security/cc-firmware-security-help-dialog.c
new file mode 100644
index 000000000..f68b9e7d6
--- /dev/null
+++ b/panels/firmware-security/cc-firmware-security-help-dialog.c
@@ -0,0 +1,62 @@
+/* cc-firmware-security-dialog.c
+ *
+ * Copyright (C) 2022 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Kate Hsuan <hpa redhat com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "config.h"
+
+#include <glib/gi18n-lib.h>
+
+#include "cc-firmware-security-help-dialog.h"
+#include "cc-firmware-security-utils.h"
+
+struct _CcFirmwareSecurityHelpDialog
+{
+  GtkDialog parent;
+};
+
+G_DEFINE_TYPE (CcFirmwareSecurityHelpDialog, cc_firmware_security_help_dialog, GTK_TYPE_DIALOG)
+
+
+static void
+cc_firmware_security_help_dialog_class_init (CcFirmwareSecurityHelpDialogClass *klass)
+{
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+  gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/firmware-security/cc-firmware-security-help-dialog.ui");
+}
+
+static void
+cc_firmware_security_help_dialog_init (CcFirmwareSecurityHelpDialog *dialog)
+{
+  gtk_widget_init_template (GTK_WIDGET (dialog));
+  load_custom_css ("/org/gnome/control-center/firmware-security/security-level.css");
+}
+
+GtkWidget *
+cc_firmware_security_help_dialog_new (void *args)
+{
+  CcFirmwareSecurityHelpDialog *dialog;
+
+  dialog = g_object_new (CC_TYPE_FIRMWARE_SECURITY_HELP_DIALOG,
+                         "use-header-bar", TRUE,
+                         NULL);
+  return GTK_WIDGET (dialog);
+}
diff --git a/panels/firmware-security/cc-firmware-security-help-dialog.h 
b/panels/firmware-security/cc-firmware-security-help-dialog.h
new file mode 100644
index 000000000..547b59f1a
--- /dev/null
+++ b/panels/firmware-security/cc-firmware-security-help-dialog.h
@@ -0,0 +1,35 @@
+/* cc-firmware-security-dialog.h
+ *
+ * Copyright (C) 2022 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Kate Hsuan <hpa redhat com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#pragma once
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_FIRMWARE_SECURITY_HELP_DIALOG (cc_firmware_security_help_dialog_get_type ())
+G_DECLARE_FINAL_TYPE (CcFirmwareSecurityHelpDialog, cc_firmware_security_help_dialog,
+                      CC, FIRMWARE_SECURITY_HELP_DIALOG, GtkDialog)
+
+GtkWidget * cc_firmware_security_help_dialog_new (void *args);
+
+G_END_DECLS
\ No newline at end of file
diff --git a/panels/firmware-security/cc-firmware-security-help-dialog.ui 
b/panels/firmware-security/cc-firmware-security-help-dialog.ui
new file mode 100644
index 000000000..5c21796af
--- /dev/null
+++ b/panels/firmware-security/cc-firmware-security-help-dialog.ui
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="CcFirmwareSecurityHelpDialog" parent="GtkDialog">
+    <property name="default-width">400</property>
+    <property name="modal">True</property>
+    <property name="title">About Device Security</property>
+
+    <child>
+      <object class="GtkBox">
+        <property name="orientation">vertical</property>
+        <property name="margin-start">32</property>
+        <property name="margin-end">32</property>
+        <property name="margin-bottom">32</property>
+        <child>
+          <object class="GtkBox">
+            <property name="orientation">vertical</property>
+            <property name="spacing">16</property>
+
+            <child>
+              <object class="GtkLabel">
+                <property name="wrap">True</property>
+                <property name="width-chars">40</property>
+                <property name="max-width-chars">40</property>
+                <property name="justify">left</property>
+                <property name="label" translatable="yes">
+Device security provides information about how protected your device is against security issues which target 
the hardware itself.
+
+Aspects of hardware that affect security include:
+ • security features that are built into a hardware itself.
+ • how the hardware is configured to protect against security issues.
+ • the security of the software runs directly on the hardware.
+
+Security threats which affect hardware include malware and viruses that target the software that runs 
directly on the hardware. It also includes physical tampering, such as physical connection to the hardware to 
read data and implant malware.
+
+Device security is just one aspect of security, and does not reflect the overall security status of the 
system and applications.
+
+                </property>
+              </object>
+            </child>
+
+          </object>
+        </child>
+      </object>
+    </child>
+
+  </template>
+</interface>
\ No newline at end of file
diff --git a/panels/firmware-security/cc-firmware-security-panel.c 
b/panels/firmware-security/cc-firmware-security-panel.c
index d48e7abc1..0a65141f8 100644
--- a/panels/firmware-security/cc-firmware-security-panel.c
+++ b/panels/firmware-security/cc-firmware-security-panel.c
@@ -26,6 +26,7 @@
 #include "cc-firmware-security-resources.h"
 #include "cc-firmware-security-dialog.h"
 #include "cc-firmware-security-boot-dialog.h"
+#include "cc-firmware-security-help-dialog.h"
 #include "cc-firmware-security-utils.h"
 #include "cc-util.h"
 
@@ -433,6 +434,22 @@ on_secure_boot_button_clicked_cb (GtkWidget *widget,
   gtk_widget_show (boot_dialog);
 }
 
+static void
+on_fw_help_button_clicked_cb (GtkWidget *widget,
+                              gpointer   data)
+{
+  GtkWidget *toplevel;
+  CcShell *shell;
+  GtkWidget *help_dialog;
+  CcfirmwareSecurityPanel *self = CC_FIRMWARE_SECURITY_PANEL (data);
+
+  help_dialog = cc_firmware_security_help_dialog_new (NULL);
+  shell = cc_panel_get_shell (CC_PANEL (self));
+  toplevel = cc_shell_get_toplevel (shell);
+  gtk_window_set_transient_for (GTK_WINDOW (help_dialog), GTK_WINDOW (toplevel));
+  gtk_widget_show (help_dialog);
+}
+
 static void
 set_hsi_button_view_contain (CcfirmwareSecurityPanel *self,
                              guint                    hsi_number,
@@ -680,6 +697,7 @@ cc_firmware_security_panel_class_init (CcfirmwareSecurityPanelClass *klass)
 
   gtk_widget_class_bind_template_callback (widget_class, on_hsi_button_clicked_cb);
   gtk_widget_class_bind_template_callback (widget_class, on_secure_boot_button_clicked_cb);
+  gtk_widget_class_bind_template_callback (widget_class, on_fw_help_button_clicked_cb);
 }
 
 static void
diff --git a/panels/firmware-security/cc-firmware-security-panel.ui 
b/panels/firmware-security/cc-firmware-security-panel.ui
index f975ee77f..8ca511683 100644
--- a/panels/firmware-security/cc-firmware-security-panel.ui
+++ b/panels/firmware-security/cc-firmware-security-panel.ui
@@ -1,6 +1,18 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <template class="CcfirmwareSecurityPanel" parent="CcPanel">
+    <child type="titlebar-end">
+      <object class="GtkButton" id="fw_help_button">
+        <property name="halign">center</property>
+        <property name="valign">center</property>
+        <property name="icon-name">help-about-symbolic</property>
+           <signal name="clicked" handler="on_fw_help_button_clicked_cb" swapped="no" />
+        <style>
+          <class name="image-button" />
+        </style>
+      </object>
+    </child>
+
     <child type="content">
       <object class="AdwPreferencesPage">
 
diff --git a/panels/firmware-security/firmware-security.gresource.xml 
b/panels/firmware-security/firmware-security.gresource.xml
index f44f6fbca..119864715 100644
--- a/panels/firmware-security/firmware-security.gresource.xml
+++ b/panels/firmware-security/firmware-security.gresource.xml
@@ -4,6 +4,7 @@
     <file preprocess="xml-stripblanks">cc-firmware-security-panel.ui</file>
     <file preprocess="xml-stripblanks">cc-firmware-security-dialog.ui</file>
     <file preprocess="xml-stripblanks">cc-firmware-security-boot-dialog.ui</file>
+    <file preprocess="xml-stripblanks">cc-firmware-security-help-dialog.ui</file>
     <file>security-level.css</file>
   </gresource>
 </gresources>
diff --git a/panels/firmware-security/meson.build b/panels/firmware-security/meson.build
index 0325568ff..f54dad7d9 100644
--- a/panels/firmware-security/meson.build
+++ b/panels/firmware-security/meson.build
@@ -19,10 +19,12 @@ i18n.merge_file(
 sources = files('cc-firmware-security-utils.c',
                 'cc-firmware-security-panel.c',
                 'cc-firmware-security-dialog.c',
+                'cc-firmware-security-help-dialog.c',
                 'cc-firmware-security-boot-dialog.c')
 
 resource_data = files('cc-firmware-security-panel.ui',
                       'cc-firmware-security-dialog.ui',
+                      'cc-firmware-security-help-dialog.ui',
                       'cc-firmware-security-boot-dialog.ui')
 
 sources += gnome.compile_resources(


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