From 3e045e899da78878f5f1da5f4d31ed05ad8aa008 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Fri, 27 Aug 2021 14:05:43 +0200 Subject: Replace code with libayatana-common functions - CMakeLists.txt: Add libayatana-common build dependency - src/CMakeLists.txt: Add AyatanaCommon package to ayatana-indicator-bluetooth-service - src/phone.vala: Replace local code with libayatana-common functions - src/desktop.vala: Replace local code with libayatana-common functions - vapi/lomiri-url-dispatcher.vapi: Drop file --- src/CMakeLists.txt | 2 +- src/desktop.vala | 45 +++++++++++++-------------------------------- src/phone.vala | 12 +++--------- 3 files changed, 17 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90a4732..cb2e717 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,7 +19,7 @@ vala_init(ayatana-indicator-bluetooth-service posix gio-2.0 gio-unix-2.0 - ${VALA_PKG_URLDISPATCHER} + AyatanaCommon OPTIONS --ccode --target-glib=${GLIB_2_0_REQUIRED_VERSION} diff --git a/src/desktop.vala b/src/desktop.vala index 7102a21..56b61cb 100644 --- a/src/desktop.vala +++ b/src/desktop.vala @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 2021 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 @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr + * Robert Tari */ class Desktop: Profile @@ -64,7 +66,7 @@ class Desktop: Profile build_menu (); // know when to show the indicator & when to hide it - if (Environment.get_variable("MIR_SOCKET") != null) + if (AyatanaCommon.utils_is_lomiri()) { settings.changed["visible"].connect (()=> update_visibility()); bluetooth.notify["supported"].connect (() => update_visibility()); @@ -180,7 +182,7 @@ class Desktop: Profile item = new MenuItem (device.name, null); item.set_attribute_value ("icon", device.icon.serialize()); - if (Environment.get_variable("MIR_SOCKET") != null) + if (AyatanaCommon.utils_is_lomiri()) { item.set_submenu (submenu); } @@ -224,44 +226,23 @@ class Desktop: Profile /// Actions /// - private bool is_desktop (string name) - { - var desktop_name_list = Environment.get_variable ("XDG_CURRENT_DESKTOP"); - if (desktop_name_list == null) - return false; - - foreach (var n in desktop_name_list.split (":")) - if (n == name) - return true; - - return false; - } - void show_settings (string panel) { - -#if HAS_URLDISPATCHER - - if (Environment.get_variable ("MIR_SOCKET") != null) - { - LomiriUrlDispatch.send ("settings:///system/bluetooth"); - - return; - } - -#endif - - if (is_desktop ("Unity") && Environment.find_program_in_path ("unity-control-center") != null) + if (AyatanaCommon.utils_is_lomiri()) + { + AyatanaCommon.utils_open_url("settings:///system/bluetooth"); + } + else if (AyatanaCommon.utils_is_unity() && AyatanaCommon.utils_have_program("unity-control-center")) { - spawn_command_line_async ("unity-control-center " + panel); + AyatanaCommon.utils_execute_command("unity-control-center " + panel); } - else if (is_desktop ("MATE") && Environment.find_program_in_path ("blueman-manager") != null) + else if (AyatanaCommon.utils_is_mate() && AyatanaCommon.utils_have_program("blueman-manager")) { - spawn_command_line_async ("blueman-manager"); + AyatanaCommon.utils_execute_command("blueman-manager"); } else { - spawn_command_line_async ("gnome-control-center " + panel); + AyatanaCommon.utils_execute_command("gnome-control-center " + panel); } } diff --git a/src/phone.vala b/src/phone.vala index 3490768..075096f 100644 --- a/src/phone.vala +++ b/src/phone.vala @@ -1,5 +1,6 @@ /* * Copyright 2013 Canonical Ltd. + * Copyright 2021 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 @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr + * Robert Tari */ class Phone: Profile @@ -62,15 +64,7 @@ class Phone: Profile void show_settings (string panel) { - -#if HAS_URLDISPATCHER - - LomiriUrlDispatch.send ("settings:///system/bluetooth"); - -#endif - - return; - + AyatanaCommon.utils_open_url("settings:///system/bluetooth"); } Action create_settings_action () -- cgit v1.2.3