1 /*
2  * Nautilus-Actions
3  * A Nautilus extension which offers configurable context menu modules.
4  *
5  * Copyright (C) 2005 The GNOME Foundation
6  * Copyright (C) 2006-2008 Frederic Ruaudel and others (see AUTHORS)
7  * Copyright (C) 2009-2014 Pierre Wieser and others (see AUTHORS)
8  *
9  * Nautilus-Actions is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License as
11  * published by the Free Software Foundation; either version 2 of
12  * the License, or (at your option) any later version.
13  *
14  * Nautilus-Actions is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with Nautilus-Actions; see the file COPYING. If not, see
21  * <http://www.gnu.org/licenses/>.
22  *
23  * Authors:
24  *   Frederic Ruaudel <grumz@grumz.net>
25  *   Rodrigo Moya <rodrigo@gnome-db.org>
26  *   Pierre Wieser <pwieser@trychlos.org>
27  *   ... and many others (see AUTHORS)
28  */
29 
30 #ifndef __CORE_NA_SETTINGS_H__
31 #define __CORE_NA_SETTINGS_H__
32 
33 /* @title: NASettings
34  * @short_description: The Settings Class Definition
35  * @include: core/na-settings.h
36  *
37  * The #NASettings class manages users preferences.
38  *
39  * Actual configuration may come from two sources:
40  * - a global configuration, which apply to all users, as read-only
41  *   parameters;
42  * - a per-user configuration.
43  *
44  * The configuration is implemented as keyed files:
45  * - global configuration is sysconfdir/xdg/nautilus-actions/nautilus-actions.conf
46  * - per-user configuration is HOME/.config/nautilus-actions/nautilus-actions.conf
47  *
48  * Each setting may so have its own read-only attribute, whether it
49  * has been read from the global configuration or from the
50  * per-user one.
51  *
52  * NASettings class monitors the whole configuration.
53  * A client may be informed of a modification of the value of a key either by
54  * pre-registering a callback on this key (see na_settings_register_key_callback()
55  * function), or by connecting to and filtering the notification signal.
56  *
57  * #NASettings class defines a singleton object, which allocates itself
58  * when needed
59  */
60 
61 #include <glib-object.h>
62 
63 G_BEGIN_DECLS
64 
65 /* This is a composite key;
66  * by registering a callback on this key, a client may be informed of any
67  * modification regarding the readability status of the i/o providers.
68  */
69 #define NA_IPREFS_IO_PROVIDERS_READ_STATUS			"io-providers-read-status-composite-key"
70 
71 /* other keys, mainly user preferences
72  */
73 #define NA_IPREFS_ADMIN_PREFERENCES_LOCKED			"preferences-locked"
74 #define NA_IPREFS_ADMIN_IO_PROVIDERS_LOCKED			"io-providers-locked"
75 #define NA_IPREFS_ASSISTANT_ESC_CONFIRM				"assistant-esc-confirm"
76 #define NA_IPREFS_ASSISTANT_ESC_QUIT				"assistant-esc-quit"
77 #define NA_IPREFS_CAPABILITY_ADD_CAPABILITY_WSP		"capability-add-capability-wsp"
78 #define NA_IPREFS_COMMAND_CHOOSER_WSP				"command-command-chooser-wsp"
79 #define NA_IPREFS_COMMAND_CHOOSER_URI				"command-command-chooser-lfu"
80 #define NA_IPREFS_COMMAND_LEGEND_WSP				"command-legend-wsp"
81 #define NA_IPREFS_DESKTOP_ENVIRONMENT				"desktop-environment"
82 #define NA_IPREFS_CONFIRM_LOGOUT_WSP				"confirm-logout-wsp"
83 #define NA_IPREFS_WORKING_DIR_WSP					"command-working-dir-chooser-wsp"
84 #define NA_IPREFS_WORKING_DIR_URI					"command-working-dir-chooser-lfu"
85 #define NA_IPREFS_SHOW_IF_RUNNING_WSP				"environment-show-if-running-wsp"
86 #define NA_IPREFS_SHOW_IF_RUNNING_URI				"environment-show-if-running-lfu"
87 #define NA_IPREFS_TRY_EXEC_WSP						"environment-try-exec-wsp"
88 #define NA_IPREFS_TRY_EXEC_URI						"environment-try-exec-lfu"
89 #define NA_IPREFS_EXPORT_ASK_USER_WSP				"export-ask-user-wsp"
90 #define NA_IPREFS_EXPORT_ASK_USER_LAST_FORMAT		"export-ask-user-last-format"
91 #define NA_IPREFS_EXPORT_ASK_USER_KEEP_LAST_CHOICE	"export-ask-user-keep-last-choice"
92 #define NA_IPREFS_EXPORT_ASSISTANT_WSP				"export-assistant-wsp"
93 #define NA_IPREFS_EXPORT_ASSISTANT_URI				"export-assistant-lfu"
94 #define NA_IPREFS_EXPORT_ASSISTANT_PANED			"export-assistant-paned-width"
95 #define NA_IPREFS_EXPORT_PREFERRED_FORMAT			"export-preferred-format"
96 #define NA_IPREFS_FOLDER_CHOOSER_WSP				"folder-chooser-wsp"
97 #define NA_IPREFS_FOLDER_CHOOSER_URI				"folder-chooser-lfu"
98 #define NA_IPREFS_IMPORT_ASK_USER_WSP				"import-ask-user-wsp"
99 #define NA_IPREFS_IMPORT_ASK_USER_LAST_MODE			"import-ask-user-last-mode"
100 #define NA_IPREFS_IMPORT_ASSISTANT_WSP				"import-assistant-wsp"
101 #define NA_IPREFS_IMPORT_ASSISTANT_URI				"import-assistant-lfu"
102 #define NA_IPREFS_IMPORT_ASK_USER_KEEP_LAST_CHOICE	"import-ask-user-keep-last-choice"
103 #define NA_IPREFS_IMPORT_PREFERRED_MODE				"import-preferred-mode"
104 #define NA_IPREFS_ICON_CHOOSER_URI					"item-icon-chooser-lfu"
105 #define NA_IPREFS_ICON_CHOOSER_PANED				"item-icon-chooser-paned-width"
106 #define NA_IPREFS_ICON_CHOOSER_WSP					"item-icon-chooser-wsp"
107 #define NA_IPREFS_IO_PROVIDERS_WRITE_ORDER			"io-providers-write-order"
108 #define NA_IPREFS_ITEMS_ADD_ABOUT_ITEM				"items-add-about-item"
109 #define NA_IPREFS_ITEMS_CREATE_ROOT_MENU			"items-create-root-menu"
110 #define NA_IPREFS_ITEMS_LEVEL_ZERO_ORDER			"items-level-zero-order"
111 #define NA_IPREFS_ITEMS_LIST_ORDER_MODE				"items-list-order-mode"
112 #define NA_IPREFS_MAIN_PANED						"main-paned-width"
113 #define NA_IPREFS_MAIN_SAVE_AUTO					"main-save-auto"
114 #define NA_IPREFS_MAIN_SAVE_PERIOD					"main-save-period"
115 #define NA_IPREFS_MAIN_TABS_POS						"main-tabs-pos"
116 #define NA_IPREFS_MAIN_TOOLBAR_EDIT_DISPLAY			"main-toolbar-edit-display"
117 #define NA_IPREFS_MAIN_TOOLBAR_FILE_DISPLAY			"main-toolbar-file-display"
118 #define NA_IPREFS_MAIN_TOOLBAR_HELP_DISPLAY			"main-toolbar-help-display"
119 #define NA_IPREFS_MAIN_TOOLBAR_TOOLS_DISPLAY		"main-toolbar-tools-display"
120 #define NA_IPREFS_MAIN_WINDOW_WSP					"main-window-wsp"
121 #define NA_IPREFS_PREFERENCES_WSP					"preferences-wsp"
122 #define NA_IPREFS_PLUGIN_MENU_LOG					"plugin-menu-log-enabled"
123 #define NA_IPREFS_RELABEL_DUPLICATE_ACTION			"relabel-when-duplicate-action"
124 #define NA_IPREFS_RELABEL_DUPLICATE_MENU			"relabel-when-duplicate-menu"
125 #define NA_IPREFS_RELABEL_DUPLICATE_PROFILE			"relabel-when-duplicate-profile"
126 #define NA_IPREFS_SCHEME_ADD_SCHEME_WSP				"scheme-add-scheme-wsp"
127 #define NA_IPREFS_SCHEME_DEFAULT_LIST				"scheme-default-list"
128 #define NA_IPREFS_TERMINAL_PATTERN					"terminal-pattern"
129 
130 #define NA_IPREFS_IO_PROVIDER_GROUP					"io-provider"
131 #define NA_IPREFS_IO_PROVIDER_READABLE				"readable"
132 #define NA_IPREFS_IO_PROVIDER_WRITABLE				"writable"
133 
134 /* pre-registration of a callback
135  */
136 typedef void ( *NASettingsKeyCallback )( const gchar *group, const gchar *key, gconstpointer new_value, gboolean mandatory, void *user_data );
137 
138 void      na_settings_register_key_callback( const gchar *key, GCallback callback, gpointer user_data );
139 
140 /* signal sent when the value of a key changes
141  */
142 #define SETTINGS_SIGNAL_KEY_CHANGED					"settings-key-changed"
143 
144 void      na_settings_free                 ( void );
145 
146 gboolean  na_settings_get_boolean          ( const gchar *key, gboolean *found, gboolean *mandatory );
147 gboolean  na_settings_get_boolean_ex       ( const gchar *group, const gchar *key, gboolean *found, gboolean *mandatory );
148 gchar    *na_settings_get_string           ( const gchar *key, gboolean *found, gboolean *mandatory );
149 GSList   *na_settings_get_string_list      ( const gchar *key, gboolean *found, gboolean *mandatory );
150 guint     na_settings_get_uint             ( const gchar *key, gboolean *found, gboolean *mandatory );
151 GList    *na_settings_get_uint_list        ( const gchar *key, gboolean *found, gboolean *mandatory );
152 
153 gboolean  na_settings_set_boolean          ( const gchar *key, gboolean value );
154 gboolean  na_settings_set_boolean_ex       ( const gchar *group, const gchar *key, gboolean value );
155 gboolean  na_settings_set_string           ( const gchar *key, const gchar *value );
156 gboolean  na_settings_set_string_ex        ( const gchar *group, const gchar *key, const gchar *value );
157 gboolean  na_settings_set_string_list      ( const gchar *key, const GSList *value );
158 gboolean  na_settings_set_int_ex           ( const gchar *group, const gchar *key, int value );
159 gboolean  na_settings_set_uint             ( const gchar *key, guint value );
160 gboolean  na_settings_set_uint_list        ( const gchar *key, const GList *value );
161 
162 GSList   *na_settings_get_groups           ( void );
163 
164 G_END_DECLS
165 
166 #endif /* __CORE_NA_SETTINGS_H__ */
167