Search
lxdream.org :: lxdream/src/config.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/config.h
changeset 1144:00dd49743974
prev1072:d82e04e6d497
next1296:30ecee61f811
author nkeynes
date Fri Mar 02 23:49:10 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Android WIP:
* Rename gui_jni.c to gui_android.c - now quite android specific.
* Implement generic EGL driver with very minimal Java wrapper
* Run emulation in separate thread, and implement simple queue for
inter-thread communication.
* Add menu/action-bar items for start + reset
view annotate diff log raw
     1 /**
     2  * $Id$
     3  *
     4  * User configuration support
     5  *
     6  * Copyright (c) 2005 Nathan Keynes.
     7  *
     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.
    12  *
    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.
    17  */
    19 #ifndef lxdream_config_H
    20 #define lxdream_config_H 1
    22 #include <glib/gtypes.h>
    23 #include <glib/glist.h>
    24 #include "lxdream.h"
    25 #include "gettext.h"
    27 #ifdef __cplusplus
    28 extern "C" {
    29 #endif
    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
    39 #define CONFIG_TYPE_BOOLEAN 6
    41 #define DEFAULT_CONFIG_FILENAME "lxdreamrc"
    43 typedef struct lxdream_config_entry {
    44     const gchar *key;
    45     const gchar *label; // i18n 
    46     int type;
    47     const gchar *default_value;
    48     uint32_t tag;
    49     gchar *value;
    50 } *lxdream_config_entry_t;
    52 struct lxdream_config_group;
    54 /**
    55  * Callback invoked for key presses (key-up/key-down).
    56  */
    57 typedef void (*key_binding_t)( void *data, uint32_t value, uint32_t pressure, gboolean isKeyDown );
    59 /**
    60  * Callback invoked immediately before updating a configuration item.
    61  * @return FALSE to abort the change (ie invalid value), or TRUE to proceed normally. 
    62  */
    63 typedef gboolean (*config_change_callback_t)( void *data, struct lxdream_config_group *group, unsigned item,
    64                                    const gchar *oldval, const gchar *newval );
    66 typedef struct lxdream_config_group {
    67     const gchar *key;
    68     config_change_callback_t on_change;
    69     key_binding_t key_binding;
    70     void *data;
    71     struct lxdream_config_entry params[CONFIG_MAX_KEYS];
    72 } *lxdream_config_group_t;
    74 #define CONFIG_BIOS_PATH 0
    75 #define CONFIG_FLASH_PATH 1
    76 #define CONFIG_DEFAULT_PATH 2
    77 #define CONFIG_SAVE_PATH 3
    78 #define CONFIG_VMU_PATH 4
    79 #define CONFIG_BOOTSTRAP 5
    80 #define CONFIG_GDROM 6
    81 #define CONFIG_RECENT 7
    82 #define CONFIG_VMU 8
    83 #define CONFIG_QUICK_STATE 9
    84 #define CONFIG_KEY_MAX CONFIG_QUICK_STATE
    86 #define CONFIG_GROUP_GLOBAL 0
    87 #define CONFIG_GROUP_HOTKEYS 2
    88 #define CONFIG_GROUP_SERIAL 3
    91 /* Global config values */
    92 const gchar *lxdream_get_global_config_value( int key );
    93 struct lxdream_config_group * lxdream_get_config_group( int group );
    94 void lxdream_set_global_config_value( int key, const gchar *value );
    96 void lxdream_register_config_group( const gchar *key, lxdream_config_group_t group ); 
    97 gboolean lxdream_set_config_value( lxdream_config_group_t group, int key, const gchar *value );
    98 void lxdream_copy_config_group( lxdream_config_group_t dest, lxdream_config_group_t src );
    99 void lxdream_clone_config_group( lxdream_config_group_t dest, lxdream_config_group_t src );
   101 gboolean lxdream_get_config_boolean_value( lxdream_config_group_t group, int key );
   102 gboolean lxdream_set_config_boolean_value( lxdream_config_group_t group, int key, gboolean value );
   104 /**
   105  * Return a fully expanded path value for a key - this performs substitutions
   106  * for ~ and simple shell variables ($VAR and ${VAR})
   107  * 
   108  * The returned string is newly allocated and must be freed by the caller
   109  */
   110 gchar *lxdream_get_global_config_path_value( int key );
   112 /**
   113  * Set a path value for a key, escaping if necessary to protect against 
   114  * shell-substitution on the round trip.
   115  * 
   116  * @return the resultant config value.
   117  */
   118 const gchar *lxdream_set_global_config_path_value( int key, const gchar *value );
   120 /**
   121  * Construct a list of strings for the given config key - The caller is 
   122  * responsible for freeing the list and its values.
   123  */
   124 GList *lxdream_get_global_config_list_value( int key );
   126 /**
   127  * Set a config key based on a list of strings. 
   128  */
   129 void lxdream_set_global_config_list_value( int key, const GList *list );
   130 /**
   131  * Search the standard locations for the configuration file:
   132  *   $HOME/.lxdreamrc
   133  *   $CWD/lxdreamrc
   134  *   $SYSCONF_DIR/lxdreamrc
   135  * @return TRUE if the file was found, otherwise FALSE.
   136  */
   137 gboolean lxdream_find_config( );
   139 /**
   140  * Set the configuration file filename to the supplied string.
   141  * The string is copied internally (ie can be released by the
   142  * caller).
   143  */
   144 void lxdream_set_config_filename( const gchar *filename );
   146 /**
   147  * Load the configuration from the previously determined filename.
   148  */
   149 gboolean lxdream_load_config( );
   151 /**
   152  * Update the configuration
   153  */
   154 gboolean lxdream_save_config( );
   156 /**
   157  * Make the user configuration directories if they don't already exist.
   158  */ 
   159 void lxdream_make_config_dir( );
   161 #ifdef __cplusplus
   162 }
   163 #endif
   165 #endif /* !lxdream_config_H */
.