diff --git a/data/gresource.xml b/data/gresource.xml index aa209733..28af4ea2 100644 --- a/data/gresource.xml +++ b/data/gresource.xml @@ -6,7 +6,8 @@ icons/account.svg icons/account.svg - + icons/location.svg + icons/location.svg icons/screencast.svg icons/screencast.svg diff --git a/data/icons/location.svg b/data/icons/location.svg new file mode 100644 index 00000000..6bbabff6 --- /dev/null +++ b/data/icons/location.svg @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + diff --git a/po/POTFILES b/po/POTFILES index 3691af5a..7be8ce28 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -1,5 +1,6 @@ src/XdgDesktopPortalPantheon.vala src/ExternalWindow.vala +src/Access/LocationDialog.vala src/Access/Portal.vala src/Access/Dialog.vala src/Account/Dialog.vala diff --git a/src/Access/LocationDialog.vala b/src/Access/LocationDialog.vala new file mode 100644 index 00000000..d8cb5c0f --- /dev/null +++ b/src/Access/LocationDialog.vala @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2026 elementary, Inc. (https://elementary.io) + * SPDX-License-Identifier: LGPL-2.1-or-later + */ + +public class Access.LocationDialog : Access.Dialog { + public string app_id { get; construct; } + + public LocationDialog (string app_id) { + Object (app_id: app_id); + } + + construct { + title = _("An application wants to access your location"); + secondary_text = _("Permissions can be changed in Location Settings…"); + secondary_icon = new ThemedIcon ("emblem-portal-location"); + + if (app_id != "") { + var app_info = new DesktopAppInfo (app_id + ".desktop"); + if (app_info != null) { + title = _("“%s” wants to access your location").printf (app_info.get_display_name ()); + } + } + } +} diff --git a/src/Access/Portal.vala b/src/Access/Portal.vala index 7a0bd0bc..820faa38 100644 --- a/src/Access/Portal.vala +++ b/src/Access/Portal.vala @@ -31,6 +31,18 @@ public class Access.Portal : Object { parent_handle = parent_window }; + if ("icon" in options) { + // elementary HIG use non-symbolic icon, while portals ask for symbolic ones. + var icon = options["icon"].get_string ().replace ("-symbolic", ""); + if (icon == "find-location") { + dialog = new LocationDialog (app_id) { + parent_handle = parent_window + }; + } else { + dialog.secondary_icon = new ThemedIcon (icon); + } + } + if (app_id != "") { dialog.primary_icon = new DesktopAppInfo (app_id + ".desktop").get_icon (); } else { @@ -42,20 +54,15 @@ public class Access.Portal : Object { dialog.action_type = DESTRUCTIVE; } - if ("icon" in options) { - // elementary HIG use non-symbolic icon, while portals ask for symbolic ones. - dialog.secondary_icon = new ThemedIcon (options["icon"].get_string ().replace ("-symbolic", "")); - } - if ("modal" in options) { dialog.modal = options["modal"].get_boolean (); } - if ("deny_label" in options) { + if ("deny_label" in options && !(dialog is LocationDialog)) { dialog.cancel_label = options["deny_label"].get_string (); } - if ("grant_label" in options) { + if ("grant_label" in options && !(dialog is LocationDialog)) { dialog.allow_label = options["grant_label"].get_string (); } diff --git a/src/meson.build b/src/meson.build index 82962862..5d0b4b34 100644 --- a/src/meson.build +++ b/src/meson.build @@ -2,6 +2,7 @@ executable( meson.project_name(), 'Access/Choice.vala', 'Access/Dialog.vala', + 'Access/LocationDialog.vala', 'Access/Portal.vala', 'Account' / 'Dialog.vala', 'Account' / 'Portal.vala',