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

Add Notifications settings #238

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
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
Binary file modified data/screenshot-permissions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 NOTIFICATIONS_TABLE = "notifications";
private const string NOTIFICATION_ID = "notification";
private const string SCREENSHOT_TABLE = "screenshot";
private const string SCREENSHOT_ID = "screenshot";
private const string WALLPAPER_TABLE = "wallpaper";
Expand All @@ -37,6 +39,7 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {
private Gtk.ListBox permission_box;
private Gtk.Button reset_button;
private PermissionSettingsWidget background_row;
private PermissionSettingsWidget notifications_row;
private PermissionSettingsWidget location_row;
private PermissionSettingsWidget screenshot_row;
private PermissionSettingsWidget wallpaper_row;
Expand Down Expand Up @@ -193,6 +196,17 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {
permission_store.set_permission (LOCATION_TABLE, LOCATION_ID, selected_app.id, permissions);
});

notifications_row = new PermissionSettingsWidget (
_("Notications"),
_("Send notification bubbles that may play sound and appear in Notification Center."),
"preferences-system-notifications"
);

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

screenshot_row = new PermissionSettingsWidget (
_("Screenshot"),
_("Take pictures of the display without asking first."),
Expand Down Expand Up @@ -257,6 +271,15 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {
}
}

var notifications_permission = yield permission_store.get_permission (NOTIFICATIONS_TABLE, NOTIFICATION_ID, selected_app.id);
if (notifications_permission[0] != null) {
notifications_row.active = notifications_permission[0] == "yes";

if (notifications_row.parent == null) {
permission_box.append (notifications_row);
}
}

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";
Expand Down