Skip to content

Commit

Permalink
Add location permission setting
Browse files Browse the repository at this point in the history
  • Loading branch information
danirabbit committed Mar 29, 2024
1 parent c205a65 commit 26e5a60
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Permissions/Widgets/AppSettingsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,16 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {

private const string BACKGROUND_TABLE = "background";
private const string BACKGROUND_ID = "background";
private const string LOCATION_TABLE = "location";
private const string LOCATION_ID = "location";

private string location_timestamp = "0";

private Gtk.ListBox sandbox_box;
private Gtk.ListBox permission_box;
private Gtk.Button reset_button;
private PermissionSettingsWidget background_row;
private PermissionSettingsWidget location_row;

construct {
notify["selected-app"].connect (update_view);
Expand Down Expand Up @@ -145,6 +150,20 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {
permission_store.set_permission (BACKGROUND_TABLE, BACKGROUND_ID, selected_app.id, permissions);
});

location_row = new PermissionSettingsWidget (
_("Location Services"),
_("Determine the location of this device."),
"preferences-system-privacy-location"
);

location_row.notify["active"].connect (() => {
string[] permissions = {
location_row.active ? "EXACT" : "NONE",
location_timestamp
};
permission_store.set_permission (LOCATION_TABLE, LOCATION_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 +194,17 @@ public class Permissions.Widgets.AppSettingsView : Switchboard.SettingsPage {
}
}

var location_permission = yield permission_store.get_permission (LOCATION_TABLE, LOCATION_ID, selected_app.id);
if (location_permission[0] != null) {
// Values are usually EXACT or NONE, but safer to assume anything but NONE is active
location_row.active = location_permission[0] != "NONE";
location_timestamp = location_permission[1];

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

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

Expand Down

0 comments on commit 26e5a60

Please sign in to comment.