aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2010-02-08 19:19:07 +0000
committerConor Curran <conor.curran@canonical.com>2010-02-08 19:19:07 +0000
commitbf02109517f8e770373e13fc78cdda3019d77f04 (patch)
tree8ac695e9ac59e2b60930b53f7fcdca91d2311442 /src
parentd1e576becc28434d42e29640b8674342f8b6f521 (diff)
downloadayatana-indicator-sound-bf02109517f8e770373e13fc78cdda3019d77f04.tar.gz
ayatana-indicator-sound-bf02109517f8e770373e13fc78cdda3019d77f04.tar.bz2
ayatana-indicator-sound-bf02109517f8e770373e13fc78cdda3019d77f04.zip
mute ui updates from external intervention
Diffstat (limited to 'src')
-rw-r--r--src/common-defs.h1
-rw-r--r--src/indicator-sound.c15
-rw-r--r--src/pulse-manager.c5
-rw-r--r--src/slider-menu-item.c3
-rw-r--r--src/slider-menu-item.h1
-rw-r--r--src/sound-service-dbus.c21
-rw-r--r--src/sound-service.c16
-rw-r--r--src/sound-service.h4
-rw-r--r--src/sound-service.xml4
9 files changed, 53 insertions, 17 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index c969ddb..4009773 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -1,6 +1,7 @@
/* constants used for signals on the dbus. This file is shared between client and server implementation */
#define SIGNAL_SINK_INPUT_WHILE_MUTED "SinkInputWhileMuted"
#define SIGNAL_SINK_VOLUME_UPDATE "SinkVolumeUpdate"
+//#define SIGNAL_SINK_MUTE_UPDATE "SinkMuteUpdate"
// DBUS items
#define DBUSMENU_SLIDER_MENUITEM_TYPE "x-canonical-ido-slider-item"
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index fe1b6fb..73a8a23 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -195,7 +195,8 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u
dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_INPUT_WHILE_MUTED, G_CALLBACK(catch_signal_sink_input_while_muted), NULL, NULL);
dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_TYPE_DOUBLE, G_TYPE_INVALID);
dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_VOLUME_UPDATE, G_CALLBACK(catch_signal_sink_volume_update), NULL, NULL);
-
+/* dbus_g_proxy_add_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_TYPE_BOOLEAN, G_TYPE_INVALID);*/
+/* dbus_g_proxy_connect_signal(sound_dbus_proxy, SIGNAL_SINK_MUTE_UPDATE, G_CALLBACK(catch_signal_sink_mute_update), NULL, NULL);*/
}
} else {
@@ -207,8 +208,7 @@ connection_changed (IndicatorServiceManager * sm, gboolean connected, gpointer u
static void catch_signal_sink_input_while_muted(DBusGProxy * proxy, gint sink_index, gboolean value, gpointer userdata)
{
- //gtk_image_set_from_icon_name(speaker_image, "audio-volume-muted-blocking-symbolic", GTK_ICON_SIZE_MENU);
- g_debug("signal caught - I don't believe it ! with index %i and value %i", sink_index, value);
+ g_debug("signal caught - sink input while muted with index %i and value %i", sink_index, value);
}
static void catch_signal_sink_volume_update(DBusGProxy * proxy, gdouble volume_percent, gpointer userdata)
@@ -219,6 +219,15 @@ static void catch_signal_sink_volume_update(DBusGProxy * proxy, gdouble volume_p
gtk_range_set_value(range, volume_percent);
}
+/*static void catch_signal_sink_mute_update(DBusGProxy * proxy, gdouble volume_percent, gpointer userdata)*/
+/*{*/
+/* g_debug("signal caught - update sink volume with value : %f", volume_percent);*/
+/* GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);*/
+/* GtkRange* range = (GtkRange*)slider; */
+/* gtk_range_set_value(range, volume_percent); */
+/*}*/
+
+
static void
indicator_sound_dispose (GObject *object)
{
diff --git a/src/pulse-manager.c b/src/pulse-manager.c
index ff6f1bb..0a35d92 100644
--- a/src/pulse-manager.c
+++ b/src/pulse-manager.c
@@ -291,10 +291,11 @@ static void update_sink_info(pa_context *c, const pa_sink_info *info, int eol, v
//update the UI
pa_volume_t vol = pa_cvolume_avg(&s->volume);
// Use the base of the device to ensure maximum acceptable levels on the hardware
- gint volume_percent = (vol/s->base_volume);
- g_debug("When using base volume => volume = %i", volume_percent);
+ gdouble volume_percent = (vol/s->base_volume) * 100;
+ g_debug("When using base volume => volume = %f", volume_percent);
g_debug("about to update ui with linear volume of %f", pa_sw_volume_to_linear(vol));
sound_service_dbus_update_sink_volume(dbus_service, pa_sw_volume_to_linear(vol) * 100);
+ update_mute_ui(s->mute);
}
}
else
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index 2620e6e..2e8321d 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -91,11 +91,8 @@ handle_event (DbusmenuMenuitem * mi, const gchar * name, const GValue * value, g
SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble start_volume)
{
SliderMenuItem *self = g_object_new(SLIDER_MENU_ITEM_TYPE, NULL);
- //SliderMenuItemPrivate * priv = SLIDER_MENU_ITEM_GET_PRIVATE(self);
dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_TYPE, DBUSMENU_SLIDER_MENUITEM_TYPE);
- //TODO: If no valid sinks are found grey out the item(s)
dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(self), DBUSMENU_MENUITEM_PROP_ENABLED, sinks_available);
- //g_debug("Sending the initial value of the slider over dbus = %f", start_volume * 100);
return self;
}
diff --git a/src/slider-menu-item.h b/src/slider-menu-item.h
index 48e71ff..c4423e3 100644
--- a/src/slider-menu-item.h
+++ b/src/slider-menu-item.h
@@ -46,6 +46,7 @@ struct _SliderMenuItem {
};
GType slider_menu_item_get_type (void);
+// TODO for now the volume percent param is not being used - remove once init mystery is solved
SliderMenuItem* slider_menu_item_new(gboolean sinks_available, gdouble current_vol);
G_END_DECLS
diff --git a/src/sound-service-dbus.c b/src/sound-service-dbus.c
index 635dfeb..bcc21f6 100644
--- a/src/sound-service-dbus.c
+++ b/src/sound-service-dbus.c
@@ -44,6 +44,7 @@ struct _SoundServiceDbusPrivate
enum {
SINK_INPUT_WHILE_MUTED,
SINK_VOLUME_UPDATE,
+ SINK_MUTE_UPDATE,
LAST_SIGNAL
};
@@ -90,11 +91,18 @@ sound_service_dbus_class_init (SoundServiceDbusClass *klass)
NULL, NULL,
g_cclosure_marshal_VOID__DOUBLE,
G_TYPE_NONE, 1, G_TYPE_DOUBLE);
+
+/* signals[SINK_MUTE_UPDATE] = g_signal_new("sink-mute-update",*/
+/* G_TYPE_FROM_CLASS (klass),*/
+/* G_SIGNAL_RUN_LAST,*/
+/* 0,*/
+/* NULL, NULL,*/
+/* g_cclosure_marshal_VOID__BOOLEAN,*/
+/* G_TYPE_NONE, 1, G_TYPE_BOOLEAN);*/
}
/**
DBUS Method Callbacks
-TODO do not see the point in this returning a boolean and also needing a sink index since the service needs to be ultimately aware of what sink is chosen.
**/
void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint volume_percent, GError** gerror)
{
@@ -102,6 +110,7 @@ void sound_service_dbus_set_sink_volume(SoundServiceDbus* service, const guint v
set_sink_volume(volume_percent);
}
+//TODO needed ?
GList *
sound_service_dbus_get_sink_list (SoundServiceDbus *self)
{
@@ -135,6 +144,16 @@ void sound_service_dbus_update_sink_volume(SoundServiceDbus* obj, gdouble sink_v
sink_volume);
}
+/*void sound_service_dbus_update_sink_mute(SoundServiceDbus* obj, gboolean sink_mute)*/
+/*{*/
+/* g_debug("Emitting signal: SINK_MUTE_UPDATE, with sink mute %i", sink_mute);*/
+/* g_signal_emit(obj,*/
+/* signals[SINK_MUTE_UPDATE],*/
+/* 0,*/
+/* sink_mute);*/
+/*}*/
+
+// TODO needed?
void set_pa_sinks_hash(SoundServiceDbus *self, GHashTable *sinks)
{
SoundServiceDbusPrivate *priv = SOUND_SERVICE_DBUS_GET_PRIVATE (self);
diff --git a/src/sound-service.c b/src/sound-service.c
index 101cd18..cc39e38 100644
--- a/src/sound-service.c
+++ b/src/sound-service.c
@@ -5,7 +5,6 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
Ted Gould <ted@canonical.com>
- Christoph Korn <c_korn@gmx.de>
Cody Russell <crussell@canonical.com>
This program is free software: you can redistribute it and/or modify it
@@ -40,7 +39,7 @@ static gboolean b_all_muted = FALSE;
static gboolean b_pulse_ready = FALSE;
static gdouble volume_percent = 0.0;
-static void set_global_mute();
+static void set_global_mute_from_ui();
static gboolean idle_routine (gpointer data);
static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service);
@@ -74,7 +73,7 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service
// Mute button
mute_all_menuitem = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(b_all_muted == FALSE ? "Mute All" : "Unmute"));
- g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute), NULL);
+ g_signal_connect(G_OBJECT(mute_all_menuitem), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(set_global_mute_from_ui), NULL);
//TODO: If no valid sinks are found grey out the item(s)
dbusmenu_menuitem_property_set_bool(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_ENABLED, b_sink_available);
@@ -93,8 +92,14 @@ static void rebuild_sound_menu(DbusmenuMenuitem *root, SoundServiceDbus *service
g_signal_connect(G_OBJECT(settings_mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED,
G_CALLBACK(show_sound_settings_dialog), NULL);
}
+/* 'public' method allowing the server to update the mute UI*/
+void update_mute_ui(gboolean incoming_mute_value)
+{
+ b_all_muted = incoming_mute_value;
+ dbusmenu_menuitem_property_set(mute_all_menuitem, DBUSMENU_MENUITEM_PROP_LABEL, _(b_all_muted == FALSE ? "Mute All" : "Unmute"));
+}
-static void set_global_mute()
+static void set_global_mute_from_ui()
{
b_all_muted = !b_all_muted;
toggle_global_mute(b_all_muted);
@@ -118,6 +123,7 @@ service_shutdown (IndicatorService *service, gpointer user_data)
if (mainloop != NULL) {
g_debug("Service shutdown - but commented out for right now");
+ // TODO: uncomment for release
/* close_pulse_activites()*/
/* g_main_loop_quit(mainloop);*/
}
@@ -132,10 +138,10 @@ void update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_m
volume_percent = percent;
g_debug("update pa state with state %i, availability of %i, mute value of %i and a volume percent is %f", pa_state, sink_available, sink_muted, volume_percent);
rebuild_sound_menu(root_menuitem, dbus_interface);
- g_debug("About to send over the volume slider");
GValue value = {0};
g_value_init(&value, G_TYPE_DOUBLE);
g_value_set_double(&value, volume_percent * 100);
+ g_debug("About to send over the volume slider initial value %f", (volume_percent * 100));
dbusmenu_menuitem_property_set_value(DBUSMENU_MENUITEM(volume_slider_menuitem), DBUSMENU_SLIDER_MENUITEM_PROP_VOLUME, &value);
}
diff --git a/src/sound-service.h b/src/sound-service.h
index fec52a3..d36ea41 100644
--- a/src/sound-service.h
+++ b/src/sound-service.h
@@ -8,7 +8,6 @@ Copyright 2010 Canonical Ltd.
Authors:
Conor Curran <conor.curran@canonical.com>
Ted Gould <ted@canonical.com>
- Christoph Korn <c_korn@gmx.de>
Cody Russell <crussell@canonical.com>
This program is free software: you can redistribute it and/or modify it
@@ -39,11 +38,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include "dbus-shared-names.h"
-
// ENTRY AND EXIT POINTS
void service_shutdown(IndicatorService * service, gpointer user_data);
int main (int argc, char ** argv);
void update_pa_state(gboolean pa_state, gboolean sink_available, gboolean sink_muted, gdouble current_vol);
-
+void update_mute_ui(gboolean incoming_mute_value);
#endif
diff --git a/src/sound-service.xml b/src/sound-service.xml
index fffad00..8583fbc 100644
--- a/src/sound-service.xml
+++ b/src/sound-service.xml
@@ -17,6 +17,10 @@ Our respective UI element should listen to this and therefore will be updated wi
<signal name="SinkVolumeUpdate">
<arg name="volume_percent" type="u" direction="out"/>
</signal>
+<!-- <signal name="SinkMuteUpdate">-->
+<!-- <arg name="current_mute_value" type="b" direction="out"/>-->
+<!-- </signal>-->
+
</interface>
</node>