From 8a4bb00bec1dc67b488cbf31d4e866a3007cab57 Mon Sep 17 00:00:00 2001 From: Christopher Michael Date: Mon, 23 Nov 2009 17:26:51 +0000 Subject: [PATCH] Add config for illume2 module (for kbd slide duration, etc). SVN revision: 43932 --- src/modules/illume2/Makefile.am | 10 +++-- src/modules/illume2/e_kbd.c | 13 +++---- src/modules/illume2/e_mod_config.c | 59 ++++++++++++++++++++++++++++++ src/modules/illume2/e_mod_config.h | 32 ++++++++++++++++ src/modules/illume2/e_mod_main.c | 10 ++++- 5 files changed, 111 insertions(+), 13 deletions(-) create mode 100644 src/modules/illume2/e_mod_config.c create mode 100644 src/modules/illume2/e_mod_config.h diff --git a/src/modules/illume2/Makefile.am b/src/modules/illume2/Makefile.am index 23d8d7a75..94cf2b051 100644 --- a/src/modules/illume2/Makefile.am +++ b/src/modules/illume2/Makefile.am @@ -18,14 +18,16 @@ INCLUDES = -I. \ @e_cflags@ pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH) pkg_LTLIBRARIES = module.la -module_la_SOURCES = e_mod_main.c \ - e_mod_main.h \ +module_la_SOURCES = e_mod_main.h \ + e_mod_main.c \ e_mod_layout.h \ e_mod_layout.c \ - e_mod_layout_illume.c \ e_mod_layout_illume.h \ + e_mod_layout_illume.c \ e_kbd.h \ - e_kbd.c + e_kbd.c \ + e_mod_config.h \ + e_mod_config.c module_la_LIBADD = @e_libs@ @dlopen_libs@ module_la_LDFLAGS = -module -avoid-version diff --git a/src/modules/illume2/e_kbd.c b/src/modules/illume2/e_kbd.c index 76b607e51..b3d504698 100644 --- a/src/modules/illume2/e_kbd.c +++ b/src/modules/illume2/e_kbd.c @@ -1,6 +1,7 @@ #include "e.h" #include "e_kbd.h" #include "e_mod_layout.h" +#include "e_mod_config.h" static Eina_List *handlers = NULL; static Eina_List *kbds = NULL; @@ -133,8 +134,7 @@ static void _e_kbd_hide(E_Kbd *kbd) { if (kbd->visible) return; -#if 0 - if (illume_cfg->sliding.kbd.duration <= 0) + if (il_cfg->sliding.kbd.duration <= 0) { _e_kbd_border_hide(kbd->border); kbd->actually_visible = kbd->visible; @@ -142,8 +142,7 @@ _e_kbd_hide(E_Kbd *kbd) _e_kbd_layout_send(kbd); } else - _e_kbd_slide(kbd, 0, (double)illume_cfg->sliding.kbd.duration / 1000.0); -#endif + _e_kbd_slide(kbd, 0, (double)il_cfg->sliding.kbd.duration / 1000.0); } static int @@ -1023,8 +1022,7 @@ e_kbd_show(E_Kbd *kbd) if (kbd->disabled) return; kbd->actually_visible = kbd->visible; _e_kbd_layout_send(kbd); -#if 0 - if (illume_cfg->sliding.kbd.duration <= 0) + if (il_cfg->sliding.kbd.duration <= 0) { if (kbd->border) { @@ -1041,9 +1039,8 @@ e_kbd_show(E_Kbd *kbd) e_border_fx_offset(kbd->border, 0, kbd->border->h - kbd->adjust); _e_kbd_border_show(kbd, kbd->border); } - _e_kbd_slide(kbd, 1, (double)illume_cfg->sliding.kbd.duration / 1000.0); + _e_kbd_slide(kbd, 1, (double)il_cfg->sliding.kbd.duration / 1000.0); } -#endif } EAPI void diff --git a/src/modules/illume2/e_mod_config.c b/src/modules/illume2/e_mod_config.c new file mode 100644 index 000000000..c81cff647 --- /dev/null +++ b/src/modules/illume2/e_mod_config.c @@ -0,0 +1,59 @@ +#include "e.h" +#include "e_mod_main.h" +#include "e_mod_config.h" + +/* local variables */ +EAPI Il_Config *il_cfg = NULL; +static E_Config_DD *conf_edd = NULL; + +/* public functions */ +EAPI int +il_config_init(E_Module *m) +{ + conf_edd = E_CONFIG_DD_NEW("Illume_Cfg", Il_Config); + #undef T + #undef D + #define T Il_Config + #define D conf_edd + E_CONFIG_VAL(D, T, version, INT); + E_CONFIG_VAL(D, T, sliding.kbd.duration, INT); + E_CONFIG_VAL(D, T, sliding.softkey.duration, INT); + + il_cfg = e_config_domain_load("module.illume2", conf_edd); + if ((il_cfg) && + ((il_cfg->version >> 16) < IL_CONFIG_MAJ)) + { + E_FREE(il_cfg); + il_cfg = NULL; + } + if (!il_cfg) + { + il_cfg = E_NEW(Il_Config, 1); + il_cfg->version = 0; + il_cfg->sliding.kbd.duration = 1000; + il_cfg->sliding.softkey.duration = 1000; + } + if (il_cfg) + { + /* Add new config variables here */ + /* if ((il_cfg->version & 0xffff) < 1) */ + il_cfg->version = (IL_CONFIG_MAJ << 16) | IL_CONFIG_MIN; + } + il_cfg->mod_dir = eina_stringshare_add(m->dir); + return 1; +} + +EAPI int +il_config_shutdown(void) +{ + if (il_cfg->mod_dir) eina_stringshare_del(il_cfg->mod_dir); + E_FREE(il_cfg); + return 1; +} + +EAPI int +il_config_save(void) +{ + e_config_domain_save("module.illume2", conf_edd, il_cfg); + return 1; +} diff --git a/src/modules/illume2/e_mod_config.h b/src/modules/illume2/e_mod_config.h new file mode 100644 index 000000000..8bfabce52 --- /dev/null +++ b/src/modules/illume2/e_mod_config.h @@ -0,0 +1,32 @@ +#ifndef E_MOD_CONFIG_H +# define E_MOD_CONFIG_H + +# define IL_CONFIG_MIN 0 +# define IL_CONFIG_MAJ 0 + +typedef struct _Il_Config Il_Config; + +struct _Il_Config +{ + int version; + + struct + { + struct + { + int duration; + } kbd, softkey; + } sliding; + + // Not User Configurable. Placeholders + const char *mod_dir; + E_Config_Dialog *cfd; +}; + +EAPI int il_config_init(E_Module *m); +EAPI int il_config_shutdown(void); +EAPI int il_config_save(void); + +extern EAPI Il_Config *il_cfg; + +#endif diff --git a/src/modules/illume2/e_mod_main.c b/src/modules/illume2/e_mod_main.c index fcdf1b385..65b4c32b1 100644 --- a/src/modules/illume2/e_mod_main.c +++ b/src/modules/illume2/e_mod_main.c @@ -1,5 +1,6 @@ #include "e.h" #include "e_mod_main.h" +#include "e_mod_config.h" #include "e_mod_layout.h" #include "e_kbd.h" @@ -13,9 +14,15 @@ EAPI E_Module_Api e_modapi = { E_MODULE_API_VERSION, "Illume2" }; EAPI void * e_modapi_init(E_Module *m) { + /* init the config system */ + if (!il_config_init(m)) return NULL; + /* set up the virtual keyboard */ e_kbd_init(m); + + /* init the layout system */ e_mod_layout_init(m); + return m; /* return NULL on failure, anything else on success. the pointer * returned will be set as m->data for convenience tracking */ } @@ -26,6 +33,7 @@ e_modapi_shutdown(E_Module *m) { e_mod_layout_shutdown(); e_kbd_shutdown(); + il_config_shutdown(); return 1; /* 1 for success, 0 for failure */ } @@ -33,5 +41,5 @@ e_modapi_shutdown(E_Module *m) EAPI int e_modapi_save(E_Module *m) { - return 1; /* 1 for success, 0 for failure */ + return il_config_save(); }