Search
lxdream.org :: lxdream/src/config.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/config.h
changeset 1072:d82e04e6d497
prev1041:5fcc39857c5c
next1144:00dd49743974
author nkeynes
date Tue Jul 21 20:33:21 2009 +1000 (12 years ago)
permissions -rw-r--r--
last change Heavy configuration management refactor
- Configuration groups now take both an on_change event handler and a
default keybinding handler, making most keybinding tasks quite simple
- GUI configuration all merged into a unified model, drastically reducing
the amount of GUI config code.

Bonuses
- OSX now has a hotkey preference pane
- GTK keybinding editor is much more usable
file annotate diff log raw
1.1 --- a/src/config.h Fri Jun 26 05:47:04 2009 +0000
1.2 +++ b/src/config.h Tue Jul 21 20:33:21 2009 +1000
1.3 @@ -21,12 +21,15 @@
1.4
1.5 #include <glib/gtypes.h>
1.6 #include <glib/glist.h>
1.7 +#include "lxdream.h"
1.8 #include "gettext.h"
1.9
1.10 #ifdef __cplusplus
1.11 extern "C" {
1.12 #endif
1.13
1.14 +#define CONFIG_MAX_KEYS 24
1.15 +
1.16 #define CONFIG_TYPE_NONE 0
1.17 #define CONFIG_TYPE_FILE 1
1.18 #define CONFIG_TYPE_PATH 2
1.19 @@ -39,14 +42,32 @@
1.20 typedef struct lxdream_config_entry {
1.21 const gchar *key;
1.22 const gchar *label; // i18n
1.23 - const int type;
1.24 + int type;
1.25 const gchar *default_value;
1.26 + uint32_t tag;
1.27 gchar *value;
1.28 } *lxdream_config_entry_t;
1.29
1.30 +struct lxdream_config_group;
1.31 +
1.32 +/**
1.33 + * Callback invoked for key presses (key-up/key-down).
1.34 + */
1.35 +typedef void (*key_binding_t)( void *data, uint32_t value, uint32_t pressure, gboolean isKeyDown );
1.36 +
1.37 +/**
1.38 + * Callback invoked immediately before updating a configuration item.
1.39 + * @return FALSE to abort the change (ie invalid value), or TRUE to proceed normally.
1.40 + */
1.41 +typedef gboolean (*config_change_callback_t)( void *data, struct lxdream_config_group *group, unsigned item,
1.42 + const gchar *oldval, const gchar *newval );
1.43 +
1.44 typedef struct lxdream_config_group {
1.45 const gchar *key;
1.46 - struct lxdream_config_entry *params;
1.47 + config_change_callback_t on_change;
1.48 + key_binding_t key_binding;
1.49 + void *data;
1.50 + struct lxdream_config_entry params[CONFIG_MAX_KEYS];
1.51 } *lxdream_config_group_t;
1.52
1.53 #define CONFIG_BIOS_PATH 0
1.54 @@ -61,17 +82,20 @@
1.55 #define CONFIG_QUICK_STATE 9
1.56 #define CONFIG_KEY_MAX CONFIG_QUICK_STATE
1.57
1.58 -extern struct lxdream_config_group lxdream_config_root[];
1.59 +#define CONFIG_GROUP_GLOBAL 0
1.60 +#define CONFIG_GROUP_HOTKEYS 2
1.61 +#define CONFIG_GROUP_SERIAL 3
1.62 +
1.63
1.64 /* Global config values */
1.65 const gchar *lxdream_get_global_config_value( int key );
1.66 -const struct lxdream_config_entry * lxdream_get_global_config_entry( int key );
1.67 +struct lxdream_config_group * lxdream_get_config_group( int group );
1.68 void lxdream_set_global_config_value( int key, const gchar *value );
1.69
1.70 -void lxdream_register_config_group( const gchar *key, lxdream_config_entry_t group );
1.71 -void lxdream_set_config_value( lxdream_config_entry_t entry, const gchar *value );
1.72 -gboolean lxdream_set_group_value( lxdream_config_group_t group, const gchar *key, const gchar *value );
1.73 -void lxdream_copy_config_list( lxdream_config_entry_t dest, lxdream_config_entry_t src );
1.74 +void lxdream_register_config_group( const gchar *key, lxdream_config_group_t group );
1.75 +gboolean lxdream_set_config_value( lxdream_config_group_t group, int key, const gchar *value );
1.76 +void lxdream_copy_config_group( lxdream_config_group_t dest, lxdream_config_group_t src );
1.77 +void lxdream_clone_config_group( lxdream_config_group_t dest, lxdream_config_group_t src );
1.78
1.79 /**
1.80 * Return a fully expanded path value for a key - this performs substitutions
.