aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharles kerr <charlesk@canonical.com>2015-12-19 21:31:12 -0600
committercharles kerr <charlesk@canonical.com>2015-12-19 21:31:12 -0600
commitaf0d715e8a451cac638980c67d1a4be0634a6b79 (patch)
tree0894fdc9fb56d4138bf3dba7e9c0ce8c02edfe7c
parent6773fd52378cca6b3b8058923f4262633cc8f71e (diff)
downloadayatana-indicator-sound-af0d715e8a451cac638980c67d1a4be0634a6b79.tar.gz
ayatana-indicator-sound-af0d715e8a451cac638980c67d1a4be0634a6b79.tar.bz2
ayatana-indicator-sound-af0d715e8a451cac638980c67d1a4be0634a6b79.zip
remove high-volume-approved from volume-control
-rw-r--r--src/service.vala6
-rw-r--r--src/volume-control-pulse.vala68
-rw-r--r--src/volume-control.vala2
-rw-r--r--src/volume-warning.vala18
4 files changed, 11 insertions, 83 deletions
diff --git a/src/service.vala b/src/service.vala
index 55743b5..f03fe19 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -622,7 +622,7 @@ public class IndicatorSound.Service: Object {
bool ignore_warning_this_time = _volume_warning.ignore_high_volume;
var warn = loud
&& this.notify_server_supports_actions
- && !this.volume_control.high_volume_approved
+ && !_volume_warning.high_volume_approved
&& !ignore_warning_this_time;
if (waiting_user_approve_warn && !_options.is_loud(volume_control.volume)) {
volume_control.set_warning_volume();
@@ -638,7 +638,7 @@ public class IndicatorSound.Service: Object {
warn_notification.clear_actions();
warn_notification.add_action ("ok", _("OK"), (n, a) => {
stop_clamp_to_high_timeout();
- volume_control.approve_high_volume ();
+ _volume_warning.approve_high_volume ();
// restore the volume the user introduced
VolumeControl.Volume vol = new VolumeControl.Volume();
vol.volume = volume_control.get_pre_clamped_volume();
@@ -658,7 +658,7 @@ public class IndicatorSound.Service: Object {
} else {
if (!waiting_user_approve_warn) {
close_notification(warn_notification);
-
+
if (notify_server_supports_sync && !block_info_notifications && !ignore_warning_this_time) {
/* Determine Label */
string volume_label = get_notification_label ();
diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala
index 985b897..251eae5 100644
--- a/src/volume-control-pulse.vala
+++ b/src/volume-control-pulse.vala
@@ -44,7 +44,6 @@ public class VolumeControlPulse : VolumeControl
private bool _is_playing = false;
private VolumeControl.Volume _volume = new VolumeControl.Volume();
private double _mic_volume = 0.0;
- private Settings _settings = new Settings ("com.canonical.indicator.sound");
/* Used by the pulseaudio stream restore extension */
private DBusConnection _pconn;
@@ -117,7 +116,6 @@ public class VolumeControlPulse : VolumeControl
private void init_all_properties()
{
init_high_volume();
- init_high_volume_approved();
}
~VolumeControlPulse ()
@@ -133,7 +131,6 @@ public class VolumeControlPulse : VolumeControl
}
stop_local_volume_timer();
stop_account_service_volume_timer();
- stop_high_volume_approved_timer();
}
private VolumeControl.ActiveOutput calculate_active_output (SinkInfo? sink) {
@@ -262,9 +259,6 @@ public class VolumeControlPulse : VolumeControl
(active_output_now != VolumeControl.ActiveOutput.CALL_MODE &&
active_output_before != VolumeControl.ActiveOutput.CALL_MODE)) {
this.active_output_changed (active_output_now);
- if (active_output_now == VolumeControl.ActiveOutput.SPEAKERS) {
- _high_volume_approved = false;
- }
update_high_volume();
}
@@ -757,68 +751,6 @@ public class VolumeControlPulse : VolumeControl
volume = vol;
}
- /** HIGH VOLUME APPROVED PROPERTY **/
-
- private bool _high_volume_approved = false;
- private uint _high_volume_approved_timer = 0;
- private int64 _high_volume_approved_at = 0;
- private int64 _high_volume_approved_ttl_usec = 0;
- public override bool high_volume_approved {
- get { return this._high_volume_approved; }
- private set { this._high_volume_approved = value; }
- }
- private void init_high_volume_approved() {
- _settings.changed["warning-volume-confirmation-ttl"].connect(() => update_high_volume_approved_cache());
- update_high_volume_approved_cache();
- }
- private void update_high_volume_approved_cache() {
- _high_volume_approved_ttl_usec = _settings.get_int("warning-volume-confirmation-ttl");
- _high_volume_approved_ttl_usec *= 1000000;
-
- update_high_volume_approved();
- update_high_volume_approved_timer();
- }
- private void update_high_volume_approved_timer() {
- stop_high_volume_approved_timer();
- if (_high_volume_approved_at != 0) {
- int64 expires_at = _high_volume_approved_at + _high_volume_approved_ttl_usec;
- int64 now = GLib.get_monotonic_time();
- if (expires_at > now) {
- var seconds_left = 1 + ((expires_at - now) / 1000000);
- _high_volume_approved_timer = Timeout.add_seconds((uint)seconds_left, on_high_volume_approved_timer);
- }
- }
- }
- private void stop_high_volume_approved_timer() {
- if (_high_volume_approved_timer != 0) {
- Source.remove (_high_volume_approved_timer);
- _high_volume_approved_timer = 0;
- }
- }
- private bool on_high_volume_approved_timer() {
- _high_volume_approved_timer = 0;
- update_high_volume_approved();
- return false; /* Source.REMOVE */
- }
- private void update_high_volume_approved() {
- var new_high_volume_approved = calculate_high_volume_approved();
- if (high_volume_approved != new_high_volume_approved) {
- debug("changing high_volume_approved from %d to %d", (int)high_volume_approved, (int)new_high_volume_approved);
- high_volume_approved = new_high_volume_approved;
- }
- }
- private bool calculate_high_volume_approved() {
- int64 now = GLib.get_monotonic_time();
- return (_high_volume_approved_at != 0)
- && (_high_volume_approved_at + _high_volume_approved_ttl_usec >= now);
- }
- public override void approve_high_volume() {
- _high_volume_approved_at = GLib.get_monotonic_time();
- update_high_volume_approved();
- update_high_volume_approved_timer();
- }
-
-
/** MIC VOLUME PROPERTY */
public override double mic_volume {
diff --git a/src/volume-control.vala b/src/volume-control.vala
index 430e9c5..d35708f 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -63,8 +63,6 @@ public abstract class VolumeControl : Object
public virtual Volume volume { get { return _volume; } set { } }
public virtual double mic_volume { get { return 0.0; } set { } }
- public virtual bool high_volume_approved { get { return false; } protected set { } }
- public virtual void approve_high_volume() { }
public virtual void clamp_to_high_volume() { }
public virtual void set_warning_volume() { }
diff --git a/src/volume-warning.vala b/src/volume-warning.vala
index 452acbe..99ae772 100644
--- a/src/volume-warning.vala
+++ b/src/volume-warning.vala
@@ -706,14 +706,17 @@ public class VolumeWarning : VolumeControl
/** HIGH VOLUME APPROVED PROPERTY **/
- private bool _high_volume_approved = false;
+ public bool high_volume_approved { get; private set; default = false; }
+
+ public void approve_high_volume() {
+ _high_volume_approved_at = GLib.get_monotonic_time();
+ update_high_volume_approved();
+ update_high_volume_approved_timer();
+ }
+
private uint _high_volume_approved_timer = 0;
private int64 _high_volume_approved_at = 0;
private int64 _high_volume_approved_ttl_usec = 0;
- public override bool high_volume_approved {
- get { return this._high_volume_approved; }
- private set { this._high_volume_approved = value; }
- }
private void init_high_volume_approved() {
_settings.changed["warning-volume-confirmation-ttl"].connect(() => update_high_volume_approved_cache());
update_high_volume_approved_cache();
@@ -759,11 +762,6 @@ public class VolumeWarning : VolumeControl
return (_high_volume_approved_at != 0)
&& (_high_volume_approved_at + _high_volume_approved_ttl_usec >= now);
}
- public override void approve_high_volume() {
- _high_volume_approved_at = GLib.get_monotonic_time();
- update_high_volume_approved();
- update_high_volume_approved_timer();
- }
/** MIC VOLUME PROPERTY */