~ci-train-bot/indicator-sound/indicator-sound-ubuntu-zesty-2138

« back to all changes in this revision

Viewing changes to src/service.vala

  • Committer: CI Train Bot
  • Author(s): Xavi Garcia Mena
  • Date: 2016-03-07 10:13:38 UTC
  • mfrom: (529.1.8 last-runnin-player-charles)
  • Revision ID: ci-train-bot@canonical.com-20160307101338-x2wynmsb4sch7jag
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

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
public class IndicatorSound.Service: Object {
21
21
        DBusConnection bus;
22
22
 
23
 
        public Service (MediaPlayerList playerlist, VolumeControl volume, AccountsServiceUser? accounts, Options options, VolumeWarning volume_warning) {
 
23
        public Service (MediaPlayerList playerlist, VolumeControl volume, AccountsServiceUser? accounts, Options options, VolumeWarning volume_warning, AccountsServiceAccess? accounts_service_access) {
 
24
 
 
25
                _accounts_service_access = accounts_service_access;
24
26
 
25
27
                try {
26
28
                        bus = Bus.get_sync(GLib.BusType.SESSION);
60
62
                                        headphones = false;
61
63
                                        break;
62
64
                        }
63
 
                        message("setting _volume_warning.headphones_active to %d", (int)headphones);
64
65
                        _volume_warning.headphones_active = headphones;
65
66
 
66
67
                        update_root_icon();
91
92
                this.actions.add_action (this.create_high_volume_action ());
92
93
                this.actions.add_action (this.create_volume_sync_action ());
93
94
 
94
 
                string last_player = this.settings.get_string ("last-running-player");
95
95
                this.menus = new HashTable<string, SoundMenu> (str_hash, str_equal);
96
 
                this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS, last_player));
97
 
                this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS, last_player));
98
 
                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));
99
 
                this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS, last_player));
 
96
                this.menus.insert ("desktop_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_MUTE | SoundMenu.DisplayFlags.HIDE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
 
97
                this.menus.insert ("phone_greeter", new SoundMenu (null, SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS | SoundMenu.DisplayFlags.GREETER_PLAYERS));
 
98
                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));
 
99
                this.menus.insert ("phone", new SoundMenu ("indicator.phone-settings", SoundMenu.DisplayFlags.SHOW_SILENT_MODE | SoundMenu.DisplayFlags.HIDE_INACTIVE_PLAYERS));
100
100
 
101
101
                this.menus.@foreach ( (profile, menu) => {
102
102
                        this.volume_control.bind_property ("active-mic", menu, "show-mic-volume", BindingFlags.SYNC_CREATE);
112
112
 
113
113
                this.menus.@foreach ( (profile, menu) => {
114
114
                        menu.last_player_updated.connect ((player_id) => { 
115
 
                                this.settings.set_value ("last-running-player", player_id);
 
115
                                this._accounts_service_access.last_running_player = player_id;
 
116
                        });
 
117
                });
 
118
 
 
119
                this._accounts_service_access.notify["last-running-player"].connect(() => {
 
120
                        this.menus.@foreach ( (profile, menu) => {
 
121
                                menu.set_default_player (this._accounts_service_access.last_running_player);
116
122
                        });
117
123
                });
118
124
 
199
205
        private Options _options;
200
206
        private VolumeWarning _volume_warning;
201
207
        private IndicatorSound.InfoNotification _info_notification = new IndicatorSound.InfoNotification();
 
208
        private AccountsServiceAccess _accounts_service_access;
202
209
 
203
210
        const double volume_step_percentage = 0.06;
204
211