Skip to content

Commit

Permalink
Add Notifications settings (#238)
Browse files Browse the repository at this point in the history
* Add Notifications settings

* Update screenshot

---------

Co-authored-by: Ryan Kornheisl <ryan@skarva.tech>
  • Loading branch information
danirabbit and zeebok authored Oct 3, 2024
1 parent 16a922b commit b4f4660
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
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

0 comments on commit b4f4660

Please sign in to comment.