From 7ec3795022cbfff0e1c0c094309a4b67d1dd3b04 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 13 Oct 2014 20:51:07 -0500 Subject: Create actions based on the high volume status --- src/service.vala | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/service.vala') 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 (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); -- cgit v1.2.3 From a2de8d1b337113ced7854683aad0183a841917f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 08:12:58 -0500 Subject: Add high volume warnings to the phone menu --- src/service.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 92523aa..3edcba0 100644 --- a/src/service.vala +++ b/src/service.vala @@ -53,9 +53,9 @@ public class IndicatorSound.Service: Object { this.menus = new HashTable (str_hash, str_equal); this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); - this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); + this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); - this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); + this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); this.menus.@foreach ( (profile, menu) => { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); -- cgit v1.2.3 From 23b3fd431a312f2b02504b998c697241c30caa0b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 10:00:32 -0500 Subject: Drop the high volume menu action as that wasn't working --- src/service.vala | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 3edcba0..93e6a51 100644 --- a/src/service.vala +++ b/src/service.vala @@ -395,30 +395,9 @@ public class IndicatorSound.Service: Object { 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); -- cgit v1.2.3 From 16828d0102efae82bf760097988474e434b884fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 10:07:30 -0500 Subject: Changing tact to change the menu when we want to show the warning --- src/service.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 93e6a51..51060d4 100644 --- a/src/service.vala +++ b/src/service.vala @@ -53,9 +53,9 @@ public class IndicatorSound.Service: Object { this.menus = new HashTable (str_hash, str_equal); this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); - this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); + this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS)); this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE)); - this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.HIGH_VOLUME_WARNING)); + this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS)); this.menus.@foreach ( (profile, menu) => { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); -- cgit v1.2.3 From 8e7cbaadfed452063b2d659bc679746cad5cbb14 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 14 Oct 2014 10:16:15 -0500 Subject: Linking volume control and the menu visibility --- src/service.vala | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 51060d4..8f58110 100644 --- a/src/service.vala +++ b/src/service.vala @@ -61,6 +61,10 @@ public class IndicatorSound.Service: Object { this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE); }); + this.menus.@foreach ( (profile, menu) => { + this.volume_control.bind_property ("high-volume", menu, "show-high-volume-warning", BindingFlags.SYNC_CREATE); + }); + this.sync_preferred_players (); this.settings.changed["interested-media-players"].connect ( () => { this.sync_preferred_players (); -- cgit v1.2.3