From caf644eb350d2035f40bd7d4b147ff732b90e53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Danielle=20For=C3=A9?= Date: Mon, 17 Jun 2024 11:55:14 -0700 Subject: [PATCH 1/4] Show when location services are in use --- data/Indicator.css | 5 +++++ po/POTFILES | 1 + src/DBus/GeoclueManager.vala | 9 ++++++++ src/PopoverWidget.vala | 5 +++++ src/Widgets/TattleBox.vala | 41 ++++++++++++++++++++++++++++++++++++ src/meson.build | 2 ++ 6 files changed, 63 insertions(+) create mode 100644 src/DBus/GeoclueManager.vala create mode 100644 src/Widgets/TattleBox.vala diff --git a/data/Indicator.css b/data/Indicator.css index 4ca5a81..a33f1f7 100644 --- a/data/Indicator.css +++ b/data/Indicator.css @@ -3,6 +3,11 @@ * SPDX-FileCopyrightText: 2023 elementary, Inc. (https://elementary.io) */ + +quicksettings tattlebox box { + padding: 0.666rem; /* 6px */ +} + quicksettings scalebox, quicksettings .togglebox { padding: 0.666rem; /* 6px */ diff --git a/po/POTFILES b/po/POTFILES index acc6a9f..badc844 100644 --- a/po/POTFILES +++ b/po/POTFILES @@ -11,4 +11,5 @@ src/Widgets/EndSessionDialog.vala src/Widgets/RotationToggle.vala src/Widgets/SessionBox.vala src/Widgets/SettingsToggle.vala +src/Widgets/TattleBox.vala src/Widgets/TextScale.vala diff --git a/src/DBus/GeoclueManager.vala b/src/DBus/GeoclueManager.vala new file mode 100644 index 0000000..fe9b470 --- /dev/null +++ b/src/DBus/GeoclueManager.vala @@ -0,0 +1,9 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * SPDX-FileCopyrightText: 2011-2024 elementary, Inc. (https://elementary.io) + */ + +[DBus (name = "org.freedesktop.GeoClue2.Manager")] +interface QuickSettings.GeoclueManager : DBusProxy { + public abstract bool in_use { get; } +} diff --git a/src/PopoverWidget.vala b/src/PopoverWidget.vala index 8e33db2..ed54e78 100644 --- a/src/PopoverWidget.vala +++ b/src/PopoverWidget.vala @@ -20,6 +20,10 @@ public class QuickSettings.PopoverWidget : Gtk.Box { } construct { + var tattle_box = new TattleBox () { + halign = CENTER + }; + var screen_reader = new SettingsToggle ( new ThemedIcon ("orca-symbolic"), _("Screen Reader") @@ -64,6 +68,7 @@ public class QuickSettings.PopoverWidget : Gtk.Box { bottom_box.get_style_context ().add_class ("togglebox"); var main_box = new Gtk.Box (VERTICAL, 0); + main_box.add (tattle_box); main_box.add (toggle_box); main_box.add (scale_box); main_box.add (new Gtk.Separator (HORIZONTAL)); diff --git a/src/Widgets/TattleBox.vala b/src/Widgets/TattleBox.vala new file mode 100644 index 0000000..39dc81b --- /dev/null +++ b/src/Widgets/TattleBox.vala @@ -0,0 +1,41 @@ +public class QuickSettings.TattleBox : Gtk.Bin { + class construct { + set_css_name ("tattlebox"); + } + + construct { + var location_image = new Gtk.Image.from_icon_name ("location-active-symbolic", MENU); + location_image.get_style_context ().add_class (Granite.STYLE_CLASS_ACCENT); + location_image.get_style_context ().add_class ("purple"); + + var location_label = new Gtk.Label (_("Location services in use")); + + var location_box = new Gtk.Box (HORIZONTAL, 3); + location_box.add (location_image); + location_box.add (location_label); + + var location_revealer = new Gtk.Revealer () { + child = location_box + }; + + child = location_revealer; + + setup_geoclue_manager.begin ((obj, res) => { + var geoclue_manager = setup_geoclue_manager.end (res); + location_revealer.reveal_child = geoclue_manager.in_use; + + geoclue_manager.g_properties_changed.connect (() => { + location_revealer.reveal_child = geoclue_manager.in_use; + }); + }); + } + + private async GeoclueManager? setup_geoclue_manager () { + try { + return yield Bus.get_proxy (BusType.SYSTEM, "org.freedesktop.GeoClue2", "/org/freedesktop/GeoClue2/Manager"); + } catch (Error e) { + info ("Unable to connect to GeoClue2 bus, location tattle tale will not be available: %s", e.message); + return null; + } + } +} diff --git a/src/meson.build b/src/meson.build index 9f2e790..49acf04 100644 --- a/src/meson.build +++ b/src/meson.build @@ -12,6 +12,7 @@ sources = [ 'PopoverWidget.vala', 'DBus' / 'AccountsService.vala', 'DBus' / 'EndSessionDialogServer.vala', + 'DBus' / 'GeoclueManager.vala', 'DBus' / 'LockInterface.vala', 'DBus' / 'SensorProxy.vala', 'DBus' / 'SessionInterface.vala', @@ -21,6 +22,7 @@ sources = [ 'Widgets' / 'RotationToggle.vala', 'Widgets' / 'SettingsToggle.vala', 'Widgets' / 'SessionBox.vala', + 'Widgets' / 'TattleBox.vala', 'Widgets' / 'TextScale.vala', ] From f4c68879bbfa4218fb190c8ee4de980db046669f Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Sat, 27 Sep 2025 09:12:17 +0900 Subject: [PATCH 2/4] Fix missing copyright header --- src/Widgets/TattleBox.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Widgets/TattleBox.vala b/src/Widgets/TattleBox.vala index 39dc81b..f59f08e 100644 --- a/src/Widgets/TattleBox.vala +++ b/src/Widgets/TattleBox.vala @@ -1,3 +1,8 @@ +/* + * SPDX-License-Identifier: GPL-2.0-or-later + * SPDX-FileCopyrightText: 2011-2024 elementary, Inc. (https://elementary.io) + */ + public class QuickSettings.TattleBox : Gtk.Bin { class construct { set_css_name ("tattlebox"); From 26b4220a1f53b433ad767f63ad478addede8e2da Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Sat, 27 Sep 2025 09:13:32 +0900 Subject: [PATCH 3/4] Fix missing null check --- src/Widgets/TattleBox.vala | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Widgets/TattleBox.vala b/src/Widgets/TattleBox.vala index f59f08e..2bf2bc3 100644 --- a/src/Widgets/TattleBox.vala +++ b/src/Widgets/TattleBox.vala @@ -27,6 +27,10 @@ public class QuickSettings.TattleBox : Gtk.Bin { setup_geoclue_manager.begin ((obj, res) => { var geoclue_manager = setup_geoclue_manager.end (res); + if (geoclue_manager == null) { + return; + } + location_revealer.reveal_child = geoclue_manager.in_use; geoclue_manager.g_properties_changed.connect (() => { From d30c488d4a7c0488910178fd6c6d00373e48ff23 Mon Sep 17 00:00:00 2001 From: Ryo Nakano Date: Sat, 27 Sep 2025 09:15:16 +0900 Subject: [PATCH 4/4] Bump copyright year --- data/Indicator.css | 3 +-- src/DBus/GeoclueManager.vala | 2 +- src/Widgets/TattleBox.vala | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/data/Indicator.css b/data/Indicator.css index fce373d..688485b 100644 --- a/data/Indicator.css +++ b/data/Indicator.css @@ -1,9 +1,8 @@ /* * SPDX-License-Identifier: GPL-3.0-or-later - * SPDX-FileCopyrightText: 2023 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2025 elementary, Inc. (https://elementary.io) */ - quicksettings tattlebox box { padding: 0.666rem; /* 6px */ } diff --git a/src/DBus/GeoclueManager.vala b/src/DBus/GeoclueManager.vala index fe9b470..f907f8e 100644 --- a/src/DBus/GeoclueManager.vala +++ b/src/DBus/GeoclueManager.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-2.0-or-later - * SPDX-FileCopyrightText: 2011-2024 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2011-2025 elementary, Inc. (https://elementary.io) */ [DBus (name = "org.freedesktop.GeoClue2.Manager")] diff --git a/src/Widgets/TattleBox.vala b/src/Widgets/TattleBox.vala index 2bf2bc3..946c86a 100644 --- a/src/Widgets/TattleBox.vala +++ b/src/Widgets/TattleBox.vala @@ -1,6 +1,6 @@ /* * SPDX-License-Identifier: GPL-2.0-or-later - * SPDX-FileCopyrightText: 2011-2024 elementary, Inc. (https://elementary.io) + * SPDX-FileCopyrightText: 2011-2025 elementary, Inc. (https://elementary.io) */ public class QuickSettings.TattleBox : Gtk.Bin {