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
22 #include <glib/gtypes.h>
23 #include <glib/glist.h>
31 #define CONFIG_MAX_KEYS 24
33 #define CONFIG_TYPE_NONE 0
34 #define CONFIG_TYPE_FILE 1
35 #define CONFIG_TYPE_PATH 2
36 #define CONFIG_TYPE_KEY 3
37 #define CONFIG_TYPE_FILELIST 4
38 #define CONFIG_TYPE_INTEGER 5
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 );
101 * Return a fully expanded path value for a key - this performs substitutions
102 * for ~ and simple shell variables ($VAR and ${VAR})
104 * The returned string is newly allocated and must be freed by the caller
106 gchar *lxdream_get_global_config_path_value( int key );
109 * Set a path value for a key, escaping if necessary to protect against
110 * shell-substitution on the round trip.
112 * @return the resultant config value.
114 const gchar *lxdream_set_global_config_path_value( int key, const gchar *value );
117 * Construct a list of strings for the given config key - The caller is
118 * responsible for freeing the list and its values.
120 GList *lxdream_get_global_config_list_value( int key );
123 * Set a config key based on a list of strings.
125 void lxdream_set_global_config_list_value( int key, const GList *list );
127 * Search the standard locations for the configuration file:
130 * $SYSCONF_DIR/lxdreamrc
131 * @return TRUE if the file was found, otherwise FALSE.
133 gboolean lxdream_find_config( );
136 * Set the configuration file filename to the supplied string.
137 * The string is copied internally (ie can be released by the
140 void lxdream_set_config_filename( const gchar *filename );
143 * Load the configuration from the previously determined filename.
145 gboolean lxdream_load_config( );
148 * Update the configuration
150 gboolean lxdream_save_config( );
153 * Make the user configuration directories if they don't already exist.
155 void lxdream_make_config_dir( );
161 #endif /* !lxdream_config_H */
.