diff options
author | Robert Tari <robert@tari.in> | 2021-08-25 22:38:17 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-08-28 13:51:34 +0200 |
commit | d6c09e65f1386e97e620b5fe972b96b1b2d207f4 (patch) | |
tree | 8aa7b9870069bb61d3745555ea93326a99d5b8a6 /src/service.vala | |
parent | c33bfccdc08bea14595094c00bc48edb357edfa5 (diff) | |
download | ayatana-indicator-sound-d6c09e65f1386e97e620b5fe972b96b1b2d207f4.tar.gz ayatana-indicator-sound-d6c09e65f1386e97e620b5fe972b96b1b2d207f4.tar.bz2 ayatana-indicator-sound-d6c09e65f1386e97e620b5fe972b96b1b2d207f4.zip |
Replace code with libayatana-common functions
- CMakeLists.txt: Add libayatana-common build dependency
- src/CMakeLists.txt: Add AyatanaCommon package to ayatana-indicator-sound-service
- src/service.vala: Replace local code with libayatana-common functions
- vapi/lomiri-url-dispatcher.vapi: Drop file
Diffstat (limited to 'src/service.vala')
-rw-r--r-- | src/service.vala | 55 |
1 files changed, 11 insertions, 44 deletions
diff --git a/src/service.vala b/src/service.vala index 6f19ed2..78c0f99 100644 --- a/src/service.vala +++ b/src/service.vala @@ -1,6 +1,6 @@ /* * Copyright 2013 Canonical Ltd. - * Copyright 2021 AyatanaIndicators + * 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 @@ -214,7 +214,6 @@ public class IndicatorSound.Service: Object { private VolumeWarning _volume_warning; private IndicatorSound.InfoNotification _info_notification = new IndicatorSound.InfoNotification(); private AccountsServiceAccess _accounts_service_access; - bool? is_unity = null; const double volume_step_percentage = 0.06; @@ -233,51 +232,27 @@ public class IndicatorSound.Service: Object { } } - private bool desktop_is_unity() { - if (is_unity != null) { - return is_unity; - } - - is_unity = false; - unowned string desktop = Environment.get_variable ("XDG_CURRENT_DESKTOP"); - - foreach (var name in desktop.split(":")) { - if (name == "Unity") { - is_unity = true; - break; - } - } - - return is_unity; - } - void activate_desktop_settings (SimpleAction action, Variant? param) { - unowned string env = Environment.get_variable ("DESKTOP_SESSION"); - unowned string xdg_desktop = Environment.get_variable ("XDG_CURRENT_DESKTOP"); string cmd; string arg; - /* FIXME: the below code needs to be moved into libayatana-common!!! */ - -#if HAS_URLDISPATCHER - if (Environment.get_variable ("MIR_SOCKET") != null) + if (AyatanaCommon.utils_is_lomiri()) { - LomiriURLDispatch.send ("settings:///system/sound"); + AyatanaCommon.utils_open_url("settings:///system/sound"); return; } -#endif - if (env == "xubuntu" || env == "xfce" || env == "ubuntustudio") + if (AyatanaCommon.utils_is_xfce()) { cmd = "pavucontrol"; arg = ""; } - else if ((env == "mate" || xdg_desktop == "MATE")) + else if (AyatanaCommon.utils_is_mate()) { cmd = "mate-volume-control"; arg = ""; } - else if (desktop_is_unity()) + else if (AyatanaCommon.utils_is_unity()) { cmd = "unity-control-center"; arg = "sound"; @@ -288,27 +263,19 @@ public class IndicatorSound.Service: Object { arg = "sound"; } - try + if (AyatanaCommon.utils_have_program(cmd) == false) { - if (Environment.find_program_in_path(cmd) == null) - { - string command_line = "zenity --warning --icon-name=\"dialog-warning\" --title=\"%s\" --text=\"%s\" --no-wrap".printf(_("Missing application"), _("Could not find the '%s' application - please make sure it is installed.").printf(cmd)); - Process.spawn_command_line_async(command_line); - } - else - { - Process.spawn_command_line_async(cmd + " " + arg); - } + AyatanaCommon.utils_zenity_warning("dialog-warning", _("Missing application"), _("Could not find the '%s' application - please make sure it is installed.").printf(cmd)); } - catch (Error e) + else { - warning("unable to launch sound settings: %s", e.message); + AyatanaCommon.utils_execute_command(cmd + " " + arg); } } #if HAS_URLDISPATCHER void activate_phone_settings (SimpleAction action, Variant? param) { - LomiriURLDispatch.send ("settings:///system/sound"); + AyatanaCommon.utils_open_url("settings:///system/sound"); } #endif |