Skip to content

Commit

Permalink
AppSettingsView: add screenshot permission
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Mar 29, 2024
1 parent 7aee4bb commit 0d9ac05
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 @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 0d9ac05

Please sign in to comment.