aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common-defs.h3
-rw-r--r--src/device.c65
-rw-r--r--src/device.h10
-rw-r--r--src/pulseaudio-mgr.c24
-rw-r--r--src/slider-menu-item.c21
-rw-r--r--src/voip-input-widget.c2
-rw-r--r--src/volume-widget.c36
7 files changed, 103 insertions, 58 deletions
diff --git a/src/common-defs.h b/src/common-defs.h
index da504de..21aab60 100644
--- a/src/common-defs.h
+++ b/src/common-defs.h
@@ -45,12 +45,13 @@ typedef enum {
TRANSPORT_STATE_PAUSED
}TransportState;
-#define NOT_ACTIVE -1
+#define NOT_ACTIVE -1
#define DBUSMENU_PROPERTY_EMPTY -1
/* DBUS Custom Items */
#define DBUSMENU_VOLUME_MENUITEM_TYPE "x-canonical-ido-volume-type"
#define DBUSMENU_VOLUME_MENUITEM_LEVEL "x-canonical-ido-volume-level"
+#define DBUSMENU_VOLUME_MENUITEM_MUTE "x-canonical-ido-volume-mute"
#define DBUSMENU_VOIP_INPUT_MENUITEM_TYPE "x-canonical-ido-voip-input-type"
#define DBUSMENU_VOIP_INPUT_MENUITEM_LEVEL "x-canonical-ido-voip-input-level"
diff --git a/src/device.c b/src/device.c
index 2f38beb..79b7b50 100644
--- a/src/device.c
+++ b/src/device.c
@@ -90,11 +90,10 @@ device_finalize (GObject *object)
}
void
-device_populate (Device* self,
+device_sink_populate (Device* self,
const pa_sink_info* update)
{
DevicePrivate* priv = DEVICE_GET_PRIVATE(self);
- device_mute_update (self, update->mute);
mute_menu_item_enable (priv->mute_menuitem, TRUE);
slider_menu_item_populate (priv->volume_slider_menuitem, update);
SoundState state = device_get_state_from_volume (self);
@@ -103,37 +102,11 @@ device_populate (Device* self,
sound_service_dbus_update_sound_state (priv->service,
priv->current_sound_state);
}
-
-}
-
-void
-device_activate_voip_item (Device* self, gint sink_input_index, gint client_index)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- if (voip_input_menu_item_is_interested (priv->voip_input_menu_item,
- sink_input_index,
- client_index)){
- voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE);
- }
-}
-
-void
-device_deactivate_voip_source (Device* self, gboolean visible)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item);
- voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible);
-}
-
-void
-device_deactivate_voip_client (Device* self)
-{
- DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
- voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item);
+ device_mute_update (self, update->mute);
}
void
-device_update (Device* self,
+device_sink_update (Device* self,
const pa_sink_info* update)
{
DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
@@ -223,22 +196,48 @@ device_determine_blocking_state (Device* self)
}
gint
-device_get_index (Device* self)
+device_get_sink_index (Device* self)
{
DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
return slider_menu_item_get_sink_index (priv->volume_slider_menuitem);
}
gboolean
-device_is_populated (Device* self)
+device_is_sink_populated (Device* self)
{
DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
return dbusmenu_menuitem_property_get_bool (DBUSMENU_MENUITEM (priv->volume_slider_menuitem),
DBUSMENU_MENUITEM_PROP_ENABLED);
}
+void
+device_activate_voip_item (Device* self, gint sink_input_index, gint client_index)
+{
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
+ if (voip_input_menu_item_is_interested (priv->voip_input_menu_item,
+ sink_input_index,
+ client_index)){
+ voip_input_menu_item_enable (priv->voip_input_menu_item, TRUE);
+ }
+}
+
+void
+device_deactivate_voip_source (Device* self, gboolean visible)
+{
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
+ visible &= voip_input_menu_item_is_active (priv->voip_input_menu_item);
+ voip_input_menu_item_deactivate_source (priv->voip_input_menu_item, visible);
+}
+
+void
+device_deactivate_voip_client (Device* self)
+{
+ DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
+ voip_input_menu_item_deactivate_voip_client (priv->voip_input_menu_item);
+}
+
void
-device_deactivate (Device* self)
+device_sink_deactivated (Device* self)
{
DevicePrivate* priv = DEVICE_GET_PRIVATE (self);
priv->current_sound_state = UNAVAILABLE;
diff --git a/src/device.h b/src/device.h
index 42d8189..9c74344 100644
--- a/src/device.h
+++ b/src/device.h
@@ -58,11 +58,11 @@ GType device_get_type (void) G_GNUC_CONST;
*/
// Sink related
-void device_populate (Device* sink, const pa_sink_info* update);
-void device_update (Device* sink, const pa_sink_info* update);
-gboolean device_is_populated (Device* sink);
-gint device_get_index (Device* self);
-void device_deactivate (Device* self);
+void device_sink_populate (Device* sink, const pa_sink_info* update);
+void device_sink_update (Device* sink, const pa_sink_info* update);
+gboolean device_is_sink_populated (Device* sink);
+gint device_get_sink_index (Device* self);
+void device_sink_deactivated (Device* self);
void device_update_mute (Device* self, gboolean mute_update);
void device_ensure_sink_is_unmuted (Device* self);
diff --git a/src/pulseaudio-mgr.c b/src/pulseaudio-mgr.c
index 036b46b..8811bcf 100644
--- a/src/pulseaudio-mgr.c
+++ b/src/pulseaudio-mgr.c
@@ -226,11 +226,11 @@ pm_subscribed_events_callback (pa_context *c,
case PA_SUBSCRIPTION_EVENT_SINK:
// We don't care about any other sink other than the active one.
- if (index != device_get_index (sink))
+ if (index != device_get_sink_index (sink))
return;
if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
- device_deactivate (sink);
+ device_sink_deactivated (sink);
}
else{
@@ -308,7 +308,7 @@ pm_context_state_callback (pa_context *c, void *userdata)
break;
case PA_CONTEXT_FAILED:
g_warning("PA_CONTEXT_FAILED - Is PulseAudio Daemon running ?");
- device_deactivate (DEVICE (userdata));
+ device_sink_deactivated (DEVICE (userdata));
if (reconnect_idle_id == 0){
reconnect_idle_id = g_timeout_add_seconds (RECONNECT_DELAY,
reconnect_to_pulse,
@@ -362,7 +362,7 @@ pm_server_info_callback (pa_context *c,
if (info == NULL) {
g_warning("No PA server - get the hell out of here");
- device_deactivate (DEVICE (userdata));
+ device_sink_deactivated (DEVICE (userdata));
return;
}
// Go for the default sink
@@ -373,7 +373,7 @@ pm_server_info_callback (pa_context *c,
pm_default_sink_info_callback,
userdata) )) {
g_warning("pa_context_get_sink_info_by_namet() failed");
- device_deactivate (DEVICE (userdata));
+ device_sink_deactivated (DEVICE (userdata));
pa_operation_unref(operation);
return;
}
@@ -382,7 +382,7 @@ pm_server_info_callback (pa_context *c,
pm_sink_info_callback,
userdata))) {
g_warning("pa_context_get_sink_info_list() failed");
- device_deactivate (DEVICE (userdata));
+ device_sink_deactivated (DEVICE (userdata));
pa_operation_unref(operation);
return;
}
@@ -426,9 +426,9 @@ pm_sink_info_callback (pa_context *c,
return;
}
Device* a_sink = DEVICE (userdata);
- if (device_is_populated (a_sink) == FALSE &&
+ if (device_is_sink_populated (a_sink) == FALSE &&
g_ascii_strncasecmp("auto_null", sink->name, 9) != 0){
- device_populate (a_sink, sink);
+ device_sink_populate (a_sink, sink);
}
}
}
@@ -448,11 +448,11 @@ pm_default_sink_info_callback (pa_context *c,
return;
}
// Only repopulate if there is a change with regards the index
- if (device_get_index (DEVICE (userdata)) == info->index)
+ if (device_get_sink_index (DEVICE (userdata)) == info->index)
return;
g_debug ("Pulse Server has handed us a new default sink");
- device_populate (DEVICE (userdata), info);
+ device_sink_populate (DEVICE (userdata), info);
}
}
@@ -494,7 +494,7 @@ pm_sink_input_info_callback (pa_context *c,
}
// And finally check for the mute blocking state
- if (device_get_index (a_sink) == info->sink){
+ if (device_get_sink_index (a_sink) == info->sink){
device_determine_blocking_state (a_sink);
}
}
@@ -514,7 +514,7 @@ pm_update_device (pa_context *c,
g_warning ("update_device - our user data is not what we think it should be or the info parameter is null");
return;
}
- device_update (DEVICE(userdata), info);
+ device_sink_update (DEVICE(userdata), info);
}
}
diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c
index fb66563..974749f 100644
--- a/src/slider-menu-item.c
+++ b/src/slider-menu-item.c
@@ -28,9 +28,10 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
typedef struct _SliderMenuItemPrivate SliderMenuItemPrivate;
struct _SliderMenuItemPrivate {
- Device* a_sink;
+ Device* a_sink;
gint index;
gchar* name;
+ gboolean mute;
pa_cvolume volume;
pa_channel_map channel_map;
pa_volume_t base_volume;
@@ -75,7 +76,7 @@ slider_menu_item_init (SliderMenuItem *self)
SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (self);
- priv->index = -1;
+ priv->index = NOT_ACTIVE;
priv->name = NULL;
return;
@@ -127,6 +128,7 @@ slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update)
priv->volume = slider_menu_item_construct_mono_volume (&update->volume);
priv->base_volume = update->base_volume;
priv->channel_map = update->channel_map;
+ priv->mute = update->mute;
pa_volume_t vol = pa_cvolume_max (&update->volume);
gdouble volume_percent = ((gdouble) vol * 100) / PA_VOLUME_NORM;
@@ -134,6 +136,11 @@ slider_menu_item_populate (SliderMenuItem* self, const pa_sink_info* update)
dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
DBUSMENU_VOLUME_MENUITEM_LEVEL,
new_volume);
+ GVariant* new_mute_update = g_variant_new_int32 (update->mute);
+ dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
+ DBUSMENU_VOLUME_MENUITEM_MUTE,
+ new_mute_update);
+
slider_menu_item_enable (self, TRUE);
}
@@ -170,6 +177,14 @@ slider_menu_item_update (SliderMenuItem* self, const pa_sink_info* update)
dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
DBUSMENU_VOLUME_MENUITEM_LEVEL,
new_volume);
+ if (priv->mute != update->mute){
+ priv->mute = update->mute;
+ g_debug ("volume menu item - update - mute = %i", update->mute);
+ GVariant* new_mute_update = g_variant_new_int32 (update->mute);
+ dbusmenu_menuitem_property_set_variant (DBUSMENU_MENUITEM(self),
+ DBUSMENU_VOLUME_MENUITEM_MUTE,
+ new_mute_update);
+ }
}
/*
@@ -185,7 +200,7 @@ slider_menu_item_enable (SliderMenuItem* self, gboolean active)
DBUSMENU_MENUITEM_PROP_ENABLED,
active);
if(active == FALSE){
- priv->index = -1;
+ priv->index = NOT_ACTIVE;
if(priv->name != NULL){
g_free(priv->name);
priv->name = NULL;
diff --git a/src/voip-input-widget.c b/src/voip-input-widget.c
index fc295ce..aec0c96 100644
--- a/src/voip-input-widget.c
+++ b/src/voip-input-widget.c
@@ -95,7 +95,7 @@ voip_input_widget_init (VoipInputWidget *self)
g_signal_connect(priv->ido_voip_input_slider, "slider-released", G_CALLBACK(voip_input_widget_slider_released), self);
GtkWidget* primary_image = ido_scale_menu_item_get_primary_image((IdoScaleMenuItem*)priv->ido_voip_input_slider);
- GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks("audio-input-microphone-none-panel");
+ GIcon * primary_gicon = g_themed_icon_new_with_default_fallbacks("audio-input-microphone-zero-panel");
gtk_image_set_from_gicon(GTK_IMAGE(primary_image), primary_gicon, GTK_ICON_SIZE_MENU);
g_object_unref(primary_gicon);
diff --git a/src/volume-widget.c b/src/volume-widget.c
index 5c842dc..55e81b3 100644
--- a/src/volume-widget.c
+++ b/src/volume-widget.c
@@ -128,11 +128,11 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
GVariant* value, gpointer userdata)
{
g_return_if_fail (IS_VOLUME_WIDGET (userdata));
- g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) );
VolumeWidget* mitem = VOLUME_WIDGET(userdata);
VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem);
- //g_debug("scrub-widget::property_update for prop %s", property);
+
if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_LEVEL, property) == 0){
+ g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) );
if(priv->grabbed == FALSE){
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
@@ -141,6 +141,27 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property,
update_accessible_desc(priv->indicator);
}
}
+ if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){
+ g_debug ("volume widget - mute update ");
+ if(priv->grabbed == FALSE){
+ GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
+ GtkRange *range = (GtkRange*)slider;
+ gint update = g_variant_get_int32 (value);
+ gdouble level;
+
+ g_debug ("volume widget - mute update %i", update);
+
+ if (update == 1){
+ level = 0;
+ }
+ else{
+ level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item,
+ DBUSMENU_VOLUME_MENUITEM_LEVEL));
+ }
+ gtk_range_set_value(range, level);
+ g_debug ("volume-widget - update mute with value %i", update);
+ }
+ }
}
static void
@@ -154,9 +175,15 @@ volume_widget_set_twin_item(VolumeWidget* self,
G_CALLBACK(volume_widget_property_update), self);
gdouble initial_level = g_variant_get_double (dbusmenu_menuitem_property_get_variant(twin_item,
DBUSMENU_VOLUME_MENUITEM_LEVEL));
+ gint initial_mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant(twin_item,
+ DBUSMENU_VOLUME_MENUITEM_MUTE));
+
//g_debug("volume_widget_set_twin_item initial level = %f", initial_level);
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
GtkRange *range = (GtkRange*)slider;
+ if(initial_mute == 1){
+ initial_level = 0;
+ }
gtk_range_set_value(range, initial_level);
update_accessible_desc(priv->indicator);
}
@@ -188,7 +215,10 @@ volume_widget_value_changed_cb (GtkRange *range, gpointer user_data)
GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider);
gdouble current_value = CLAMP(gtk_range_get_value(GTK_RANGE(slider)), 0, 100);
//g_debug ("value changed %f", gtk_range_get_value(GTK_RANGE(slider)));
- if(current_value == 0 || current_value == 100){
+ gint mute = g_variant_get_int32 (dbusmenu_menuitem_property_get_variant (priv->twin_item,
+ DBUSMENU_VOLUME_MENUITEM_MUTE));
+
+ if((current_value == 0 && mute != 1) || current_value == 100){
volume_widget_update(mitem, current_value);
}