diff options
author | Eduardo Lima (Etrunko) <eduardo.lima@intel.com> | 2014-10-22 16:26:44 -0200 |
---|---|---|
committer | Eduardo Lima (Etrunko) <eduardo.lima@intel.com> | 2014-10-27 18:47:24 -0200 |
commit | 063a46345cb7f814c2ef91d9db340ca093c2e0ea (patch) | |
tree | 18c0ede32f20fe4fac19f18fdf2e1b3b6796d8a2 | |
parent | ee736f2a405a3b5dac885714c788d2e6d526451a (diff) | |
download | weekeyboard-063a46345cb7f814c2ef91d9db340ca093c2e0ea.tar.gz weekeyboard-063a46345cb7f814c2ef91d9db340ca093c2e0ea.tar.bz2 weekeyboard-063a46345cb7f814c2ef91d9db340ca093c2e0ea.zip |
Add section id to struct wkb_config_key
Also make it available via accessor functions
Change-Id: Ie7642ffe80279923b3fa775723157e6ae438c167
Signed-off-by: Eduardo Lima (Etrunko) <eduardo.lima@intel.com>
-rw-r--r-- | src/wkb-ibus-config-eet.c | 2 | ||||
-rw-r--r-- | src/wkb-ibus-config-key.c | 27 | ||||
-rw-r--r-- | src/wkb-ibus-config-key.h | 9 |
3 files changed, 24 insertions, 14 deletions
diff --git a/src/wkb-ibus-config-eet.c b/src/wkb-ibus-config-eet.c index eee3b3c..4f455cf 100644 --- a/src/wkb-ibus-config-eet.c +++ b/src/wkb-ibus-config-eet.c @@ -175,7 +175,7 @@ end: #define _config_section_add_key(_section, _section_id, _key_type, _field) \ do { \ struct _config_ ## _section_id *__conf = (struct _config_ ## _section_id *) _section; \ - struct wkb_config_key *__key = wkb_config_key_ ## _key_type(#_field, &__conf->_field); \ + struct wkb_config_key *__key = wkb_config_key_ ## _key_type(#_field, _section->id, &__conf->_field); \ _section->keys = eina_list_append(_section->keys, __key); \ } while (0) diff --git a/src/wkb-ibus-config-key.c b/src/wkb-ibus-config-key.c index e44ce0a..1429c86 100644 --- a/src/wkb-ibus-config-key.c +++ b/src/wkb-ibus-config-key.c @@ -32,6 +32,7 @@ typedef Eina_Bool (*key_get_cb) (struct wkb_config_key *, Eldbus_Message_Iter *) struct wkb_config_key { const char *id; + const char *section; const char *signature; void *field; /* pointer to the actual struct field */ @@ -41,10 +42,11 @@ struct wkb_config_key }; static struct wkb_config_key * -_key_new(const char *id, const char *signature, void *field, key_free_cb free_cb, key_set_cb set_cb, key_get_cb get_cb) +_key_new(const char *id, const char *section, const char *signature, void *field, key_free_cb free_cb, key_set_cb set_cb, key_get_cb get_cb) { struct wkb_config_key *key = calloc(1, sizeof(*key)); key->id = eina_stringshare_add(id); + key->section = eina_stringshare_add(section); key->signature = eina_stringshare_add(signature); key->field = field; key->free = free_cb; @@ -189,27 +191,27 @@ _key_string_list_get(struct wkb_config_key *key, Eldbus_Message_Iter *reply) * PUBLIC FUNCTIONS */ struct wkb_config_key * -wkb_config_key_int(const char *id, void *field) +wkb_config_key_int(const char *id, const char *section, void *field) { - return _key_new(id, "i", field, NULL, _key_int_set, _key_int_get); + return _key_new(id, section, "i", field, NULL, _key_int_set, _key_int_get); } struct wkb_config_key * -wkb_config_key_bool(const char *id, void *field) +wkb_config_key_bool(const char *id, const char *section, void *field) { - return _key_new(id, "b", field, NULL, _key_bool_set, _key_bool_get); + return _key_new(id, section, "b", field, NULL, _key_bool_set, _key_bool_get); } struct wkb_config_key * -wkb_config_key_string(const char *id, void *field) +wkb_config_key_string(const char *id, const char *section, void *field) { - return _key_new(id, "s", field, (key_free_cb) _key_string_free, _key_string_set, _key_string_get); + return _key_new(id, section, "s", field, (key_free_cb) _key_string_free, _key_string_set, _key_string_get); } struct wkb_config_key * -wkb_config_key_string_list(const char *id, void *field) +wkb_config_key_string_list(const char *id, const char *section, void *field) { - return _key_new(id, "as", field, (key_free_cb) _key_string_list_free, _key_string_list_set, _key_string_list_get); + return _key_new(id, section, "as", field, (key_free_cb) _key_string_list_free, _key_string_list_set, _key_string_list_get); } void @@ -219,6 +221,7 @@ wkb_config_key_free(struct wkb_config_key *key) key->free(key->field); eina_stringshare_del(key->id); + eina_stringshare_del(key->section); eina_stringshare_del(key->signature); free(key); } @@ -230,6 +233,12 @@ wkb_config_key_id(struct wkb_config_key *key) } const char * +wkb_config_key_section(struct wkb_config_key *key) +{ + return key->section; +} + +const char * wkb_config_key_signature(struct wkb_config_key *key) { return key->signature; diff --git a/src/wkb-ibus-config-key.h b/src/wkb-ibus-config-key.h index f76f8aa..5706667 100644 --- a/src/wkb-ibus-config-key.h +++ b/src/wkb-ibus-config-key.h @@ -27,13 +27,14 @@ extern "C" { struct wkb_config_key; -struct wkb_config_key *wkb_config_key_int(const char *id, void *field); -struct wkb_config_key *wkb_config_key_bool(const char *id, void *field); -struct wkb_config_key *wkb_config_key_string(const char *id, void *field); -struct wkb_config_key *wkb_config_key_string_list(const char *id, void *field); +struct wkb_config_key *wkb_config_key_int(const char *id, const char *section, void *field); +struct wkb_config_key *wkb_config_key_bool(const char *id, const char *section, void *field); +struct wkb_config_key *wkb_config_key_string(const char *id, const char *section, void *field); +struct wkb_config_key *wkb_config_key_string_list(const char *id, const char *section, void *field); void wkb_config_key_free(struct wkb_config_key *key); const char *wkb_config_key_id(struct wkb_config_key *key); +const char *wkb_config_key_section(struct wkb_config_key *key); const char *wkb_config_key_signature(struct wkb_config_key *key); Eina_Bool wkb_config_key_set(struct wkb_config_key * key, Eldbus_Message_Iter *iter); Eina_Bool wkb_config_key_get(struct wkb_config_key *key, Eldbus_Message_Iter *reply); |