aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-28 13:52:30 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-28 13:52:30 +0200
commit781af2ce90d68b6034524f5bf2242b70792e2b9f (patch)
tree8aa7b9870069bb61d3745555ea93326a99d5b8a6 /src
parentc33bfccdc08bea14595094c00bc48edb357edfa5 (diff)
parentd6c09e65f1386e97e620b5fe972b96b1b2d207f4 (diff)
downloadayatana-indicator-sound-781af2ce90d68b6034524f5bf2242b70792e2b9f.tar.gz
ayatana-indicator-sound-781af2ce90d68b6034524f5bf2242b70792e2b9f.tar.bz2
ayatana-indicator-sound-781af2ce90d68b6034524f5bf2242b70792e2b9f.zip
Merge branch 'tari01-pr/use-libayatana-common'
Attributes GH PR #32: https://github.com/AyatanaIndicators/ayatana-indicator-sound/pull/32
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/service.vala55
2 files changed, 12 insertions, 45 deletions
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