From d84e5d382f2f62e4af5d0e9f8ed993b671acc15a Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Mar 2011 13:04:13 +0000 Subject: some extra trace around sliders to track the volume zero app start madness --- src/volume-widget.c | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) (limited to 'src/volume-widget.c') diff --git a/src/volume-widget.c b/src/volume-widget.c index f638bd4..a54441c 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -131,26 +131,33 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, g_return_if_fail (IS_VOLUME_WIDGET (userdata)); VolumeWidget* mitem = VOLUME_WIDGET(userdata); VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); - 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; gdouble update = g_variant_get_double (value); +/* + g_debug ("volume widget volume prop update with %f", update); +*/ gtk_range_set_value(range, update); update_accessible_desc(priv->indicator); } } if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ +/* g_debug ("volume widget - mute update "); +*/ + g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32) ); 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; @@ -160,7 +167,9 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, DBUSMENU_VOLUME_MENUITEM_LEVEL)); } gtk_range_set_value(range, level); +/* g_debug ("volume-widget - update mute with value %i", update); +*/ } } } @@ -197,8 +206,10 @@ volume_widget_change_value_cb (GtkRange *range, { g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); VolumeWidget* mitem = VOLUME_WIDGET(user_data); - //g_debug ("changed value %f", new_value); - volume_widget_update(mitem, new_value); +/* + g_debug ("changed value %f", new_value); +*/ + volume_widget_update(mitem, new_value, "change-value"); return FALSE; } @@ -215,24 +226,35 @@ volume_widget_value_changed_cb (GtkRange *range, gpointer user_data) VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); 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))); +/* + g_debug ("value changed %f", gtk_range_get_value(GTK_RANGE(slider))); +*/ + 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); +/* + g_debug ("value changed - actual set %f", current_value); +*/ + volume_widget_update(mitem, current_value, "value-changed"); } return FALSE; } void -volume_widget_update(VolumeWidget* self, gdouble update) +volume_widget_update(VolumeWidget* self, gdouble update, gchar* label) { + gchar* source = NULL; + source = label; + if (label == NULL){ + source = "v widget update"; + } VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(self); gdouble clamped = CLAMP(update, 0, 100); GVariant* new_volume = g_variant_new_double(clamped); - dbusmenu_menuitem_handle_event (priv->twin_item, "update", new_volume, 0); + dbusmenu_menuitem_handle_event (priv->twin_item, source, new_volume, 0); } GtkWidget* -- cgit v1.2.3 From 6a501d5787eec8bfef3558d14a36754f7be22858 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Mon, 21 Mar 2011 18:06:24 +0000 Subject: change the mute type on the volume slider to the appropriate type of boolean --- src/volume-widget.c | 48 ++++++++++++++++-------------------------------- 1 file changed, 16 insertions(+), 32 deletions(-) (limited to 'src/volume-widget.c') diff --git a/src/volume-widget.c b/src/volume-widget.c index a54441c..1a6895e 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -137,29 +137,20 @@ 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 volume prop update with %f", update); -*/ gtk_range_set_value(range, update); update_accessible_desc(priv->indicator); + g_debug ("volume-widget::volume_widget_property_update - mute - value %f", update); } } - if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ -/* - g_debug ("volume widget - mute update "); -*/ - g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32) ); + else if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ + g_return_if_fail (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)); 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); + gboolean update = g_variant_get_boolean (value); gdouble level; -/* - g_debug ("volume widget - mute update %i", update); -*/ - - if (update == 1){ + if (update == TRUE){ level = 0; } else{ @@ -167,9 +158,7 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, DBUSMENU_VOLUME_MENUITEM_LEVEL)); } gtk_range_set_value(range, level); -/* - g_debug ("volume-widget - update mute with value %i", update); -*/ + g_debug ("volume-widget::volume_widget_property_update - mute - value %i", update); } } } @@ -185,13 +174,13 @@ 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)); + gboolean initial_mute = g_variant_get_boolean (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){ + if(initial_mute == TRUE){ initial_level = 0; } gtk_range_set_value(range, initial_level); @@ -206,9 +195,9 @@ volume_widget_change_value_cb (GtkRange *range, { g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); VolumeWidget* mitem = VOLUME_WIDGET(user_data); -/* + g_debug ("changed value %f", new_value); -*/ + volume_widget_update(mitem, new_value, "change-value"); return FALSE; } @@ -222,22 +211,17 @@ 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); + 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); 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))); -*/ - - 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){ -/* + gboolean mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant (priv->twin_item, + DBUSMENU_VOLUME_MENUITEM_MUTE)); + if((current_value == 0 && mute == FALSE) || current_value == 100){ g_debug ("value changed - actual set %f", current_value); -*/ - volume_widget_update(mitem, current_value, "value-changed"); + volume_widget_update (mitem, current_value, "value-changed"); } return FALSE; -- cgit v1.2.3 From 851b1bb2b1acaa5440f66d69948a066779ddf862 Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 22 Mar 2011 00:01:53 +0000 Subject: more trace added --- src/volume-widget.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/volume-widget.c') diff --git a/src/volume-widget.c b/src/volume-widget.c index 1a6895e..77392c8 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -131,6 +131,12 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, g_return_if_fail (IS_VOLUME_WIDGET (userdata)); VolumeWidget* mitem = VOLUME_WIDGET(userdata); VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); + + g_debug ("volume-widget::volume_widget_property_update for prop %s, is it a double %i", + property, g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) ); + g_debug ("volume-widget::volume_widget_property_update for prop %s, is it a boolean %i", + property, g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN) ); + 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){ @@ -139,7 +145,7 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, gdouble update = g_variant_get_double (value); gtk_range_set_value(range, update); update_accessible_desc(priv->indicator); - g_debug ("volume-widget::volume_widget_property_update - mute - value %f", update); + g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update); } } else if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ -- cgit v1.2.3 From 0a7074927f2f600b6e7eb98459b97b73de0baa8d Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Tue, 22 Mar 2011 19:53:19 +0000 Subject: protected now against any type ot irregular spam dbusmenu may throw at it --- src/volume-widget.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) (limited to 'src/volume-widget.c') diff --git a/src/volume-widget.c b/src/volume-widget.c index 77392c8..e8e7bae 100644 --- a/src/volume-widget.c +++ b/src/volume-widget.c @@ -128,15 +128,10 @@ static void volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, GVariant* value, gpointer userdata) { - g_return_if_fail (IS_VOLUME_WIDGET (userdata)); + g_return_if_fail (IS_VOLUME_WIDGET(userdata)); VolumeWidget* mitem = VOLUME_WIDGET(userdata); VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); - g_debug ("volume-widget::volume_widget_property_update for prop %s, is it a double %i", - property, g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE) ); - g_debug ("volume-widget::volume_widget_property_update for prop %s, is it a boolean %i", - property, g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN) ); - 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){ @@ -144,8 +139,10 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, GtkRange *range = (GtkRange*)slider; gdouble update = g_variant_get_double (value); gtk_range_set_value(range, update); - update_accessible_desc(priv->indicator); +/* g_debug ("volume-widget::volume_widget_property_update - volume - value %f", update); +*/ + update_accessible_desc(priv->indicator); } } else if(g_ascii_strcasecmp(DBUSMENU_VOLUME_MENUITEM_MUTE, property) == 0){ @@ -160,11 +157,19 @@ volume_widget_property_update( DbusmenuMenuitem* item, gchar* property, level = 0; } else{ - level = g_variant_get_double (dbusmenu_menuitem_property_get_variant (priv->twin_item, - DBUSMENU_VOLUME_MENUITEM_LEVEL)); + GVariant* variant = dbusmenu_menuitem_property_get_variant (priv->twin_item, + DBUSMENU_VOLUME_MENUITEM_LEVEL); +/* + g_debug ("variant for the volume - is it null = %i", variant == NULL); +*/ + g_return_if_fail (g_variant_is_of_type (variant, G_VARIANT_TYPE_DOUBLE) ); + + level = g_variant_get_double (variant); } +/* + g_debug ("volume-widget::volume_widget_property_update - mute - value %i and level = %f", update, level); +*/ gtk_range_set_value(range, level); - g_debug ("volume-widget::volume_widget_property_update - mute - value %i", update); } } } @@ -202,7 +207,9 @@ volume_widget_change_value_cb (GtkRange *range, g_return_val_if_fail (IS_VOLUME_WIDGET (user_data), FALSE); VolumeWidget* mitem = VOLUME_WIDGET(user_data); +/* g_debug ("changed value %f", new_value); +*/ volume_widget_update(mitem, new_value, "change-value"); return FALSE; @@ -221,12 +228,13 @@ volume_widget_value_changed_cb (GtkRange *range, gpointer user_data) VolumeWidgetPrivate * priv = VOLUME_WIDGET_GET_PRIVATE(mitem); 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))); gboolean mute = g_variant_get_boolean (dbusmenu_menuitem_property_get_variant (priv->twin_item, DBUSMENU_VOLUME_MENUITEM_MUTE)); if((current_value == 0 && mute == FALSE) || current_value == 100){ +/* g_debug ("value changed - actual set %f", current_value); +*/ volume_widget_update (mitem, current_value, "value-changed"); } -- cgit v1.2.3