aboutsummaryrefslogtreecommitdiff
path: root/src/volume-widget.c
diff options
context:
space:
mode:
authorConor Curran <conor.curran@canonical.com>2011-03-16 11:03:46 +0000
committerConor Curran <conor.curran@canonical.com>2011-03-16 11:03:46 +0000
commitd0ef5f9435e10d39baea01c9d240e4149a80944c (patch)
tree170c3a420f3bc3f14d8dadc91da55c42ce0b0389 /src/volume-widget.c
parent661b34c4f8175efbd51a4471c01e96a370806228 (diff)
parent7a2e0aec631872d45c3e5b508a1c84343f53ed30 (diff)
downloadayatana-indicator-sound-d0ef5f9435e10d39baea01c9d240e4149a80944c.tar.gz
ayatana-indicator-sound-d0ef5f9435e10d39baea01c9d240e4149a80944c.tar.bz2
ayatana-indicator-sound-d0ef5f9435e10d39baea01c9d240e4149a80944c.zip
volume-slider now behaves the same as the voip slider when muted
Diffstat (limited to 'src/volume-widget.c')
-rw-r--r--src/volume-widget.c36
1 files changed, 33 insertions, 3 deletions
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);
}