Skip to content

Commit

Permalink
AppSettingsView: add screenshot permission (#222)
Browse files Browse the repository at this point in the history
* AppSettingsView: add screenshot permission

* Update AppSettingsView.vala
  • Loading branch information
danirabbit authored Apr 3, 2024
1 parent f0448f5 commit 1639043
Showing 1 changed file with 23 additions and 0 deletions.
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

0 comments on commit 1639043

Please sign in to comment.