From eb3df565591fb7474aa5290db83ca601a7edd1ee Mon Sep 17 00:00:00 2001 From: Conor Curran Date: Wed, 3 Mar 2010 17:23:08 +0000 Subject: fixes the key listener problems --- src/indicator-sound.c | 86 ++++++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 42 deletions(-) (limited to 'src/indicator-sound.c') diff --git a/src/indicator-sound.c b/src/indicator-sound.c index 49c02fa..63d48aa 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -441,51 +441,53 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat const gdouble five_percent = 5; GtkWidget *menuitem; - menuitem = gtk_menu_get_active (GTK_MENU (widget)); - g_print (g_type_name (menuitem)); - - switch(event->keyval) - { - case GDK_Right: - digested = TRUE; - if(event->state & GDK_CONTROL_MASK) - { - new_value = 100; - } - else - { - new_value = current_value + five_percent; - } - break; - case GDK_Left: - digested = TRUE; - if(event->state & GDK_CONTROL_MASK) - { - new_value = 0; - } - else + menuitem = GTK_MENU_SHELL (widget)->active_menu_item; +/* g_print ("object (%p) name should be %s", menuitem, G_OBJECT_TYPE_NAME(menuitem));*/ + if(IDO_IS_SCALE_MENU_ITEM(menuitem) == TRUE) + { + switch(event->keyval) { + case GDK_Right: + digested = TRUE; + if(event->state & GDK_CONTROL_MASK) + { + new_value = 100; + } + else + { + new_value = current_value + five_percent; + } + break; + case GDK_Left: + digested = TRUE; + if(event->state & GDK_CONTROL_MASK) + { + new_value = 0; + } + else + { + new_value = current_value - five_percent; + } + break; + case GDK_plus: + digested = TRUE; + new_value = current_value + five_percent; + break; + case GDK_minus: + digested = TRUE; new_value = current_value - five_percent; + break; + default: + break; + } + + new_value = CLAMP(new_value, 0, 100); + if(new_value != current_value && current_state != STATE_MUTED) + { + g_debug("Attempting to set the range from the key listener to %f", new_value); + gtk_range_set_value(range, new_value); } - break; - case GDK_plus: - digested = TRUE; - new_value = current_value + five_percent; - break; - case GDK_minus: - digested = TRUE; - new_value = current_value - five_percent; - break; - default: - break; - } - - new_value = CLAMP(new_value, 0, 100); - if(new_value != current_value && current_state != STATE_MUTED) - { - g_debug("Attempting to set the range from the key listener to %f", new_value); - gtk_range_set_value(range, new_value); - } + } return digested; } -- cgit v1.2.3