Search
lxdream.org :: lxdream/src/config.h
lxdream 0.9.1
released Jun 29
Download Now
filename src/config.h
changeset 1296:30ecee61f811
prev1144:00dd49743974
author nkeynes
date Sun May 24 19:46:06 2015 +1000 (8 years ago)
permissions -rw-r--r--
last change Remove static from gl_load_frame_buffer() - also needed by video_egl.c
Fix error location in gl_frame_buffer_to_tex
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.h>
    23 #include "lxdream.h"
    24 #include "gettext.h"
    26 #ifdef __cplusplus
    27 extern "C" {
    28 #endif
    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 {
    43     const gchar *key;
    44     const gchar *label; // i18n 
    45     int type;
    46     const gchar *default_value;
    47     uint32_t tag;
    48     gchar *value;
    49 } *lxdream_config_entry_t;
    51 struct lxdream_config_group;
    53 /**
    54  * Callback invoked for key presses (key-up/key-down).
    55  */
    56 typedef void (*key_binding_t)( void *data, uint32_t value, uint32_t pressure, gboolean isKeyDown );
    58 /**
    59  * Callback invoked immediately before updating a configuration item.
    60  * @return FALSE to abort the change (ie invalid value), or TRUE to proceed normally. 
    61  */
    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 {
    66     const gchar *key;
    67     config_change_callback_t on_change;
    68     key_binding_t key_binding;
    69     void *data;
    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
    81 #define CONFIG_VMU 8
    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 );
   103 /**
   104  * Return a fully expanded path value for a key - this performs substitutions
   105  * for ~ and simple shell variables ($VAR and ${VAR})
   106  * 
   107  * The returned string is newly allocated and must be freed by the caller
   108  */
   109 gchar *lxdream_get_global_config_path_value( int key );
   111 /**
   112  * Set a path value for a key, escaping if necessary to protect against 
   113  * shell-substitution on the round trip.
   114  * 
   115  * @return the resultant config value.
   116  */
   117 const gchar *lxdream_set_global_config_path_value( int key, const gchar *value );
   119 /**
   120  * Construct a list of strings for the given config key - The caller is 
   121  * responsible for freeing the list and its values.
   122  */
   123 GList *lxdream_get_global_config_list_value( int key );
   125 /**
   126  * Set a config key based on a list of strings. 
   127  */
   128 void lxdream_set_global_config_list_value( int key, const GList *list );
   129 /**
   130  * Search the standard locations for the configuration file:
   131  *   $HOME/.lxdreamrc
   132  *   $CWD/lxdreamrc
   133  *   $SYSCONF_DIR/lxdreamrc
   134  * @return TRUE if the file was found, otherwise FALSE.
   135  */
   136 gboolean lxdream_find_config( );
   138 /**
   139  * Set the configuration file filename to the supplied string.
   140  * The string is copied internally (ie can be released by the
   141  * caller).
   142  */
   143 void lxdream_set_config_filename( const gchar *filename );
   145 /**
   146  * Load the configuration from the previously determined filename.
   147  */
   148 gboolean lxdream_load_config( );
   150 /**
   151  * Update the configuration
   152  */
   153 gboolean lxdream_save_config( );
   155 /**
   156  * Make the user configuration directories if they don't already exist.
   157  */ 
   158 void lxdream_make_config_dir( );
   160 #ifdef __cplusplus
   161 }
   162 #endif
   164 #endif /* !lxdream_config_H */
.