-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathPreferences.cs
202 lines (151 loc) · 6.15 KB
/
Preferences.cs
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
using System;
using Mono.Unix;
namespace Tomboy
{
public class Preferences
{
public const string ENABLE_SPELLCHECKING = "/apps/tomboy/enable_spellchecking";
public const string ENABLE_WIKIWORDS = "/apps/tomboy/enable_wikiwords";
public const string ENABLE_CUSTOM_FONT = "/apps/tomboy/enable_custom_font";
public const string ENABLE_CUSTOM_SEARCH_MATCH_COLOR = "/apps/tomboy/enable_custom_search_match_color";
public const string ENABLE_KEYBINDINGS = "/apps/tomboy/enable_keybindings";
public const string ENABLE_STARTUP_NOTES = "/apps/tomboy/enable_startup_notes";
public const string ENABLE_AUTO_BULLETED_LISTS = "/apps/tomboy/enable_bulleted_lists";
public const string ENABLE_ICON_PASTE = "/apps/tomboy/enable_icon_paste";
public const string ENABLE_CLOSE_NOTE_ON_ESCAPE = "/apps/tomboy/enable_close_note_on_escape";
public const string ENABLE_TRAY_ICON = "/apps/tomboy/enable_tray_icon";
public const string ENABLE_DELETE_CONFIRM = "/apps/tomboy/enable_delete_confirm";
public const string START_NOTE_URI = "/apps/tomboy/start_note";
public const string CUSTOM_FONT_FACE = "/apps/tomboy/custom_font_face";
public const string CUSTOM_SEARCH_MATCH_COLOR = "/apps/tomboy/custom_search_match_color";
public const string MENU_NOTE_COUNT = "/apps/tomboy/menu_note_count";
public const string MENU_MAX_NOTE_COUNT = "/apps/tomboy/menu_max_note_count";
public const string MENU_PINNED_NOTES = "/apps/tomboy/menu_pinned_notes";
public const string MENU_ITEM_MAX_LENGTH = "/apps/tomboy/tray_menu_item_max_length";
public const string KEYBINDING_SHOW_NOTE_MENU = "/apps/tomboy/global_keybindings/show_note_menu";
public const string KEYBINDING_OPEN_START_HERE = "/apps/tomboy/global_keybindings/open_start_here";
public const string KEYBINDING_CREATE_NEW_NOTE = "/apps/tomboy/global_keybindings/create_new_note";
public const string KEYBINDING_OPEN_SEARCH = "/apps/tomboy/global_keybindings/open_search";
public const string KEYBINDING_OPEN_RECENT_CHANGES = "/apps/tomboy/global_keybindings/open_recent_changes";
public const string EXPORTHTML_LAST_DIRECTORY = "/apps/tomboy/export_html/last_directory";
public const string EXPORTHTML_EXPORT_LINKED = "/apps/tomboy/export_html/export_linked";
public const string EXPORTHTML_EXPORT_LINKED_ALL = "/apps/tomboy/export_html/export_linked_all";
public const string STICKYNOTEIMPORTER_FIRST_RUN = "/apps/tomboy/sticky_note_importer/sticky_importer_first_run";
public const string SYNC_CLIENT_ID = "/apps/tomboy/sync/sync_guid";
public const string SYNC_LOCAL_PATH = "/apps/tomboy/sync/sync_local_path";
public const string SYNC_SELECTED_SERVICE_ADDIN = "/apps/tomboy/sync/sync_selected_service_addin";
public const string SYNC_CONFIGURED_CONFLICT_BEHAVIOR = "/apps/tomboy/sync/sync_conflict_behavior";
public const string SYNC_AUTOSYNC_TIMEOUT = "/apps/tomboy/sync/autosync_timeout";
public const string NOTE_RENAME_BEHAVIOR = "/apps/tomboy/note_rename_behavior";
public const string INSERT_TIMESTAMP_FORMAT = "/apps/tomboy/insert_timestamp/format";
public const string SEARCH_WINDOW_X_POS = "/apps/tomboy/search_window_x_pos";
public const string SEARCH_WINDOW_Y_POS = "/apps/tomboy/search_window_y_pos";
public const string SEARCH_WINDOW_WIDTH = "/apps/tomboy/search_window_width";
public const string SEARCH_WINDOW_HEIGHT = "/apps/tomboy/search_window_height";
public const string SEARCH_WINDOW_SPLITTER_POS = "/apps/tomboy/search_window_splitter_pos";
public const string SEARCH_WINDOW_MONITOR_NUM = "/apps/tomboy/search_window_monitor_num";
static IPreferencesClient client;
public static IPreferencesClient Client
{
get {
if (client == null) {
client = Services.Preferences;
client.AddNotify ("/apps/tomboy", OnSettingChanged);
}
return client;
}
}
// NOTE: Keep synced with tomboy.schemas.in
public static object GetDefault (string key)
{
switch (key) {
case ENABLE_SPELLCHECKING:
case ENABLE_KEYBINDINGS:
return true;
case ENABLE_CUSTOM_FONT:
return false;
case ENABLE_CUSTOM_SEARCH_MATCH_COLOR:
return false;
case ENABLE_WIKIWORDS:
return false;
case ENABLE_AUTO_BULLETED_LISTS:
return true;
case ENABLE_ICON_PASTE:
return false;
case ENABLE_CLOSE_NOTE_ON_ESCAPE:
return true;
case ENABLE_TRAY_ICON:
return true;
case ENABLE_DELETE_CONFIRM:
return true;
case START_NOTE_URI:
return String.Empty;
case CUSTOM_FONT_FACE:
return "Serif 11";
case CUSTOM_SEARCH_MATCH_COLOR:
return "#7cfc00"; // "lawngreen", provides good contrast with default font color
case MENU_NOTE_COUNT:
return 10;
case MENU_MAX_NOTE_COUNT:
return 18;
case MENU_PINNED_NOTES:
return string.Empty;
case MENU_ITEM_MAX_LENGTH:
return 100;
case KEYBINDING_SHOW_NOTE_MENU:
return "<Alt>F12";
case KEYBINDING_OPEN_START_HERE:
return "<Alt>F11";
case KEYBINDING_CREATE_NEW_NOTE:
case KEYBINDING_OPEN_SEARCH:
case KEYBINDING_OPEN_RECENT_CHANGES:
return "disabled";
case EXPORTHTML_EXPORT_LINKED:
return false;
case EXPORTHTML_EXPORT_LINKED_ALL:
return false;
case EXPORTHTML_LAST_DIRECTORY:
return string.Empty;
case STICKYNOTEIMPORTER_FIRST_RUN:
return true;
case ENABLE_STARTUP_NOTES:
return true;
case SYNC_CLIENT_ID:
return System.Guid.NewGuid ().ToString ();
case SYNC_LOCAL_PATH:
return string.Empty;
case SYNC_CONFIGURED_CONFLICT_BEHAVIOR:
return 0;
case SYNC_AUTOSYNC_TIMEOUT:
return -1;
case NOTE_RENAME_BEHAVIOR:
return 0;
case INSERT_TIMESTAMP_FORMAT:
return Catalog.GetString ("dddd, MMMM d, h:mm tt");
}
return null;
}
public static object Get (string key)
{
try {
return Client.Get (key);
} catch (NoSuchKeyException) {
object default_val = GetDefault (key);
if (default_val != null)
Client.Set (key, default_val);
return default_val;
}
}
public static void Set (string key, object value)
{
Client.Set (key, value);
}
public static event NotifyEventHandler SettingChanged;
static void OnSettingChanged (object sender, NotifyEventArgs args)
{
if (SettingChanged != null) {
SettingChanged (sender, args);
}
}
}
}