3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this
7
* This program is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
23
using System.Collections;
24
using System.Collections.Generic;
25
using Env = System.Environment;
31
class CorePreferences {
33
#region Key constants and default values
34
const string ThemeKey = "Theme";
35
const string QuietStartKey = "QuietStart";
36
const string StartAtLoginKey = "StartAtLogin";
37
const string AlwaysShowResultsKey = "AlwaysShowResults";
39
const string ThemeDefaultValue = "Classic Interface";
40
const bool QuietStartDefaultValue = false;
41
const bool StartAtLoginDefaultValue = false;
42
const bool AlwaysShowResultsDefaultValue = false;
43
const string TextModeKeybindingDefaultValue = "period";
44
const string SummonKeybindingDefaultValue = "<Super>space";
46
const string DebugOption = "--debug";
47
const string LogToFileOption = "--log-to-file";
52
public event EventHandler<PreferencesChangedEventArgs> ThemeChanged;
54
IPreferences Preferences { get; set; }
56
public CorePreferences ()
58
Preferences = Services.Preferences.Get<CorePreferences> ();
59
Preferences.PreferencesChanged += PreferencesChanged;
62
public bool WriteLogToFile {
63
get { return HasOption (LogToFileOption); }
66
public static bool PeekDebug {
67
get { return HasOption (DebugOption); }
71
get { return CorePreferences.PeekDebug; }
75
get { return Preferences.Get (ThemeKey, ThemeDefaultValue); }
76
set { Preferences.Set (ThemeKey, value); }
79
public bool QuietStart {
80
get { return Preferences.Get (QuietStartKey, QuietStartDefaultValue); }
81
set { Preferences.Set (QuietStartKey, value); }
84
public bool StartAtLogin {
85
get { return Preferences.Get(StartAtLoginKey, StartAtLoginDefaultValue); }
86
set { Preferences.Set (StartAtLoginKey, value); }
89
public bool AlwaysShowResults {
90
get { return Preferences.Get (AlwaysShowResultsKey, AlwaysShowResultsDefaultValue); }
91
set { Preferences.Set (AlwaysShowResultsKey, value); }
94
static bool HasOption (string option)
96
return Env.GetCommandLineArgs ().Contains (option);
100
void PreferencesChanged (object sender, PreferencesChangedEventArgs e)
104
if (ThemeChanged != null)
105
ThemeChanged (this, e);