aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-sound.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/indicator-sound.c')
-rw-r--r--src/indicator-sound.c84
1 files changed, 46 insertions, 38 deletions
diff --git a/src/indicator-sound.c b/src/indicator-sound.c
index 8e79db6..1301916 100644
--- a/src/indicator-sound.c
+++ b/src/indicator-sound.c
@@ -432,54 +432,62 @@ key_press_cb:
**/
static gboolean key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data)
{
- if (current_state == STATE_MUTED)
- return FALSE;
+ gboolean digested = FALSE;
GtkWidget* slider = ido_scale_menu_item_get_scale((IdoScaleMenuItem*)volume_slider);
GtkRange* range = (GtkRange*)slider;
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:
- if(event->state & GDK_CONTROL_MASK)
- {
- new_value = 100;
- }
- else
- {
- new_value = current_value + five_percent;
- }
- break;
- case GDK_Left:
- 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)
{
- new_value = current_value - five_percent;
- }
- break;
- case GDK_plus:
+ 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:
+ 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)
- {
- g_debug("Attempting to set the range from the key listener to %f", new_value);
- gtk_range_set_value(range, new_value);
- }
- return FALSE;
+ 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;
}
/**