aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharles kerr <charlesk@canonical.com>2016-01-01 19:37:51 -0600
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-28 10:17:14 +0200
commit460f1464709a4c5e2c1594045961be9108ae2afd (patch)
tree8bee12f505a68322e5e7102ddd4b7b2bf675ea33
parentc7881a2d849191e1b6243da75ebf9140d29655cb (diff)
downloadayatana-indicator-power-460f1464709a4c5e2c1594045961be9108ae2afd.tar.gz
ayatana-indicator-power-460f1464709a4c5e2c1594045961be9108ae2afd.tar.bz2
ayatana-indicator-power-460f1464709a4c5e2c1594045961be9108ae2afd.zip
use a symbolic constant for the low battery sound's filename
-rw-r--r--CMakeLists.txt3
-rw-r--r--src/notifier.c2
-rw-r--r--tests/test-notify.cc7
3 files changed, 9 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 927a0bf..3d59545 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,7 +41,8 @@ set (CMAKE_INSTALL_FULL_PKGLIBEXECDIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${CMAKE_
set(GETTEXT_PACKAGE "ayatana-indicator-power")
add_definitions (-DGETTEXT_PACKAGE="${GETTEXT_PACKAGE}"
- -DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}")
+ -DLOCALEDIR="${CMAKE_INSTALL_FULL_LOCALEDIR}"
+ -DLOW_BATTERY_SOUND="Low battery.ogg")
##
## Check for prerequisites
diff --git a/src/notifier.c b/src/notifier.c
index d5e8b5d..7d81f3a 100644
--- a/src/notifier.c
+++ b/src/notifier.c
@@ -146,7 +146,7 @@ get_battery_power_level (IndicatorPowerDevice * battery)
static void
play_low_battery_sound (IndicatorPowerNotifier * self)
{
- const gchar * const key = "Low battery.ogg";
+ const gchar * const key = LOW_BATTERY_SOUND;
gchar * filename;
priv_t * const p = get_priv(self);
diff --git a/tests/test-notify.cc b/tests/test-notify.cc
index 6fe7c59..0d92d7a 100644
--- a/tests/test-notify.cc
+++ b/tests/test-notify.cc
@@ -359,9 +359,14 @@ TEST_F(NotifyFixture, EventsThatChangeNotifications)
30,
TRUE);
+ // the file we expect to play on a low battery notification...
+ const char* expected_file = XDG_DATA_HOME "/" GETTEXT_PACKAGE "/sounds/" LOW_BATTERY_SOUND;
+ char* tmp = g_filename_to_uri(expected_file, nullptr, nullptr);
+ const std::string low_power_uri {tmp};
+ g_clear_pointer(&tmp, g_free);
+
// set up a notifier and give it the battery so changing the battery's
// charge should show up on the bus.
- const std::string low_power_uri {"file://" XDG_DATA_HOME "/" GETTEXT_PACKAGE "/sounds/Low%20battery.ogg"};
std::string last_uri;
auto sound_player = indicator_power_sound_player_mock_new ();
g_signal_connect(sound_player, "uri-played", G_CALLBACK(on_uri_played), &last_uri);