Imported Upstream version 0.0.5
[ptask-pkg-ubuntu.git] / src / settings.c
1 /*
2  * Copyright (C) 2012-2013 jeanfi@gmail.com
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License as
6  * published by the Free Software Foundation; either version 2 of the
7  * License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  * 02110-1301 USA
18  */
19
20 #include <settings.h>
21
22 const char *SETTINGS_KEY_WINDOW_WIDTH = "window-width";
23 const char *SETTINGS_KEY_WINDOW_HEIGHT = "window-height";
24 const char *SETTINGS_KEY_WINDOW_X = "window-x";
25 const char *SETTINGS_KEY_WINDOW_Y = "window-y";
26 const char *SETTINGS_KEY_SPLITER_VERTICAL_POS = "spliter-vertical-pos";
27 const char *SETTINGS_KEY_SPLITER_HORIZONTAL_POS = "spliter-horizontal-pos";
28 const char *SETTINGS_KEY_TASKS_SORT_COL = "tasks-sort-col";
29 const char *SETTINGS_KEY_TASKS_SORT_ORDER = "tasks-sort-order";
30 const char *SETTINGS_KEY_NOTES_DIR = "notes-dir";
31
32 const char * const SETTINGS_VISIBLE_COL_KEYS[] = {
33         "tasktree-id-visible",
34         "tasktree-description-visible",
35         "tasktree-project-visible",
36         "tasktree-uuid-visible",
37         "tasktree-priority-visible",
38         "tasktree-urgency-visible",
39         "tasktree-creation-date-visible",
40         "tasktree-due-visible",
41         "tasktree-start-visible",
42 };
43
44 static GSettings *settings;
45
46 void settings_init()
47 {
48         settings = g_settings_new("ptask");
49 }
50
51 gint settings_get_int(const gchar *key)
52 {
53         return g_settings_get_int(settings, key);
54 }
55
56 void settings_set_int(const gchar *key, gint value)
57 {
58         g_settings_set_int(settings, key, value);
59 }
60
61 gboolean settings_get_boolean(const gchar *key)
62 {
63         return g_settings_get_boolean(settings, key);
64 }
65
66 void settings_set_boolean(const gchar *key, gboolean value)
67 {
68         g_settings_set_boolean(settings, key, value);
69 }
70
71 gchar *settings_get_str(const gchar *key)
72 {
73         return g_settings_get_string(settings, key);
74 }
75
76 void settings_set_str(const gchar *key, const gchar *value)
77 {
78         g_settings_set_string(settings, key, value);
79 }
80
81 const char *settings_get_notes_dir()
82 {
83         return settings_get_str(SETTINGS_KEY_NOTES_DIR);
84 }
85
86 void settings_set_notes_dir(const char *dir)
87 {
88         settings_set_str(SETTINGS_KEY_NOTES_DIR, dir);
89 }