aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDylan McCall <dylanmccall@ubuntu.com>2011-04-04 20:14:19 -0700
committerDylan McCall <dylanmccall@ubuntu.com>2011-04-04 20:14:19 -0700
commit1c1adfebc0a8c9fc1a64f89fa879823ff316ecec (patch)
tree550bacf75c64d9db6d459f465ffaeeb600d81665 /src
parent15c7802a9f753b0d06e7690ae24402644cd12bfe (diff)
downloadayatana-indicator-sound-1c1adfebc0a8c9fc1a64f89fa879823ff316ecec.tar.gz
ayatana-indicator-sound-1c1adfebc0a8c9fc1a64f89fa879823ff316ecec.tar.bz2
ayatana-indicator-sound-1c1adfebc0a8c9fc1a64f89fa879823ff316ecec.zip
Sound state manager volume notification is based on new volume instead of current (old) volume.
Notifications use notification variants of audio-volume-* icons.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am4
-rw-r--r--src/device.c17
-rw-r--r--src/sound-state-manager.c14
-rw-r--r--src/sound-state.c43
-rw-r--r--src/sound-state.h31
5 files changed, 88 insertions, 21 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index ae0d55a..bafd6be 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,8 @@ libsoundmenu_la_SOURCES = \
common-defs.h \
indicator-sound.h \
indicator-sound.c \
+ sound-state.c \
+ sound-state.h \
sound-state-manager.c \
sound-state-manager.h \
transport-widget.c \
@@ -90,6 +92,8 @@ indicator_sound_service_SOURCES = \
common-defs.h \
sound-service.h \
sound-service.c \
+ sound-state.c \
+ sound-state.h \
pulseaudio-mgr.h \
pulseaudio-mgr.c \
device.c \
diff --git a/src/device.c b/src/device.c
index 79b7b50..a3e8019 100644
--- a/src/device.c
+++ b/src/device.c
@@ -23,6 +23,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "mute-menu-item.h"
#include "voip-input-menu-item.h"
#include "pulseaudio-mgr.h"
+#include "sound-state.h"
typedef struct _DevicePrivate DevicePrivate;
@@ -164,21 +165,7 @@ device_get_state_from_volume (Device* self)
DBUSMENU_VOLUME_MENUITEM_LEVEL);
gdouble volume_percent = g_variant_get_double (v);
- SoundState state = LOW_LEVEL;
-
- if (volume_percent < 30.0 && volume_percent > 0) {
- state = LOW_LEVEL;
- }
- else if (volume_percent < 70.0 && volume_percent >= 30.0) {
- state = MEDIUM_LEVEL;
- }
- else if (volume_percent >= 70.0) {
- state = HIGH_LEVEL;
- }
- else if (volume_percent == 0.0) {
- state = ZERO_LEVEL;
- }
- return state;
+ return sound_state_get_from_volume ((int)volume_percent);
}
void
diff --git a/src/sound-state-manager.c b/src/sound-state-manager.c
index 7095a39..c851407 100644
--- a/src/sound-state-manager.c
+++ b/src/sound-state-manager.c
@@ -24,6 +24,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sound-state-manager.h"
#include "dbus-shared-names.h"
+#include "sound-state.h"
typedef struct _SoundStateManagerPrivate SoundStateManagerPrivate;
@@ -170,19 +171,20 @@ sound_state_manager_show_notification (SoundStateManager *self,
char *icon;
const int notify_value = CLAMP((int)value, -1, 101);
- SoundState state = sound_state_manager_get_current_state (self);
+
+ SoundState state = sound_state_get_from_volume ((int)value);
if (state == ZERO_LEVEL) {
// Not available for all the themes
- icon = "audio-volume-off";
+ icon = "notification-audio-volume-off";
} else if (state == LOW_LEVEL) {
- icon = "audio-volume-low";
+ icon = "notification-audio-volume-low";
} else if (state == MEDIUM_LEVEL) {
- icon = "audio-volume-medium";
+ icon = "notification-audio-volume-medium";
} else if (state == HIGH_LEVEL) {
- icon = "audio-volume-high";
+ icon = "notification-audio-volume-high";
} else {
- icon = "audio-volume-muted";
+ icon = "notification-audio-volume-muted";
}
notify_notification_update(priv->notification, PACKAGE_NAME, NULL, icon);
diff --git a/src/sound-state.c b/src/sound-state.c
new file mode 100644
index 0000000..72e411a
--- /dev/null
+++ b/src/sound-state.c
@@ -0,0 +1,43 @@
+/*
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "config.h"
+
+#include "sound-state.h"
+
+SoundState
+sound_state_get_from_volume (int volume_percent)
+{
+ SoundState state = LOW_LEVEL;
+
+ if (volume_percent < 30 && volume_percent > 0) {
+ state = LOW_LEVEL;
+ }
+ else if (volume_percent < 70 && volume_percent >= 30) {
+ state = MEDIUM_LEVEL;
+ }
+ else if (volume_percent >= 70) {
+ state = HIGH_LEVEL;
+ }
+ else if (volume_percent <= 0) {
+ state = ZERO_LEVEL;
+ }
+ return state;
+}
+
diff --git a/src/sound-state.h b/src/sound-state.h
new file mode 100644
index 0000000..9527c8e
--- /dev/null
+++ b/src/sound-state.h
@@ -0,0 +1,31 @@
+/*
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Conor Curran <conor.curran@canonical.com>
+
+This program is free software: you can redistribute it and/or modify it
+under the terms of the GNU General Public License version 3, as published
+by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranties of
+MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _SOUND_STATE_H_
+#define _SOUND_STATE_H_
+
+#include <glib.h>
+#include "common-defs.h"
+
+/* Helper functions for determining SOUNDSTATE */
+
+SoundState sound_state_get_from_volume (int volume_percent);
+
+#endif /* _SOUND_STATE_H_ */
+