Skip to content

Commit

Permalink
AppSettingsView: add wallpaper permission
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Mar 29, 2024
1 parent 7aee4bb commit af87964
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 WALLPAPER_TABLE = "wallpaper";
private const string WALLPAPER_ID = "wallpaper";

private Gtk.ListBox sandbox_box;
private Gtk.ListBox permission_box;
private Gtk.Button reset_button;
private PermissionSettingsWidget background_row;
private PermissionSettingsWidget wallpaper_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);
});

wallpaper_row = new PermissionSettingsWidget (
_("Wallpaper"),
_("Set the wallpaper on the desktop and lock screen."),
"preferences-desktop-wallpaper"
);

wallpaper_row.notify["active"].connect (() => {
string[] permissions = { wallpaper_row.active ? "yes" : "no" };
permission_store.set_permission (WALLPAPER_TABLE, WALLPAPER_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 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";

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

permission_box.visible = permission_box.get_row_at_index (0) != null;
}

Expand Down

0 comments on commit af87964

Please sign in to comment.