aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2014-12-03 16:30:23 -0600
committerTed Gould <ted@gould.cx>2014-12-03 16:30:23 -0600
commit66cd2203d5fcee99d3264bc6f23c8d4683c299bf (patch)
tree8aa68c757e9a748531b35710084831e0d362f508 /src
parent119ae3decb89f0066dd5abf53d0ab1bef49c15c8 (diff)
downloadayatana-indicator-sound-66cd2203d5fcee99d3264bc6f23c8d4683c299bf.tar.gz
ayatana-indicator-sound-66cd2203d5fcee99d3264bc6f23c8d4683c299bf.tar.bz2
ayatana-indicator-sound-66cd2203d5fcee99d3264bc6f23c8d4683c299bf.zip
Switch from having custom signals for volume changing to using the property change signals.
Diffstat (limited to 'src')
-rw-r--r--src/service.vala24
-rw-r--r--src/volume-control.vala19
2 files changed, 19 insertions, 24 deletions
diff --git a/src/service.vala b/src/service.vala
index 1f9b880..c7e29e7 100644
--- a/src/service.vala
+++ b/src/service.vala
@@ -383,16 +383,6 @@ public class IndicatorSound.Service: Object {
return mute_action;
}
- void volume_changed (double volume) {
- var volume_action = this.actions.lookup_action ("volume") as SimpleAction;
-
- /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */
- volume_action.set_state (new Variant.double (volume / this.max_volume));
-
- this.update_root_icon ();
- this.update_sync_notification ();
- }
-
Action create_volume_action () {
/* The action's state is between be in [0.0, 1.0] instead of [0.0,
* max_volume], so that we don't need to update the slider menu item
@@ -417,7 +407,15 @@ public class IndicatorSound.Service: Object {
volume_control.volume = v.clamp (0.0, this.max_volume);
});
- this.volume_control.volume_changed.connect (volume_changed);
+ this.volume_control.notify["volume"].connect (() => {
+ var vol_action = this.actions.lookup_action ("volume") as SimpleAction;
+
+ /* Normalize volume, because the volume action's state is [0.0, 1.0], see create_volume_action() */
+ vol_action.set_state (new Variant.double (this.volume_control.volume / this.max_volume));
+
+ this.update_root_icon ();
+ this.update_sync_notification ();
+ });
this.volume_control.bind_property ("ready", volume_action, "enabled", BindingFlags.SYNC_CREATE);
@@ -431,8 +429,8 @@ public class IndicatorSound.Service: Object {
volume_control.mic_volume = val.get_double ();
});
- this.volume_control.mic_volume_changed.connect ( (volume) => {
- volume_action.set_state (new Variant.double (volume));
+ this.volume_control.notify["mic-volume"].connect ( () => {
+ volume_action.set_state (new Variant.double (this.volume_control.mic_volume));
});
this.volume_control.bind_property ("ready", volume_action, "enabled", BindingFlags.SYNC_CREATE);
diff --git a/src/volume-control.vala b/src/volume-control.vala
index d9a734c..22212d5 100644
--- a/src/volume-control.vala
+++ b/src/volume-control.vala
@@ -70,9 +70,6 @@ public class VolumeControl : Object
private double _account_service_volume = 0.0;
private bool _active_port_headphone = false;
- public signal void volume_changed (double v);
- public signal void mic_volume_changed (double v);
-
/** true when connected to the pulse server */
public bool ready { get; set; }
@@ -190,10 +187,10 @@ public class VolumeControl : Object
_volume != volume_to_double (i.volume.max ()))
{
_volume = volume_to_double (i.volume.max ());
- volume_changed (_volume);
+ this.notify_property("volume");
start_local_volume_timer();
} else if (this._active_port_headphone != old_active_port_headphone) {
- volume_changed (_volume);
+ this.notify_property("volume");
}
}
@@ -205,7 +202,7 @@ public class VolumeControl : Object
if (_mic_volume != volume_to_double (i.volume.values[0]))
{
_mic_volume = volume_to_double (i.volume.values[0]);
- mic_volume_changed (_mic_volume);
+ this.notify_property ("mic-volume");
}
}
@@ -261,7 +258,7 @@ public class VolumeControl : Object
if (volume != cvolume) {
/* Someone else changed the volume for this role, reflect on the indicator */
_volume = volume_to_double (volume);
- volume_changed (_volume);
+ this.notify_property("volume");
start_local_volume_timer();
}
}
@@ -304,7 +301,7 @@ public class VolumeControl : Object
iter.next ("(uu)", &type, &volume);
_volume = volume_to_double (volume);
- volume_changed (_volume);
+ this.notify_property("volume");
start_local_volume_timer();
} catch (GLib.Error e) {
warning ("unable to get volume for active role %s (%s)", sink_input_objp, e.message);
@@ -521,7 +518,7 @@ public class VolumeControl : Object
private void set_volume_success_cb (Context c, int success)
{
if ((bool)success)
- volume_changed (_volume);
+ this.notify_property("volume");
}
private void sink_info_set_volume_cb (Context c, SinkInfo? i, int eol)
@@ -567,7 +564,7 @@ public class VolumeControl : Object
new Variant ("(ssv)", "org.PulseAudio.Ext.StreamRestore1.RestoreEntry", "Volume", volume),
null, DBusCallFlags.NONE, -1);
- volume_changed (_volume);
+ this.notify_property("volume");
} catch (GLib.Error e) {
lock (_pa_volume_sig_count) {
_pa_volume_sig_count--;
@@ -599,7 +596,7 @@ public class VolumeControl : Object
void set_mic_volume_success_cb (Context c, int success)
{
if ((bool)success)
- mic_volume_changed (_mic_volume);
+ this.notify_property ("mic-volume");
}
void set_mic_volume_get_server_info_cb (PulseAudio.Context c, PulseAudio.ServerInfo? i) {