aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-10-13 20:51:07 -0500
committerTed Gould <ted@gould.cx>2014-10-13 20:51:07 -0500
commit7ec3795022cbfff0e1c0c094309a4b67d1dd3b04 (patch)
treea0bf967c3c172b907f23dc571e1fdd1084457423 /src
parent9c8f845b511cf8a8a02cb90df5546ff852978ed6 (diff)
downloadayatana-indicator-sound-7ec3795022cbfff0e1c0c094309a4b67d1dd3b04.tar.gz
ayatana-indicator-sound-7ec3795022cbfff0e1c0c094309a4b67d1dd3b04.tar.bz2
ayatana-indicator-sound-7ec3795022cbfff0e1c0c094309a4b67d1dd3b04.zip
Create actions based on the high volume status
Diffstat (limited to 'src')
-rw-r--r--src/service.vala31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/service.vala b/src/service.vala
index 2a65492..92523aa 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -49,6 +49,7 @@ public class IndicatorSound.Service: Object {
this.actions.add_action (this.create_mute_action ());
this.actions.add_action (this.create_volume_action ());
this.actions.add_action (this.create_mic_volume_action ());
+ this.actions.add_action (this.create_high_volume_actions ());
this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal);
this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
@@ -388,6 +389,36 @@ public class IndicatorSound.Service: Object {
return volume_action;
}
+ Action create_high_volume_actions () {
+ var high_volume_action = new SimpleAction.stateful("high-volume", null, new Variant.boolean (this.volume_control.high_volume));
+
+ this.volume_control.notify["high_volume"].connect( () =>
+ high_volume_action.set_state(new Variant.boolean (this.volume_control.high_volume)));
+
+ /* So this is a bit confusing, putting it here because everywhere else
+ sucks too. It might create an action and put it into the action group.
+ Which is sneaky. Better to have the code not duplicated, but no good
+ place to put code like that. */
+ setup_high_volume_menu_action();
+
+ return high_volume_action;
+ }
+
+ void setup_high_volume_menu_action () {
+ this.volume_control.notify["high_volume"].connect(update_high_volume_menu_action);
+ update_high_volume_menu_action();
+ }
+
+ void update_high_volume_menu_action () {
+ if (this.volume_control.high_volume) {
+ var menu_action = new SimpleAction("high-volume-menu", null);
+ menu_action.set_enabled(false);
+ this.actions.add_action(menu_action);
+ } else {
+ this.actions.remove_action("high-volume-menu");
+ }
+ }
+
void bus_acquired (DBusConnection connection, string name) {
try {
connection.export_action_group ("/com/canonical/indicator/sound", this.actions);