~mhr3/libunity/fix-1062331

« back to all changes in this revision

Viewing changes to src/unity-lens-preferences-manager.vala

  • Committer: Tarmac
  • Author(s): Didier Roche
  • Date: 2012-09-26 12:10:54 UTC
  • mfrom: (180.1.9 libunity)
  • Revision ID: tarmac-20120926121054-dbqb5uw6foqspdke
Add remote search disabling option support to libunity for lenses to consume it.. Fixes: https://bugs.launchpad.net/bugs/1054746. Approved by Michal Hruby.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2012 Canonical, Ltd.
 
3
 *
 
4
 * This library is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU Lesser General Public License
 
6
 * version 3.0 as published by the Free Software Foundation.
 
7
 *
 
8
 * This library is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License version 3.0 for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public
 
14
 * License along with this library. If not, see
 
15
 * <http://www.gnu.org/licenses/>.
 
16
 *
 
17
 * Authored by Didier Roche <didrocks@ubuntu.com>
 
18
 *
 
19
 */
 
20
 
 
21
using Gee;
 
22
 
 
23
namespace Unity {
 
24
 
 
25
  /**
 
26
   * A singleton class that caches different gsettings settings.
 
27
   *
 
28
   */
 
29
  public class PreferencesManager : GLib.Object
 
30
  {
 
31
    private static PreferencesManager singleton = null;
 
32
 
 
33
    private Settings gp_settings;
 
34
    private const string REMOTE_CONTENT_KEY = "remote-content-search";
 
35
 
 
36
    public enum RemoteContent
 
37
    {
 
38
      ALL,
 
39
      NONE,
 
40
    }
 
41
    
 
42
    private PreferencesManager ()
 
43
    {
 
44
      Object();
 
45
    }
 
46
 
 
47
    construct
 
48
    {
 
49
      gp_settings = new Settings ("com.canonical.Unity.Lenses");
 
50
      gp_settings.bind (REMOTE_CONTENT_KEY, this, "remote_content_search", SettingsBindFlags.GET);
 
51
    }
 
52
 
 
53
    public RemoteContent remote_content_search { get; set; default = RemoteContent.ALL; }
 
54
    
 
55
    /**
 
56
     * Get a ref to the singleton PreferencesManager
 
57
     */
 
58
    public static PreferencesManager get_default ()
 
59
    {
 
60
      if (PreferencesManager.singleton == null)
 
61
        PreferencesManager.singleton = new PreferencesManager();
 
62
      
 
63
      return PreferencesManager.singleton;
 
64
    }
 
65
    
 
66
  } /* class PreferencesManager */
 
67
 
 
68
} /* namespace */