aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt1
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/service.vala55
-rw-r--r--vapi/lomiri-url-dispatcher.vapi9
4 files changed, 13 insertions, 54 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 760983b..e83d738 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -66,6 +66,7 @@ pkg_check_modules(
libxml-2.0
libnotify
accountsservice
+ libayatana-common
)
include_directories(${SOUNDSERVICE_INCLUDE_DIRS})
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index fb6e422..7dae84a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -60,7 +60,7 @@ vala_init(ayatana-indicator-sound-service
libpulse-mainloop-glib
libnotify
accounts-service
- ${VALA_PKG_URLDISPATCHER}
+ AyatanaCommon
OPTIONS
--ccode
--target-glib=${GLIB_2_0_REQUIRED_VERSION}
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
diff --git a/vapi/lomiri-url-dispatcher.vapi b/vapi/lomiri-url-dispatcher.vapi
deleted file mode 100644
index 1285b12..0000000
--- a/vapi/lomiri-url-dispatcher.vapi
+++ /dev/null
@@ -1,9 +0,0 @@
-[CCode (cprefix="", lower_case_cprefix="", cheader_filename="liblomiri-url-dispatcher/lomiri-url-dispatcher.h")]
-
-namespace LomiriURLDispatch
-{
- public delegate void LomiriURLDispatchCallback ();
-
- [CCode (cname = "lomiri_url_dispatch_send")]
- public static void send (string url, LomiriURLDispatchCallback? func = null);
-}