[gnome-control-center] screen: Add Screen Privacy section to show Privacy screen toggle
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] screen: Add Screen Privacy section to show Privacy screen toggle
- Date: Thu, 28 Jul 2022 22:52:05 +0000 (UTC)
commit 72863a8f56382f6f412483c51dff9ff70dfe2ba5
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Tue Jan 25 02:42:10 2022 +0100
screen: Add Screen Privacy section to show Privacy screen toggle
The privacy screen toggle is visible only when there's a monitor that
supports it and it's modifiable only when there's not hardware lock.
Fixes: #909
panels/screen/cc-screen-panel.c | 69 ++++++++++++++++++++++++++++++++++++----
panels/screen/cc-screen-panel.ui | 21 ++++++++++++
2 files changed, 83 insertions(+), 7 deletions(-)
---
diff --git a/panels/screen/cc-screen-panel.c b/panels/screen/cc-screen-panel.c
index 891cb71f9..05bd11d7c 100644
--- a/panels/screen/cc-screen-panel.c
+++ b/panels/screen/cc-screen-panel.c
@@ -2,6 +2,7 @@
*
* Copyright (C) 2018 Red Hat, Inc
* Copyright (C) 2020 Collabora Ltd.
+ * Copyright (C) 2021-2022 Canonical Ltd.
*
* 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
@@ -24,7 +25,10 @@
#include "cc-screen-resources.h"
#include "cc-util.h"
+#include "panels/display/cc-display-config-manager-dbus.h"
+
#include <adwaita.h>
+
#include <gio/gdesktopappinfo.h>
#include <glib/gi18n.h>
@@ -32,6 +36,8 @@ struct _CcScreenPanel
{
CcPanel parent_instance;
+ CcDisplayConfigManager *display_config_manager;
+
GSettings *lock_settings;
GSettings *notification_settings;
GSettings *privacy_settings;
@@ -39,13 +45,15 @@ struct _CcScreenPanel
GCancellable *cancellable;
- AdwComboRow *blank_screen_row;
- AdwComboRow *lock_after_row;
- GDBusProxy *usb_proxy;
- GtkListBoxRow *usb_protection_row;
- GtkSwitch *automatic_screen_lock_switch;
- GtkSwitch *show_notifications_switch;
- GtkSwitch *usb_protection_switch;
+ AdwComboRow *blank_screen_row;
+ AdwComboRow *lock_after_row;
+ AdwPreferencesGroup *screen_privacy_group;
+ GDBusProxy *usb_proxy;
+ GtkListBoxRow *usb_protection_row;
+ GtkSwitch *automatic_screen_lock_switch;
+ GtkSwitch *privacy_screen_switch;
+ GtkSwitch *show_notifications_switch;
+ GtkSwitch *usb_protection_switch;
};
CC_PANEL_REGISTER (CcScreenPanel, cc_screen_panel)
@@ -242,6 +250,7 @@ cc_screen_panel_finalize (GObject *object)
g_cancellable_cancel (self->cancellable);
g_clear_object (&self->cancellable);
+ g_clear_object (&self->display_config_manager);
g_clear_object (&self->lock_settings);
g_clear_object (&self->notification_settings);
g_clear_object (&self->session_settings);
@@ -265,6 +274,8 @@ cc_screen_panel_class_init (CcScreenPanelClass *klass)
gtk_widget_class_bind_template_child (widget_class, CcScreenPanel, automatic_screen_lock_switch);
gtk_widget_class_bind_template_child (widget_class, CcScreenPanel, blank_screen_row);
gtk_widget_class_bind_template_child (widget_class, CcScreenPanel, lock_after_row);
+ gtk_widget_class_bind_template_child (widget_class, CcScreenPanel, privacy_screen_switch);
+ gtk_widget_class_bind_template_child (widget_class, CcScreenPanel, screen_privacy_group);
gtk_widget_class_bind_template_child (widget_class, CcScreenPanel, show_notifications_switch);
gtk_widget_class_bind_template_child (widget_class, CcScreenPanel, usb_protection_row);
gtk_widget_class_bind_template_child (widget_class, CcScreenPanel, usb_protection_switch);
@@ -275,6 +286,38 @@ cc_screen_panel_class_init (CcScreenPanelClass *klass)
gtk_widget_class_bind_template_callback (widget_class, screen_delay_name_cb);
}
+static void
+update_display_config (CcScreenPanel *self)
+{
+ g_autoptr (CcDisplayConfig) config = NULL;
+ gboolean any_privacy_screen = FALSE;
+ gboolean any_configurable_privacy_screen = FALSE;
+ GList *monitors;
+ GList *l;
+
+ config = cc_display_config_manager_get_current (self->display_config_manager);
+ monitors = config ? cc_display_config_get_monitors (config) : NULL;
+
+ for (l = monitors; l; l = l->next)
+ {
+ CcDisplayMonitor *monitor = CC_DISPLAY_MONITOR (l->data);
+ CcDisplayMonitorPrivacy privacy = cc_display_monitor_get_privacy (monitor);
+
+ if (privacy != CC_DISPLAY_MONITOR_PRIVACY_UNSUPPORTED)
+ {
+ any_privacy_screen = TRUE;
+
+ if (!(privacy & CC_DISPLAY_MONITOR_PRIVACY_LOCKED))
+ any_configurable_privacy_screen = TRUE;
+ }
+ }
+
+ gtk_widget_set_visible (GTK_WIDGET (self->screen_privacy_group),
+ any_privacy_screen);
+ gtk_widget_set_sensitive (GTK_WIDGET (self->privacy_screen_switch),
+ any_configurable_privacy_screen);
+}
+
static void
cc_screen_panel_init (CcScreenPanel *self)
{
@@ -320,6 +363,18 @@ cc_screen_panel_init (CcScreenPanel *self)
"active",
G_SETTINGS_BIND_DEFAULT);
+ self->display_config_manager = cc_display_config_manager_dbus_new ();
+ g_signal_connect_object (self->display_config_manager, "changed",
+ G_CALLBACK (update_display_config), self,
+ G_CONNECT_SWAPPED);
+
+ update_display_config (self);
+ g_settings_bind (self->privacy_settings,
+ "privacy-screen",
+ self->privacy_screen_switch,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
G_DBUS_PROXY_FLAGS_NONE,
NULL,
diff --git a/panels/screen/cc-screen-panel.ui b/panels/screen/cc-screen-panel.ui
index 1f9fb78ca..831d5a7c8 100644
--- a/panels/screen/cc-screen-panel.ui
+++ b/panels/screen/cc-screen-panel.ui
@@ -102,6 +102,27 @@
</object>
</child>
+
+ <child>
+ <object class="AdwPreferencesGroup" id="screen_privacy_group">
+ <property name="title" translatable="yes">Screen Privacy</property>
+
+ <!-- Privacy Screen row -->
+ <child>
+ <object class="AdwActionRow">
+ <property name="title" translatable="yes">Restrict Viewing Angle</property>
+ <property name="activatable-widget">privacy_screen_switch</property>
+ <property name="use-underline">true</property>
+ <child>
+ <object class="GtkSwitch" id="privacy_screen_switch">
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+
</object>
</child>
</template>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]