Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppSettingsView: add screenshot permission #222

Merged
merged 3 commits into from
Apr 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/Permissions/Widgets/AppSettingsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {
private const string BACKGROUND_ID = "background";
private const string LOCATION_TABLE = "location";
private const string LOCATION_ID = "location";
private const string SCREENSHOT_TABLE = "screenshot";
private const string SCREENSHOT_ID = "screenshot";
private const string WALLPAPER_TABLE = "wallpaper";
private const string WALLPAPER_ID = "wallpaper";

Expand All @@ -36,6 +38,7 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {
private Gtk.Button reset_button;
private PermissionSettingsWidget background_row;
private PermissionSettingsWidget location_row;
private PermissionSettingsWidget screenshot_row;
private PermissionSettingsWidget wallpaper_row;

construct {
Expand Down Expand Up @@ -176,6 +179,17 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {
permission_store.set_permission (LOCATION_TABLE, LOCATION_ID, selected_app.id, permissions);
});

screenshot_row = new PermissionSettingsWidget (
_("Screenshot"),
_("Take pictures of the display without asking first."),
"accessories-screenshot-tool"
);

screenshot_row.notify["active"].connect (() => {
string[] permissions = { screenshot_row.active ? "yes" : "no" };
permission_store.set_permission (SCREENSHOT_TABLE, SCREENSHOT_ID, selected_app.id, permissions);
});

wallpaper_row = new PermissionSettingsWidget (
_("Wallpaper"),
_("Set the wallpaper on the desktop and lock screen."),
Expand Down Expand Up @@ -229,6 +243,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);
}
}

var wallpaper_permission = yield permission_store.get_permission (WALLPAPER_TABLE, WALLPAPER_ID, selected_app.id);
if (wallpaper_permission[0] != null) {
wallpaper_row.active = wallpaper_permission[0] == "yes";
Expand Down
Loading