diff options
author | Conor Curran <conor.curran@canonical.com> | 2011-03-15 12:22:21 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2011-03-15 12:22:21 +0000 |
commit | 57e21d3708ad855333de53f31a3e1b0f93081dc2 (patch) | |
tree | fcfcaa1fff741871213e88cb9c0906234878d175 /src/volume-widget.c | |
parent | 661b34c4f8175efbd51a4471c01e96a370806228 (diff) | |
download | ayatana-indicator-sound-57e21d3708ad855333de53f31a3e1b0f93081dc2.tar.gz ayatana-indicator-sound-57e21d3708ad855333de53f31a3e1b0f93081dc2.tar.bz2 ayatana-indicator-sound-57e21d3708ad855333de53f31a3e1b0f93081dc2.zip |
mute behaviour consistent over both sliders => go to 0 on mute and return to previous volume on unmute
Diffstat (limited to 'src/volume-widget.c')
-rw-r--r-- | src/volume-widget.c | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/src/volume-widget.c b/src/volume-widget.c index 5c842dc..c947669 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 @@ -188,7 +209,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); } |