aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-01-27 16:10:48 -0600
committerConor Curran <conor.curran@canonical.com>2011-01-27 16:10:48 -0600
commit4e0d98ea31ff315c03d2a297af0743cd92acfedf (patch)
treeaa30531c2fdee93f00704365fd1bab2cfad1e30e /src
parentb6b241d47f33a67b6f61f9860a278a6582113835 (diff)
downloadayatana-indicator-sound-4e0d98ea31ff315c03d2a297af0743cd92acfedf.tar.gz
ayatana-indicator-sound-4e0d98ea31ff315c03d2a297af0743cd92acfedf.tar.bz2
ayatana-indicator-sound-4e0d98ea31ff315c03d2a297af0743cd92acfedf.zip
sink automatically unmuted now when slider is manually changed in accordance with the spec revision, plus some tidy ups
Diffstat (limited to 'src')
-rw-r--r--src/indicator-sound.c1
-rw-r--r--src/mute-menu-item.c30
-rw-r--r--src/mute-menu-item.h4
-rw-r--r--src/pulse-manager.c2
-rw-r--r--src/pulse-manager.h2
-rw-r--r--src/slider-menu-item.c9
-rw-r--r--src/sound-service-dbus.c60
-rw-r--r--src/sound-service.xml1
-rw-r--r--src/sound-state-manager.c3
9 files changed, 69 insertions, 43 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 3c65a90..42560c8 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -278,7 +278,6 @@ static void create_connection_to_service (GObject *source_object,
g_error_free(error);
return;
}
- g_debug ("Connection to dbus seemed to work fine from the indicator side");
sound_state_manager_connect_to_dbus (priv->state_manager,
priv->dbus_proxy);
diff --git a/src/mute-menu-item.c b/src/mute-menu-item.c
index 2f40177..f7f3824 100644
--- a/src/mute-menu-item.c
+++ b/src/mute-menu-item.c
@@ -43,7 +43,8 @@ static void mute_menu_item_set_global_mute_from_ui (gpointer user_data);
G_DEFINE_TYPE (MuteMenuItem, mute_menu_item, G_TYPE_OBJECT);
-static void mute_menu_item_class_init (MuteMenuItemClass *klass)
+static void
+mute_menu_item_class_init (MuteMenuItemClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -55,7 +56,8 @@ static void mute_menu_item_class_init (MuteMenuItemClass *klass)
return;
}
-static void mute_menu_item_init (MuteMenuItem *self)
+static void
+mute_menu_item_init (MuteMenuItem *self)
{
g_debug("Building new Mute Menu Item");
MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE(self);
@@ -68,7 +70,8 @@ static void mute_menu_item_init (MuteMenuItem *self)
return;
}
-static void mute_menu_item_dispose (GObject *object)
+static void
+mute_menu_item_dispose (GObject *object)
{
G_OBJECT_CLASS (mute_menu_item_parent_class)->dispose (object);
return;
@@ -93,8 +96,8 @@ mute_menu_item_set_global_mute_from_ui (gpointer user_data)
toggle_global_mute (new_value);
}
-
-void mute_menu_item_update(MuteMenuItem* item, gboolean value_update)
+void
+mute_menu_item_update (MuteMenuItem* item, gboolean value_update)
{
MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE (item);
@@ -106,7 +109,8 @@ void mute_menu_item_update(MuteMenuItem* item, gboolean value_update)
value_update == FALSE ? _("Mute") : _("Unmute"));
}
-void mute_menu_item_enable(MuteMenuItem* item, gboolean active)
+void
+mute_menu_item_enable (MuteMenuItem* item, gboolean active)
{
MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE (item);
@@ -115,13 +119,23 @@ void mute_menu_item_enable(MuteMenuItem* item, gboolean active)
active);
}
-DbusmenuMenuitem* mute_menu_item_get_button (MuteMenuItem* item)
+DbusmenuMenuitem*
+mute_menu_item_get_button (MuteMenuItem* item)
{
MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE (item);
return priv->button;
}
-MuteMenuItem* mute_menu_item_new (gboolean initial_update, gboolean enabled)
+gboolean
+mute_menu_item_is_muted (MuteMenuItem* item)
+{
+ MuteMenuItemPrivate* priv = MUTE_MENU_ITEM_GET_PRIVATE (item);
+ return dbusmenu_menuitem_property_get_bool (priv->button,
+ DBUSMENU_MUTE_MENUITEM_VALUE);
+}
+
+MuteMenuItem*
+mute_menu_item_new (gboolean initial_update, gboolean enabled)
{
MuteMenuItem *self = g_object_new (MUTE_MENU_ITEM_TYPE, NULL);
mute_menu_item_update (self, initial_update);
diff --git a/src/mute-menu-item.h b/src/mute-menu-item.h
index 8240441..81a4b33 100644
--- a/src/mute-menu-item.h
+++ b/src/mute-menu-item.h
@@ -50,10 +50,10 @@ MuteMenuItem* mute_menu_item_new ();
void mute_menu_item_update (MuteMenuItem* item, gboolean update);
void mute_menu_item_enable (MuteMenuItem* item, gboolean active);
+gboolean mute_menu_item_is_muted (MuteMenuItem* item);
DbusmenuMenuitem* mute_menu_item_get_button (MuteMenuItem* item);
G_END_DECLS
-#endif
-
+#endif \ No newline at end of file
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index ca008a7..457992b 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -183,7 +183,7 @@ static gboolean determine_sink_availability()
return available;
}
-static gboolean default_sink_is_muted()
+gboolean default_sink_is_muted()
{
if (DEFAULT_SINK_INDEX < 0)
return FALSE;
diff --git a/src/pulse-manager.h b/src/pulse-manager.h
index dfe1256..5895aeb 100644
--- a/src/pulse-manager.h
+++ b/src/pulse-manager.h
@@ -40,6 +40,6 @@ void establish_pulse_activities(SoundServiceDbus *service);
void set_sink_volume(gdouble percent);
void toggle_global_mute(gboolean mute_value);
void close_pulse_activites();
-
+gboolean default_sink_is_muted();
#endif
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index 64db277..a20bb00 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -81,12 +81,8 @@ handle_event (DbusmenuMenuitem * mi,
GVariant * value,
guint timestamp)
{
- /*g_debug ( "handle-event in the slider at the backend, input is of type %s",
- g_variant_get_type_string(value));*/
-
GVariant* input = NULL;
input = value;
- // Please note: Subject to change in future DBusmenu revisions
if (g_variant_is_of_type(value, G_VARIANT_TYPE_VARIANT) == TRUE) {
input = g_variant_get_variant(value);
}
@@ -94,6 +90,11 @@ handle_event (DbusmenuMenuitem * mi,
gboolean volume_input = g_variant_get_double(input);
if (value != NULL){
set_sink_volume(volume_input);
+ // TODO -when the ACTIVESINK instance exists this will be handled nicely
+ // PA MANAGER will be refactored first.
+ if (default_sink_is_muted () == TRUE){
+ toggle_global_mute (FALSE);
+ }
}
}
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index b444a91..a532c0e 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -35,6 +35,7 @@
#include "pulse-manager.h"
#include "slider-menu-item.h"
#include "mute-menu-item.h"
+#include "pulse-manager.h"
// DBUS methods
static void bus_method_call (GDBusConnection * connection,
@@ -153,7 +154,8 @@ sound_service_dbus_init (SoundServiceDbus *self)
}
}
-DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self)
+DbusmenuMenuitem*
+sound_service_dbus_create_root_item (SoundServiceDbus* self)
{
SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
priv->root_menuitem = dbusmenu_menuitem_new();
@@ -165,10 +167,11 @@ DbusmenuMenuitem* sound_service_dbus_create_root_item (SoundServiceDbus* self)
return priv->root_menuitem;
}
-static void sound_service_dbus_build_sound_menu ( SoundServiceDbus* self,
- gboolean mute_update,
- gboolean availability,
- gdouble volume )
+static void
+sound_service_dbus_build_sound_menu ( SoundServiceDbus* self,
+ gboolean mute_update,
+ gboolean availability,
+ gdouble volume )
{
SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
@@ -209,8 +212,9 @@ static void sound_service_dbus_build_sound_menu ( SoundServiceDbus* self,
show_sound_settings_dialog:
Bring up the gnome volume preferences dialog
**/
-static void show_sound_settings_dialog (DbusmenuMenuitem *mi,
- gpointer user_data)
+static void
+show_sound_settings_dialog (DbusmenuMenuitem *mi,
+ gpointer user_data)
{
GError * error = NULL;
if (!g_spawn_command_line_async("gnome-volume-control --page=applications", &error) &&
@@ -221,10 +225,11 @@ static void show_sound_settings_dialog (DbusmenuMenuitem *mi,
}
}
-void sound_service_dbus_update_pa_state ( SoundServiceDbus* self,
- gboolean availability,
- gboolean mute_update,
- gdouble volume )
+void
+sound_service_dbus_update_pa_state ( SoundServiceDbus* self,
+ gboolean availability,
+ gboolean mute_update,
+ gdouble volume )
{
g_debug("update pa state with availability of %i, mute value of %i and a volume percent is %f", availability, mute_update, volume);
SoundServiceDbusPrivate * priv = SOUND_SERVICE_DBUS_GET_PRIVATE(self);
@@ -265,8 +270,11 @@ sound_service_dbus_finalize (GObject *object)
return;
}
-void sound_service_dbus_update_volume(SoundServiceDbus* self,
- gdouble volume)
+// UNTIL PA-MANAGER IS REFACTORED AND THE ACTIVESINK CLASS IS CREATED LEAVE
+// THE UI ELEMENTS SEPARATELY HANDLED LIKE THIS.
+void
+sound_service_dbus_update_volume (SoundServiceDbus* self,
+ gdouble volume)
{
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
slider_menu_item_update (priv->volume_slider_menuitem, volume);
@@ -274,8 +282,9 @@ void sound_service_dbus_update_volume(SoundServiceDbus* self,
sound_service_dbus_get_state_from_volume (self));
}
-void sound_service_dbus_update_sink_mute(SoundServiceDbus* self,
- gboolean mute_update)
+void
+sound_service_dbus_update_sink_mute (SoundServiceDbus* self,
+ gboolean mute_update)
{
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
mute_menu_item_update (priv->mute_menuitem, mute_update);
@@ -286,7 +295,9 @@ void sound_service_dbus_update_sink_mute(SoundServiceDbus* self,
sound_service_dbus_update_sound_state (self, state);
}
-static SoundState sound_service_dbus_get_state_from_volume (SoundServiceDbus* self)
+/*------- State calculators ------------------*/
+static SoundState
+sound_service_dbus_get_state_from_volume (SoundServiceDbus* self)
{
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
GVariant* v = dbusmenu_menuitem_property_get_variant (DBUSMENU_MENUITEM(priv->volume_slider_menuitem),
@@ -310,10 +321,11 @@ static SoundState sound_service_dbus_get_state_from_volume (SoundServiceDbus* se
return state;
}
-static void sound_service_dbus_determine_state (SoundServiceDbus* self,
- gboolean availability,
- gboolean mute,
- gdouble volume)
+static void
+sound_service_dbus_determine_state (SoundServiceDbus* self,
+ gboolean availability,
+ gboolean mute,
+ gdouble volume)
{
SoundState update;
if (availability == FALSE) {
@@ -333,15 +345,15 @@ static void sound_service_dbus_determine_state (SoundServiceDbus* self,
// TODO: this will be a bit messy until the pa_manager is sorted.
// And we figure out all of the edge cases.
-void sound_service_dbus_update_sound_state (SoundServiceDbus* self,
- SoundState new_state)
+void
+sound_service_dbus_update_sound_state (SoundServiceDbus* self,
+ SoundState new_state)
{
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
SoundState update = new_state;
// Ensure that after it has become available update the state with the current volume level
if (new_state == AVAILABLE &&
- dbusmenu_menuitem_property_get_bool ( DBUSMENU_MENUITEM(priv->mute_menuitem),
- DBUSMENU_MUTE_MENUITEM_VALUE) == FALSE ){
+ mute_menu_item_is_muted (priv->mute_menuitem) == FALSE){
update = sound_service_dbus_get_state_from_volume (self);
}
if (update != BLOCKED){
diff --git a/src/sound-service.xml b/src/sound-service.xml
index 07c9c3d..18e47fc 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -4,6 +4,7 @@
<method name = "BlacklistMediaPlayer">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_blacklist_media_player"/>
<arg type='s' name='player_desktop_name' direction="in"/>
+ <arg type='b' name='blacklist' direction="in"/>
</method>
<method name = "GetSoundState">
<annotation name="org.freedesktop.DBus.GLib.CSymbol" value="sound_service_dbus_get_sink_state"/>
diff --git a/src/sound-state-manager.c b/src/sound-state-manager.c
index 2ea9b1a..e8865d8 100644
--- a/src/sound-state-manager.c
+++ b/src/sound-state-manager.c
@@ -193,7 +193,6 @@ sound_state_manager_connect_to_dbus (SoundStateManager* self, GDBusProxy* proxy)
{
SoundStateManagerPrivate* priv = SOUND_STATE_MANAGER_GET_PRIVATE(self);
priv->dbus_proxy = proxy;
- g_debug (" here about to register for signal callback on %s", g_dbus_proxy_get_name (priv->dbus_proxy));
g_signal_connect (priv->dbus_proxy, "g-signal",
G_CALLBACK (sound_state_signal_cb), self);
@@ -223,7 +222,7 @@ sound_state_manager_get_state_cb (GObject *object,
&error );
if (error != NULL) {
- g_debug("get_sound_state call failed: %s", error->message);
+ g_warning("get_sound_state call failed: %s", error->message);
g_error_free(error);
return;
}