diff options
author | Lars Uebernickel <lars.uebernickel@canonical.com> | 2013-10-10 04:12:15 +0000 |
---|---|---|
committer | Tarmac <Unknown> | 2013-10-10 04:12:15 +0000 |
commit | 473db0554c2a3a4b428f261843508480627ef2d4 (patch) | |
tree | b02277b08d66649c4899537437fdda3eb1ee5b94 | |
parent | 7ffdaac644f29bd1ee63a861f42a4ea8c26e52eb (diff) | |
parent | 81c82dca758bf30134e2483dfa897de0baecf647 (diff) | |
download | ayatana-indicator-sound-473db0554c2a3a4b428f261843508480627ef2d4.tar.gz ayatana-indicator-sound-473db0554c2a3a4b428f261843508480627ef2d4.tar.bz2 ayatana-indicator-sound-473db0554c2a3a4b428f261843508480627ef2d4.zip |
Allow activating the 'volume' action
It does the same as the 'scroll' action except showing a notification. Fixes: https://bugs.launchpad.net/bugs/1236292.
Approved by Charles Kerr, PS Jenkins bot.
-rw-r--r-- | src/service.vala | 11 | ||||
-rw-r--r-- | src/sound-menu.vala | 2 |
2 files changed, 10 insertions, 3 deletions
diff --git a/src/service.vala b/src/service.vala index 1611608..e69bca8 100644 --- a/src/service.vala +++ b/src/service.vala @@ -87,8 +87,9 @@ public class IndicatorSound.Service { uint player_action_update_id; Notify.Notification notification; + const double volume_step_percentage = 0.06; + void activate_scroll_action (SimpleAction action, Variant? param) { - const double volume_step_percentage = 0.06; int delta = param.get_int32(); /* positive for up, negative for down */ double v = this.volume_control.get_volume () + volume_step_percentage * delta; @@ -202,12 +203,18 @@ public class IndicatorSound.Service { } Action create_volume_action () { - var volume_action = new SimpleAction.stateful ("volume", null, this.volume_control.get_volume ()); + var volume_action = new SimpleAction.stateful ("volume", VariantType.INT32, this.volume_control.get_volume ()); volume_action.change_state.connect ( (action, val) => { volume_control.set_volume (val.get_double ()); }); + /* activating this action changes the volume by the amount given in the parameter */ + volume_action.activate.connect ( (action, param) => { + double v = volume_control.get_volume () + volume_step_percentage * param.get_int32 (); + volume_control.set_volume (v.clamp (0.0, 1.0)); + }); + this.volume_control.volume_changed.connect (volume_changed); this.volume_control.bind_property ("ready", volume_action, "enabled", BindingFlags.SYNC_CREATE); diff --git a/src/sound-menu.vala b/src/sound-menu.vala index 9d0c521..1641219 100644 --- a/src/sound-menu.vala +++ b/src/sound-menu.vala @@ -31,7 +31,7 @@ class SoundMenu: Object this.volume_section = new Menu (); if (show_mute) volume_section.append (_("Mute"), "indicator.mute"); - volume_section.append_item (this.create_slider_menu_item ("indicator.volume", 0.0, 1.0, 0.01, + volume_section.append_item (this.create_slider_menu_item ("indicator.volume(0)", 0.0, 1.0, 0.01, "audio-volume-low-zero-panel", "audio-volume-high-panel")); |