From ce2286e1c9cdea9a8fe8ffccd854ce268c1c645f Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 11 Jun 2026 19:40:30 +0200 Subject: phone_greeter: Introduce profile that applies to bt indicator when run as part of a phone's greeter --- src/CMakeLists.txt | 13 +++++++++++-- src/desktop_greeter.vala | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ src/greeter.vala | 50 ------------------------------------------------ src/phone_greeter.vala | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ src/service.vala | 3 ++- 5 files changed, 113 insertions(+), 53 deletions(-) create mode 100644 src/desktop_greeter.vala delete mode 100644 src/greeter.vala create mode 100644 src/phone_greeter.vala (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d616baf..d63eda2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,7 +56,7 @@ vala_add(ayatana-indicator-bluetooth-service ) vala_add(ayatana-indicator-bluetooth-service - greeter.vala + desktop_greeter.vala DEPENDS profile bluetooth @@ -79,6 +79,14 @@ vala_add(ayatana-indicator-bluetooth-service device ) +vala_add(ayatana-indicator-bluetooth-service + phone_greeter.vala + DEPENDS + profile + bluetooth + device +) + vala_add(ayatana-indicator-bluetooth-service profile.vala DEPENDS @@ -93,8 +101,9 @@ vala_add(ayatana-indicator-bluetooth-service profile device phone + phone_greeter desktop - greeter + desktop_greeter agent ) diff --git a/src/desktop_greeter.vala b/src/desktop_greeter.vala new file mode 100644 index 0000000..01737e0 --- /dev/null +++ b/src/desktop_greeter.vala @@ -0,0 +1,50 @@ +/* +* Copyright 2025 Robert Tari +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 3. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +class DesktopGreeter: Profile +{ + GLib.SimpleActionGroup action_group; + + public DesktopGreeter (Bluetooth bluetooth, GLib.SimpleActionGroup action_group) + { + base (bluetooth, "desktop_greeter"); + this.bluetooth = bluetooth; + this.action_group = action_group; + GLib.Action[] actions = {}; + actions += root_action; + actions += create_supported_action (bluetooth); + actions += create_enabled_action (bluetooth); + + foreach (GLib.Action action in actions) + { + action_group.add_action (action); + } + + GLib.Menu section = new GLib.Menu (); + GLib.MenuItem menu_item = create_enabled_menuitem (); + section.append_item (menu_item); + menu.append_section (null, section); + + bluetooth.notify.connect (() => update_visibility ()); + update_visibility (); + bluetooth.notify.connect (() => update_root_action_state ()); + } + + void update_visibility () + { + visible = bluetooth.enabled; + } +} diff --git a/src/greeter.vala b/src/greeter.vala deleted file mode 100644 index 17c2042..0000000 --- a/src/greeter.vala +++ /dev/null @@ -1,50 +0,0 @@ -/* -* Copyright 2025 Robert Tari -* -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; version 3. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -class Greeter: Profile -{ - GLib.SimpleActionGroup action_group; - - public Greeter (Bluetooth bluetooth, GLib.SimpleActionGroup action_group) - { - base (bluetooth, "greeter"); - this.bluetooth = bluetooth; - this.action_group = action_group; - GLib.Action[] actions = {}; - actions += root_action; - actions += create_supported_action (bluetooth); - actions += create_enabled_action (bluetooth); - - foreach (GLib.Action action in actions) - { - action_group.add_action (action); - } - - GLib.Menu section = new GLib.Menu (); - GLib.MenuItem menu_item = create_enabled_menuitem (); - section.append_item (menu_item); - menu.append_section (null, section); - - bluetooth.notify.connect (() => update_visibility ()); - update_visibility (); - bluetooth.notify.connect (() => update_root_action_state ()); - } - - void update_visibility () - { - visible = bluetooth.enabled; - } -} diff --git a/src/phone_greeter.vala b/src/phone_greeter.vala new file mode 100644 index 0000000..d9fe437 --- /dev/null +++ b/src/phone_greeter.vala @@ -0,0 +1,50 @@ +/* +* Copyright 2025 Robert Tari +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; version 3. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +class PhoneGreeter: Profile +{ + GLib.SimpleActionGroup action_group; + + public PhoneGreeter (Bluetooth bluetooth, GLib.SimpleActionGroup action_group) + { + base (bluetooth, "phone_greeter"); + this.bluetooth = bluetooth; + this.action_group = action_group; + GLib.Action[] actions = {}; + actions += root_action; + actions += create_supported_action (bluetooth); + actions += create_enabled_action (bluetooth); + + foreach (GLib.Action action in actions) + { + action_group.add_action (action); + } + + GLib.Menu section = new GLib.Menu (); + GLib.MenuItem menu_item = create_enabled_menuitem (); + section.append_item (menu_item); + menu.append_section (null, section); + + bluetooth.notify.connect (() => update_visibility ()); + update_visibility (); + bluetooth.notify.connect (() => update_root_action_state ()); + } + + void update_visibility () + { + visible = bluetooth.enabled; + } +} diff --git a/src/service.vala b/src/service.vala index cff90d3..f5b33be 100644 --- a/src/service.vala +++ b/src/service.vala @@ -78,8 +78,9 @@ public class Service: Object profiles = new HashTable (str_hash, str_equal); profiles.insert ("phone", new Phone (bluetooth, actions)); + profiles.insert ("phone_greeter", new PhoneGreeter (bluetooth, actions)); profiles.insert ("desktop", new Desktop (bluetooth, actions)); - profiles.insert ("greeter", new Greeter (bluetooth, actions)); + profiles.insert ("desktop_greeter", new DesktopGreeter (bluetooth, actions)); } public int run () -- cgit v1.2.3