From 0d9ac05177061f28b8e7b8613cbe3a1e34a36221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Fri, 29 Mar 2024 08:21:54 -0700 Subject: [PATCH] AppSettingsView: add screenshot permission --- src/Permissions/Widgets/AppSettingsView.vala | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/Permissions/Widgets/AppSettingsView.vala b/src/Permissions/Widgets/AppSettingsView.vala index f72b2a54..217cb4fb 100644 --- a/src/Permissions/Widgets/AppSettingsView.vala +++ b/src/Permissions/Widgets/AppSettingsView.vala @@ -24,11 +24,14 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage { private const string BACKGROUND_TABLE = "background"; private const string BACKGROUND_ID = "background"; + private const string SCREENSHOT_TABLE = "screenshot"; + private const string SCREENSHOT_ID = "screenshot"; private Gtk.ListBox sandbox_box; private Gtk.ListBox permission_box; private Gtk.Button reset_button; private PermissionSettingsWidget background_row; + private PermissionSettingsWidget screenshot_row; construct { notify["selected-app"].connect (update_view); @@ -145,6 +148,17 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage { permission_store.set_permission (BACKGROUND_TABLE, BACKGROUND_ID, selected_app.id, permissions); }); + screenshot_row = new PermissionSettingsWidget ( + _("Screenshot"), + _("Take pictures of the display without asking first."), + "applets-screenshooter" + ); + + screenshot_row.notify["active"].connect (() => { + string[] permissions = { screenshot_row.active ? "yes" : "no" }; + permission_store.set_permission (SCREENSHOT_TABLE, SCREENSHOT_ID, selected_app.id, permissions); + }); + update_permissions.begin (); permission_store.notify["dbus"].connect (update_permissions); permission_store.changed.connect (update_permissions); @@ -175,6 +189,15 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage { } } + var screenshot_permission = yield permission_store.get_permission (SCREENSHOT_TABLE, SCREENSHOT_ID, selected_app.id); + if (screenshot_permission[0] != null) { + screenshot_row.active = screenshot_permission[0] == "yes"; + + if (screenshot_row.parent == null) { + permission_box.append (screenshot_row); + } + } + permission_box.visible = permission_box.get_row_at_index (0) != null; }