4 * User configuration support
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #ifndef lxdream_config_H
20 #define lxdream_config_H 1
30 #define CONFIG_MAX_KEYS 24
32 #define CONFIG_TYPE_NONE 0
33 #define CONFIG_TYPE_FILE 1
34 #define CONFIG_TYPE_PATH 2
35 #define CONFIG_TYPE_KEY 3
36 #define CONFIG_TYPE_FILELIST 4
37 #define CONFIG_TYPE_INTEGER 5
38 #define CONFIG_TYPE_BOOLEAN 6
40 #define DEFAULT_CONFIG_FILENAME "lxdreamrc"
42 typedef struct lxdream_config_entry {
44 const gchar *label; // i18n
46 const gchar *default_value;
49 } *lxdream_config_entry_t;
51 struct lxdream_config_group;
54 * Callback invoked for key presses (key-up/key-down).
56 typedef void (*key_binding_t)( void *data, uint32_t value, uint32_t pressure, gboolean isKeyDown );
59 * Callback invoked immediately before updating a configuration item.
60 * @return FALSE to abort the change (ie invalid value), or TRUE to proceed normally.
62 typedef gboolean (*config_change_callback_t)( void *data, struct lxdream_config_group *group, unsigned item,
63 const gchar *oldval, const gchar *newval );
65 typedef struct lxdream_config_group {
67 config_change_callback_t on_change;
68 key_binding_t key_binding;
70 struct lxdream_config_entry params[CONFIG_MAX_KEYS];
71 } *lxdream_config_group_t;
73 #define CONFIG_BIOS_PATH 0
74 #define CONFIG_FLASH_PATH 1
75 #define CONFIG_DEFAULT_PATH 2
76 #define CONFIG_SAVE_PATH 3
77 #define CONFIG_VMU_PATH 4
78 #define CONFIG_BOOTSTRAP 5
79 #define CONFIG_GDROM 6
80 #define CONFIG_RECENT 7
82 #define CONFIG_QUICK_STATE 9
83 #define CONFIG_KEY_MAX CONFIG_QUICK_STATE
85 #define CONFIG_GROUP_GLOBAL 0
86 #define CONFIG_GROUP_HOTKEYS 2
87 #define CONFIG_GROUP_SERIAL 3
90 /* Global config values */
91 const gchar *lxdream_get_global_config_value( int key );
92 struct lxdream_config_group * lxdream_get_config_group( int group );
93 void lxdream_set_global_config_value( int key, const gchar *value );
95 void lxdream_register_config_group( const gchar *key, lxdream_config_group_t group );
96 gboolean lxdream_set_config_value( lxdream_config_group_t group, int key, const gchar *value );
97 void lxdream_copy_config_group( lxdream_config_group_t dest, lxdream_config_group_t src );
98 void lxdream_clone_config_group( lxdream_config_group_t dest, lxdream_config_group_t src );
100 gboolean lxdream_get_config_boolean_value( lxdream_config_group_t group, int key );
101 gboolean lxdream_set_config_boolean_value( lxdream_config_group_t group, int key, gboolean value );
104 * Return a fully expanded path value for a key - this performs substitutions
105 * for ~ and simple shell variables ($VAR and ${VAR})
107 * The returned string is newly allocated and must be freed by the caller
109 gchar *lxdream_get_global_config_path_value( int key );
112 * Set a path value for a key, escaping if necessary to protect against
113 * shell-substitution on the round trip.
115 * @return the resultant config value.
117 const gchar *lxdream_set_global_config_path_value( int key, const gchar *value );
120 * Construct a list of strings for the given config key - The caller is
121 * responsible for freeing the list and its values.
123 GList *lxdream_get_global_config_list_value( int key );
126 * Set a config key based on a list of strings.
128 void lxdream_set_global_config_list_value( int key, const GList *list );
130 * Search the standard locations for the configuration file:
133 * $SYSCONF_DIR/lxdreamrc
134 * @return TRUE if the file was found, otherwise FALSE.
136 gboolean lxdream_find_config( );
139 * Set the configuration file filename to the supplied string.
140 * The string is copied internally (ie can be released by the
143 void lxdream_set_config_filename( const gchar *filename );
146 * Load the configuration from the previously determined filename.
148 gboolean lxdream_load_config( );
151 * Update the configuration
153 gboolean lxdream_save_config( );
156 * Make the user configuration directories if they don't already exist.
158 void lxdream_make_config_dir( );
164 #endif /* !lxdream_config_H */
.