From f6fd2dc4c5c1fb31f9175ddded990264cf939c77 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Thu, 10 Mar 2011 19:48:26 +0000 Subject: fixes bug around volume going to zero on client start up --- src/slider-menu-item.c | 3 ++- src/volume-widget.c | 19 +++++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/slider-menu-item.c b/src/slider-menu-item.c index b89f5ca..1c88f01 100644 --- a/src/slider-menu-item.c +++ b/src/slider-menu-item.c @@ -92,10 +92,11 @@ handle_event (DbusmenuMenuitem * mi, input = g_variant_get_variant(value); } - gboolean volume_input = g_variant_get_double(input); if (value != NULL){ if (IS_SLIDER_MENU_ITEM (mi)) { SliderMenuItemPrivate* priv = SLIDER_MENU_ITEM_GET_PRIVATE (SLIDER_MENU_ITEM (mi)); + gdouble volume_input = g_variant_get_double(input); + //g_debug ("slider menu item about to update volume %f", volume_input); active_sink_update_volume (priv->a_sink, volume_input); active_sink_ensure_sink_is_unmuted (priv->a_sink); } diff --git a/src/volume-widget.c b/src/volume-widget.c index c45e93c..5c842dc 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -128,6 +128,7 @@ 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); @@ -136,7 +137,6 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); GtkRange *range = (GtkRange*)slider; gdouble update = g_variant_get_double (value); - //g_debug("volume-widget - update level with value %f", update); gtk_range_set_value(range, update); update_accessible_desc(priv->indicator); } @@ -163,13 +163,14 @@ volume_widget_set_twin_item(VolumeWidget* self, static gboolean volume_widget_change_value_cb (GtkRange *range, - GtkScrollType scroll, - gdouble new_value, - gpointer user_data) + GtkScrollType scroll, + gdouble new_value, + gpointer user_data) { g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); VolumeWidget* mitem = VOLUME_WIDGET(user_data); - volume_widget_update(mitem, new_value); + //g_debug ("changed value %f", new_value); + volume_widget_update(mitem, new_value); return FALSE; } @@ -178,17 +179,19 @@ volume_widget_change_value_cb (GtkRange *range, which set the slider to 0 or 100. Ignore all other events. */ static gboolean -volume_widget_value_changed_cb(GtkRange *range, gpointer user_data) +volume_widget_value_changed_cb (GtkRange *range, gpointer user_data) { + g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); VolumeWidget* mitem = VOLUME_WIDGET(user_data); VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); - GtkWidget *slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)priv->ido_volume_slider); + 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){ volume_widget_update(mitem, current_value); } + return FALSE; } -- cgit v1.2.3