diff options
author | Bastien Nocera <hadess@hadess.net> | 2011-06-10 15:00:33 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2011-06-10 15:00:33 +0100 |
commit | 1d41ab388a06844c4b46cee6e396a4976f136770 (patch) | |
tree | 8c94ed86bec64590d6586552c3a9fe41b76effb3 | |
parent | e310a5445a4d2020359a4dd4105eb70fcae334bd (diff) | |
download | gnome-settings-daemon-1d41ab388a06844c4b46cee6e396a4976f136770.tar.gz |
media-keys: Make sound changes quiet with Alt
<Alt>+volume control keys will change the sound, without
playing a notification sound, which can be useful when things need
to be quiet.
Note that this doesn't use the settings stored in GSettings, but
is hard-coded for those audio keys.
https://bugzilla.gnome.org/show_bug.cgi?id=651704
-rw-r--r-- | plugins/media-keys/acme.h | 8 | ||||
-rw-r--r-- | plugins/media-keys/gsd-media-keys-manager.c | 29 |
2 files changed, 31 insertions, 6 deletions
diff --git a/plugins/media-keys/acme.h b/plugins/media-keys/acme.h index 73b01dfb..ac58d7b8 100644 --- a/plugins/media-keys/acme.h +++ b/plugins/media-keys/acme.h @@ -32,6 +32,9 @@ typedef enum { MUTE_KEY, VOLUME_DOWN_KEY, VOLUME_UP_KEY, + MUTE_QUIET_KEY, + VOLUME_DOWN_QUIET_KEY, + VOLUME_UP_QUIET_KEY, LOGOUT_KEY, EJECT_KEY, HOME_KEY, @@ -74,9 +77,12 @@ static struct { { TOUCHPAD_KEY, NULL, "XF86TouchpadToggle", NULL }, { TOUCHPAD_ON_KEY, NULL, "XF86TouchpadOn", NULL }, { TOUCHPAD_OFF_KEY, NULL, "XF86TouchpadOff", NULL }, - { MUTE_KEY, "volume-mute",NULL, NULL }, + { MUTE_KEY, "volume-mute", NULL, NULL }, { VOLUME_DOWN_KEY, "volume-down", NULL, NULL }, { VOLUME_UP_KEY, "volume-up", NULL, NULL }, + { MUTE_QUIET_KEY, NULL, "<Alt>XF86AudioMute", NULL }, + { VOLUME_DOWN_QUIET_KEY, NULL, "<Alt>XF86AudioLowerVolume", NULL }, + { VOLUME_UP_QUIET_KEY, NULL, "<Alt>XF86AudioRaiseVolume", NULL }, { LOGOUT_KEY, "logout", NULL, NULL }, { EJECT_KEY, "eject", NULL, NULL }, { HOME_KEY, "home", NULL, NULL }, diff --git a/plugins/media-keys/gsd-media-keys-manager.c b/plugins/media-keys/gsd-media-keys-manager.c index b2171d00..b6e9cf9f 100644 --- a/plugins/media-keys/gsd-media-keys-manager.c +++ b/plugins/media-keys/gsd-media-keys-manager.c @@ -609,7 +609,8 @@ update_dialog (GsdMediaKeysManager *manager, guint vol, guint max_vol, gboolean muted, - gboolean sound_changed) + gboolean sound_changed, + gboolean quiet) { vol = (int) (100 * (double) vol / (double) max_vol); vol = CLAMP (vol, 0, 100); @@ -622,7 +623,7 @@ update_dialog (GsdMediaKeysManager *manager, GSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME); dialog_show (manager); - if (sound_changed != FALSE && muted == FALSE) + if (quiet == FALSE && sound_changed != FALSE && muted == FALSE) ca_gtk_play_for_widget (manager->priv->dialog, 0, CA_PROP_EVENT_ID, "audio-volume-change", CA_PROP_EVENT_DESCRIPTION, "volume changed through key press", @@ -632,7 +633,8 @@ update_dialog (GsdMediaKeysManager *manager, static void do_sound_action (GsdMediaKeysManager *manager, - int type) + int type, + gboolean quiet) { gboolean old_muted, new_muted; guint old_vol, new_vol, max_vol, norm_vol_step; @@ -681,7 +683,7 @@ do_sound_action (GsdMediaKeysManager *manager, } } - update_dialog (manager, new_vol, max_vol, new_muted, sound_changed); + update_dialog (manager, new_vol, max_vol, new_muted, sound_changed, quiet); } static void @@ -1172,7 +1174,22 @@ do_action (GsdMediaKeysManager *manager, case VOLUME_DOWN_KEY: case VOLUME_UP_KEY: #ifdef HAVE_PULSE - do_sound_action (manager, type); + do_sound_action (manager, type, FALSE); +#endif /* HAVE_PULSE */ + break; + case MUTE_QUIET_KEY: +#ifdef HAVE_PULSE + do_sound_action (manager, MUTE_KEY, TRUE); +#endif /* HAVE_PULSE */ + break; + case VOLUME_DOWN_QUIET_KEY: +#ifdef HAVE_PULSE + do_sound_action (manager, VOLUME_DOWN_KEY, TRUE); +#endif /* HAVE_PULSE */ + break; + case VOLUME_UP_QUIET_KEY: +#ifdef HAVE_PULSE + do_sound_action (manager, VOLUME_UP_KEY, TRUE); #endif /* HAVE_PULSE */ break; case LOGOUT_KEY: @@ -1316,6 +1333,8 @@ acme_filter_events (GdkXEvent *xevent, switch (keys[i].key_type) { case VOLUME_DOWN_KEY: case VOLUME_UP_KEY: + case VOLUME_DOWN_QUIET_KEY: + case VOLUME_UP_QUIET_KEY: /* auto-repeatable keys */ if (xev->type != KeyPress) { return GDK_FILTER_CONTINUE; |