diff options
author | Xavi Garcia Mena <xavi.garcia.mena@canonical.com> | 2016-03-07 10:13:38 +0000 |
---|---|---|
committer | CI Train Bot <ci-train-bot@canonical.com> | 2016-03-07 10:13:38 +0000 |
commit | 57f5cbe43e95d72e0904473ab371e9e016b73956 (patch) | |
tree | b8186a4701bbafcf9fc9a71bbcb35fd9b3ee81d1 /src/service.vala | |
parent | de4abb7448d329f7e7c20e01f8b14f22627a69a3 (diff) | |
parent | 3aa67455801c7db139be5a9293ddb6d7d703a981 (diff) | |
download | ayatana-indicator-sound-57f5cbe43e95d72e0904473ab371e9e016b73956.tar.gz ayatana-indicator-sound-57f5cbe43e95d72e0904473ab371e9e016b73956.tar.bz2 ayatana-indicator-sound-57f5cbe43e95d72e0904473ab371e9e016b73956.zip |
This branch sets the last running player using accounts service instead of gsettings.
It also includes a new class AccountsServiceAccess, to centralize all accesses to account service properties.
Approved by: PS Jenkins bot, Charles Kerr
Diffstat (limited to 'src/service.vala')
-rw-r--r-- | src/service.vala | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/service.vala b/src/service.vala index cb30820..bdc4d40 100644 --- a/src/service.vala +++ b/src/service.vala @@ -20,7 +20,9 @@ public class IndicatorSound.Service: Object { DBusConnection bus; - public Service (MediaPlayerList playerlist, VolumeControl volume, AccountsServiceUser? accounts, Options options, VolumeWarning volume_warning) { + public Service (MediaPlayerList playerlist, VolumeControl volume, AccountsServiceUser? accounts, Options options, VolumeWarning volume_warning, AccountsServiceAccess? accounts_service_access) { + + _accounts_service_access = accounts_service_access; try { bus = Bus.get_sync(GLib.BusType.SESSION); @@ -60,7 +62,6 @@ public class IndicatorSound.Service: Object { headphones = false; break; } - message("setting _volume_warning.headphones_active to %d", (int)headphones); _volume_warning.headphones_active = headphones; update_root_icon(); @@ -91,12 +92,11 @@ public class IndicatorSound.Service: Object { this.actions.add_action (this.create_high_volume_action ()); this.actions.add_action (this.create_volume_sync_action ()); - string last_player = this.settings.get_string ("last-running-player"); 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, last_player)); - this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS, last_player)); - this.menus.insert ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS_PLAY_CONTROLS | SoundMenu.DisplayFlags.ADD_PLAY_CONTROL_INACTIVE_PLAYER, last_player)); - this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS, last_player)); + 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 ("desktop", new SoundMenu ("indicator.desktop-settings", SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS_PLAY_CONTROLS | SoundMenu.DisplayFlags.ADD_PLAY_CONTROL_INACTIVE_PLAYER)); + 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); @@ -112,7 +112,13 @@ public class IndicatorSound.Service: Object { this.menus.@foreach ( (profile, menu) => { menu.last_player_updated.connect ((player_id) => { - this.settings.set_value ("last-running-player", player_id); + this._accounts_service_access.last_running_player = player_id; + }); + }); + + this._accounts_service_access.notify["last-running-player"].connect(() => { + this.menus.@foreach ( (profile, menu) => { + menu.set_default_player (this._accounts_service_access.last_running_player); }); }); @@ -199,6 +205,7 @@ public class IndicatorSound.Service: Object { private Options _options; private VolumeWarning _volume_warning; private IndicatorSound.InfoNotification _info_notification = new IndicatorSound.InfoNotification(); + private AccountsServiceAccess _accounts_service_access; const double volume_step_percentage = 0.06; |