From 8d981b26459b98189ab3200a23d75ecd0294fb2b Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Tue, 10 Nov 2015 14:56:02 +0100 Subject: Restore code to allow amplified volume --- src/service.vala | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index a08edf3..1173194 100644 --- a/src/service.vala +++ b/src/service.vala @@ -47,6 +47,7 @@ public class IndicatorSound.Service: Object { () => { debug("Notifications name vanshed"); notify_server_caps_checked = false; }); this.settings = new Settings ("com.canonical.indicator.sound"); + this.sharedsettings = new Settings ("com.ubuntu.sound"); this.settings.bind ("visible", this, "visible", SettingsBindFlags.GET); this.notify["visible"].connect ( () => this.update_root_icon () ); @@ -95,6 +96,8 @@ public class IndicatorSound.Service: Object { this.sync_preferred_players (); }); + sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET); + /* Hide the notification when the menu is shown */ var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction; shown_action.change_state.connect ((state) => { @@ -173,6 +176,28 @@ public class IndicatorSound.Service: Object { public bool visible { get; set; } + public bool allow_amplified_volume { + get { + return this.volume_control.max_volume > 1.0; + } + + set { + if (this.allow_amplified_volume == value) + return; + + if (value) { + /* from pulse/volume.h: #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0)) */ + this.volume_control.max_volume = (double)PulseAudio.Volume.sw_from_dB(11.0) / PulseAudio.Volume.NORM; + } + else { + this.volume_control.max_volume = 1.0; + } + + /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */ + this.actions.change_action_state ("volume", this.volume_control.volume.volume / this.volume_control.max_volume); + } + } + const ActionEntry[] action_entries = { { "root", null, null, "@a{sv} {}", null }, { "scroll", activate_scroll_action, "i", null, null }, @@ -184,6 +209,7 @@ public class IndicatorSound.Service: Object { SimpleActionGroup actions; HashTable menus; Settings settings; + Settings sharedsettings; VolumeControl volume_control; MediaPlayerList players; uint player_action_update_id; -- cgit v1.2.3 From 7c69f81a079a08d58241cc50365dde7d37ad3345 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Tue, 1 Dec 2015 12:22:00 +0100 Subject: Added action to sync volume with UI --- src/service.vala | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 985d434..8f90547 100644 --- a/src/service.vala +++ b/src/service.vala @@ -40,7 +40,11 @@ public class IndicatorSound.Service: Object { warn_notification.set_hint ("x-canonical-non-shaped-icon", "true"); warn_notification.set_hint ("x-canonical-snap-decisions", "true"); warn_notification.set_hint ("x-canonical-private-affirmative-tint", "true"); - warn_notification.closed.connect((n) => { n.clear_actions(); waiting_user_approve_warn=false; }); + warn_notification.closed.connect((n) => { + n.clear_actions(); + waiting_user_approve_warn=false; + volume_sync_action.set_state(volume_sync_number_++); + }); BusWatcher.watch_namespace (GLib.BusType.SESSION, "org.freedesktop.Notifications", () => { debug("Notifications name appeared"); }, @@ -77,6 +81,7 @@ public class IndicatorSound.Service: Object { 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_action ()); + this.actions.add_action (this.create_volume_sync_action ()); 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)); @@ -634,6 +639,7 @@ public class IndicatorSound.Service: Object { warn_notification.add_action ("cancel", _("Cancel"), (n, a) => { _pre_warn_volume = null; waiting_user_approve_warn = false; + volume_sync_action.set_state(volume_sync_number_++); }); waiting_user_approve_warn = true; show_notification(warn_notification); @@ -818,6 +824,14 @@ public class IndicatorSound.Service: Object { return high_volume_action; } + SimpleAction volume_sync_action; + uint64 volume_sync_number_ = 0; + Action create_volume_sync_action () { + volume_sync_action = new SimpleAction.stateful("volume-sync", null, new Variant.uint64 (volume_sync_number_)); + + return volume_sync_action; + } + uint export_actions = 0; Variant action_state_for_player (MediaPlayer player, bool show_track = true) { -- cgit v1.2.3 From d9a00604c1d8e3103444053da39a4af17230903b Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Wed, 2 Dec 2015 14:44:58 +0100 Subject: Added integration tests --- src/service.vala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 8f90547..3ac6b89 100644 --- a/src/service.vala +++ b/src/service.vala @@ -43,7 +43,7 @@ public class IndicatorSound.Service: Object { warn_notification.closed.connect((n) => { n.clear_actions(); waiting_user_approve_warn=false; - volume_sync_action.set_state(volume_sync_number_++); + volume_sync_action.set_state(new Variant.uint64 (++volume_sync_number_)); }); BusWatcher.watch_namespace (GLib.BusType.SESSION, "org.freedesktop.Notifications", @@ -639,7 +639,7 @@ public class IndicatorSound.Service: Object { warn_notification.add_action ("cancel", _("Cancel"), (n, a) => { _pre_warn_volume = null; waiting_user_approve_warn = false; - volume_sync_action.set_state(volume_sync_number_++); + volume_sync_action.set_state(new Variant.uint64 (++volume_sync_number_)); }); waiting_user_approve_warn = true; show_notification(warn_notification); @@ -827,7 +827,7 @@ public class IndicatorSound.Service: Object { SimpleAction volume_sync_action; uint64 volume_sync_number_ = 0; Action create_volume_sync_action () { - volume_sync_action = new SimpleAction.stateful("volume-sync", null, new Variant.uint64 (volume_sync_number_)); + volume_sync_action = new SimpleAction.stateful("volume-sync", VariantType.UINT64, new Variant.uint64 (volume_sync_number_)); return volume_sync_action; } -- cgit v1.2.3 From c61e4c4f2c5e24f374c0d6e3c90c318443403c94 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Wed, 2 Dec 2015 17:19:19 +0100 Subject: Changes after review. Method to increment sync counter and integration test changed --- src/service.vala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 3ac6b89..923aba2 100644 --- a/src/service.vala +++ b/src/service.vala @@ -43,7 +43,7 @@ public class IndicatorSound.Service: Object { warn_notification.closed.connect((n) => { n.clear_actions(); waiting_user_approve_warn=false; - volume_sync_action.set_state(new Variant.uint64 (++volume_sync_number_)); + increment_volume_sync_action(); }); BusWatcher.watch_namespace (GLib.BusType.SESSION, "org.freedesktop.Notifications", @@ -639,7 +639,7 @@ public class IndicatorSound.Service: Object { warn_notification.add_action ("cancel", _("Cancel"), (n, a) => { _pre_warn_volume = null; waiting_user_approve_warn = false; - volume_sync_action.set_state(new Variant.uint64 (++volume_sync_number_)); + increment_volume_sync_action(); }); waiting_user_approve_warn = true; show_notification(warn_notification); @@ -832,6 +832,10 @@ public class IndicatorSound.Service: Object { return volume_sync_action; } + void increment_volume_sync_action () { + volume_sync_action.set_state(new Variant.uint64 (++volume_sync_number_)); + } + uint export_actions = 0; Variant action_state_for_player (MediaPlayer player, bool show_track = true) { -- cgit v1.2.3 From 7ec5db7e050505bbcb04a70edacec4075389a2df Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Fri, 4 Dec 2015 11:46:27 +0100 Subject: Setting user selected volume when pressing OK in the high volume dialog --- src/service.vala | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 923aba2..312fec5 100644 --- a/src/service.vala +++ b/src/service.vala @@ -629,11 +629,13 @@ public class IndicatorSound.Service: Object { warn_notification.add_action ("ok", _("OK"), (n, a) => { stop_clamp_to_high_timeout(); volume_control.approve_high_volume (); - if (_pre_warn_volume != null) { - var tmp = _pre_warn_volume; - _pre_warn_volume = null; - volume_control.volume = tmp; - } + // restore the volume the user introduced + VolumeControl.Volume vol = new VolumeControl.Volume(); + vol.volume = volume_control.get_pre_clamped_volume(); + vol.reason = VolumeControl.VolumeReasons.USER_KEYPRESS; + _pre_warn_volume = null; + volume_control.volume = vol; + waiting_user_approve_warn = false; }); warn_notification.add_action ("cancel", _("Cancel"), (n, a) => { -- cgit v1.2.3 From 292592932ea18777ad15b3b0c07d17047781cde8 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Mon, 14 Dec 2015 18:09:24 +0100 Subject: rolling back lp:~xavi-garcia-mena/indicator-sound/bug-1512798-reenable-amplified-volume --- src/service.vala | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 9127f05..312fec5 100644 --- a/src/service.vala +++ b/src/service.vala @@ -51,7 +51,6 @@ public class IndicatorSound.Service: Object { () => { debug("Notifications name vanshed"); notify_server_caps_checked = false; }); this.settings = new Settings ("com.canonical.indicator.sound"); - this.sharedsettings = new Settings ("com.ubuntu.sound"); this.settings.bind ("visible", this, "visible", SettingsBindFlags.GET); this.notify["visible"].connect ( () => this.update_root_icon () ); @@ -107,8 +106,6 @@ public class IndicatorSound.Service: Object { this.sync_preferred_players (); }); - sharedsettings.bind ("allow-amplified-volume", this, "allow-amplified-volume", SettingsBindFlags.GET); - /* Hide the notification when the menu is shown */ var shown_action = actions.lookup_action ("indicator-shown") as SimpleAction; shown_action.change_state.connect ((state) => { @@ -187,28 +184,6 @@ public class IndicatorSound.Service: Object { public bool visible { get; set; } - public bool allow_amplified_volume { - get { - return this.volume_control.max_volume > 1.0; - } - - set { - if (this.allow_amplified_volume == value) - return; - - if (value) { - /* from pulse/volume.h: #define PA_VOLUME_UI_MAX (pa_sw_volume_from_dB(+11.0)) */ - this.volume_control.max_volume = (double)PulseAudio.Volume.sw_from_dB(11.0) / PulseAudio.Volume.NORM; - } - else { - this.volume_control.max_volume = 1.0; - } - - /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */ - this.actions.change_action_state ("volume", this.volume_control.volume.volume / this.volume_control.max_volume); - } - } - const ActionEntry[] action_entries = { { "root", null, null, "@a{sv} {}", null }, { "scroll", activate_scroll_action, "i", null, null }, @@ -220,7 +195,6 @@ public class IndicatorSound.Service: Object { SimpleActionGroup actions; HashTable menus; Settings settings; - Settings sharedsettings; VolumeControl volume_control; MediaPlayerList players; uint player_action_update_id; -- cgit v1.2.3 From 093d3198061540ce76b2f526926cdbb6c929bcd8 Mon Sep 17 00:00:00 2001 From: Xavi Garcia Mena Date: Thu, 17 Dec 2015 18:03:27 +0100 Subject: Added workaround for Maroon in Trouble, second option --- src/service.vala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/service.vala') diff --git a/src/service.vala b/src/service.vala index 312fec5..0a7e108 100644 --- a/src/service.vala +++ b/src/service.vala @@ -611,9 +611,11 @@ public class IndicatorSound.Service: Object { notify_server_caps_checked = true; var loud = volume_control.high_volume; + bool ignore_warning_this_time = this.volume_control.ignore_high_volume; var warn = loud && this.notify_server_supports_actions - && !this.volume_control.high_volume_approved; + && !this.volume_control.high_volume_approved + && !ignore_warning_this_time; if (waiting_user_approve_warn && volume_control.below_warning_volume) { volume_control.set_warning_volume(); close_notification(warn_notification); @@ -649,8 +651,7 @@ public class IndicatorSound.Service: Object { if (!waiting_user_approve_warn) { close_notification(warn_notification); - if (notify_server_supports_sync && !block_info_notifications) { - + if (notify_server_supports_sync && !block_info_notifications && !ignore_warning_this_time) { /* Determine Label */ string volume_label = get_notification_label (); -- cgit v1.2.3