aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2021-08-27 14:05:43 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-28 14:22:15 +0200
commit3e045e899da78878f5f1da5f4d31ed05ad8aa008 (patch)
treeff6deeb31da0c4786f7ae7d522399dec04bb392a /src
parentf9dcff7b3a42082ad3ba6076991ed8aa7df9b6a8 (diff)
downloadayatana-indicator-bluetooth-3e045e899da78878f5f1da5f4d31ed05ad8aa008.tar.gz
ayatana-indicator-bluetooth-3e045e899da78878f5f1da5f4d31ed05ad8aa008.tar.bz2
ayatana-indicator-bluetooth-3e045e899da78878f5f1da5f4d31ed05ad8aa008.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/desktop.vala45
-rw-r--r--src/phone.vala12
3 files changed, 17 insertions, 42 deletions
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 <charles.kerr@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
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 <charles.kerr@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
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 ()