[gnome-control-center/wip/hughsie/firmware-security-hide-vm] firmware-security: Hide the panel when using a VM
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/hughsie/firmware-security-hide-vm] firmware-security: Hide the panel when using a VM
- Date: Wed, 20 Jul 2022 12:02:29 +0000 (UTC)
commit ee0659a09f9b55f8ec1fd4eae0202d299b8fe6f6
Author: Richard Hughes <richard hughsie com>
Date: Tue Jul 19 17:40:49 2022 +0100
firmware-security: Hide the panel when using a VM
Fixes https://gitlab.gnome.org/GNOME/gnome-control-center/-/issues/1972
.../firmware-security/cc-firmware-security-panel.c | 56 ++++++++++++++++++++++
.../firmware-security/cc-firmware-security-panel.h | 2 +
shell/cc-panel-loader.c | 3 +-
3 files changed, 60 insertions(+), 1 deletion(-)
---
diff --git a/panels/firmware-security/cc-firmware-security-panel.c
b/panels/firmware-security/cc-firmware-security-panel.c
index ebd152834..f56108670 100644
--- a/panels/firmware-security/cc-firmware-security-panel.c
+++ b/panels/firmware-security/cc-firmware-security-panel.c
@@ -20,6 +20,8 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
+#include "shell/cc-application.h"
+
#include "cc-firmware-security-panel.h"
#include "cc-firmware-security-resources.h"
#include "cc-firmware-security-dialog.h"
@@ -509,6 +511,60 @@ on_properties_bus_ready_cb (GObject *source_object,
self);
}
+static void
+update_panel_visibility (const gchar *chassis_type)
+{
+ CcApplication *application;
+ gboolean visible = TRUE;
+
+ /* there's *almost* no point showing this by default */
+ if (g_strcmp0 (chassis_type, "vm") == 0)
+ visible = FALSE;
+ application = CC_APPLICATION (g_application_get_default ());
+ cc_shell_model_set_panel_visibility (cc_application_get_model (application),
+ "firmware-security",
+ visible ? CC_PANEL_VISIBLE : CC_PANEL_VISIBLE_IN_SEARCH);
+ g_debug ("Firmware Security panel visible: %s as chassis was %s",
+ visible ? "yes" : "no",
+ chassis_type);
+}
+
+void
+cc_firmware_security_panel_static_init_func (void)
+{
+ g_autoptr(GDBusConnection) connection = NULL;
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GVariant) inner = NULL;
+ g_autoptr(GVariant) variant = NULL;
+
+ connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (!connection)
+ {
+ g_warning ("system bus not available: %s", error->message);
+ return;
+ }
+ variant = g_dbus_connection_call_sync (connection,
+ "org.freedesktop.hostname1",
+ "/org/freedesktop/hostname1",
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ g_variant_new ("(ss)",
+ "org.freedesktop.hostname1",
+ "Chassis"),
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error);
+ if (!variant)
+ {
+ g_warning ("Cannot get org.freedesktop.hostname1.Chassis: %s", error->message);
+ return;
+ }
+ g_variant_get (variant, "(v)", &inner);
+ update_panel_visibility (g_variant_get_string (inner, NULL));
+}
+
static void
cc_firmware_security_panel_finalize (GObject *object)
{
diff --git a/panels/firmware-security/cc-firmware-security-panel.h
b/panels/firmware-security/cc-firmware-security-panel.h
index a4afb5dc3..1c7a02426 100644
--- a/panels/firmware-security/cc-firmware-security-panel.h
+++ b/panels/firmware-security/cc-firmware-security-panel.h
@@ -29,4 +29,6 @@ G_BEGIN_DECLS
#define CC_TYPE_FIRMWARE_SECURITY_PANEL (cc_firmware_security_panel_get_type ())
G_DECLARE_FINAL_TYPE (CcfirmwareSecurityPanel, cc_firmware_security_panel, CC, FIRMWARE_SECURITY_PANEL,
CcPanel)
+void cc_firmware_security_panel_static_init_func (void);
+
G_END_DECLS
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index 57b2d5bed..5fff89ba6 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -87,6 +87,7 @@ extern void cc_wacom_panel_static_init_func (void);
#ifdef BUILD_WWAN
extern void cc_wwan_panel_static_init_func (void);
#endif /* BUILD_WWAN */
+extern void cc_firmware_security_panel_static_init_func (void);
#define PANEL_TYPE(name, get_type, init_func) { name, get_type, init_func }
@@ -112,7 +113,7 @@ static CcPanelLoaderVtable default_panels[] =
PANEL_TYPE("info-overview", cc_info_overview_panel_get_type, NULL),
PANEL_TYPE("keyboard", cc_keyboard_panel_get_type, NULL),
PANEL_TYPE("location", cc_location_panel_get_type, NULL),
- PANEL_TYPE("firmware-security",cc_firmware_security_panel_get_type, NULL),
+ PANEL_TYPE("firmware-security",cc_firmware_security_panel_get_type,
cc_firmware_security_panel_static_init_func),
PANEL_TYPE("lock", cc_lock_panel_get_type, NULL),
PANEL_TYPE("microphone", cc_microphone_panel_get_type, NULL),
PANEL_TYPE("mouse", cc_mouse_panel_get_type, NULL),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]