diff options
author | Conor Curran <conor.curran@canonical.com> | 2010-03-03 17:40:55 +0000 |
---|---|---|
committer | Conor Curran <conor.curran@canonical.com> | 2010-03-03 17:40:55 +0000 |
commit | f7447474f5703318b38578ec8ee9a66fbb9b7657 (patch) | |
tree | 20da22ba2f173d74e895a24676a8e2bd16766fae /src | |
parent | 90f724e9890f4631eecab0eb46275558a28111bc (diff) | |
parent | 55fe3e5a44992862735b4ef2208300dbfccacebb (diff) | |
download | ayatana-indicator-sound-f7447474f5703318b38578ec8ee9a66fbb9b7657.tar.gz ayatana-indicator-sound-f7447474f5703318b38578ec8ee9a66fbb9b7657.tar.bz2 ayatana-indicator-sound-f7447474f5703318b38578ec8ee9a66fbb9b7657.zip |
merged Cody's fix for filtering key events which enable proper use of arrow keys with the indicator
Diffstat (limited to 'src')
-rw-r--r-- | src/indicator-sound.c | 83 |
1 files changed, 44 insertions, 39 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c index acacddc..1301916 100644 --- a/src/indicator-sound.c +++ b/src/indicator-sound.c @@ -439,49 +439,54 @@ static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer dat gdouble current_value = gtk_range_get_value(range); gdouble new_value = current_value; const gdouble five_percent = 5; + GtkWidget *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; + 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; } |