aboutsummaryrefslogtreecommitdiff
path: root/src/settings-manager.vala
blob: 05db430aa774deefaf0a1cd869d1e5ec015fb378 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
Copyright 2010 Canonical Ltd.

Authors:
    Conor Curran <conor.curran@canonical.com>

This program is free software: you can redistribute it and/or modify it 
under the terms of the GNU General Public License version 3, as published 
by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranties of 
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
PURPOSE.  See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along 
with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
using Gee;

public class SettingsManager : GLib.Object
{
  private Settings settings;
  public signal void blacklist_updates ( string[] new_blacklist );
  
  public SettingsManager ( ){
  }
  construct{
    this.settings = new Settings ("com.canonical.indicators.sound");
    settings.changed["blacklisted-media-players"].connect (on_blacklist_event);    
  }
   
  public string[] fetch_blacklist()
  {
    return this.settings.get_strv ("blacklisted-media-players");
  }

  public string[] fetch_interested()
  {
    return this.settings.get_strv ("interested-media-players");
  }

  public bool add_interested(string app_desktop_name)
  {
    string[] already_interested = fetch_interested();
    already_interested += (app_desktop_name);
    return this.settings.set_strv( "interested-media-players",
                                    already_interested );
  }

  private void on_blacklist_event()
  {
    this.blacklist_updates(this.settings.get_strv ("blacklisted-media-players"));        
  }  
}